// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/asf.c
// Function: handler_ECD_or_metadata
static void handler_ECD_or_metadata(deark *c, lctx *d, struct handler_params *hp)
{
	i64 descr_count;
	i64 k;
	i64 pos = hp->dpos;

	descr_count = de_getu16le_p(&pos);
	de_dbg(c, "descriptor count: %d", (int)descr_count);

	for(k=0; k<descr_count; k++) {
		i64 bytes_consumed = 0;
		int ret;

		if(pos >= hp->dpos + hp->dlen) {
			break;
		}
		if(hp->uui->short_id==SID_ECD) {
			ret = do_ECD_entry(c, d, pos, hp->dpos+hp->dlen-pos, &bytes_consumed);
		}
		else if(hp->uui->short_id==SID_METADATA || hp->uui->short_id==SID_METADATALIB) {
			ret = do_metadata_entry(c, d, hp, pos, hp->dpos+hp->dlen-pos, &bytes_consumed);
		}
		else {
			break;
		}
		if(!ret || (bytes_consumed<6)) break;
		pos += bytes_consumed;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rdi, %r14
movq 0x10(%rdx), %rax
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%rdi), %rdi
callq 0xe3fc4
movq %rax, %r12
leaq 0xe6c07(%rip), %rsi     # 0x1056e0
xorl %ebx, %ebx
movq %r14, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
testq %r12, %r12
cmovleq %rbx, %r12
movq %r12, %rbx
movq %r15, 0x18(%rsp)
subq $0x1, %rbx
jb 0x1ee4d
movq 0x20(%rsp), %r12
movq 0x18(%r15), %r13
addq 0x10(%r15), %r13
subq %r12, %r13
jle 0x1ee4d
movq 0x28(%r15), %rax
movl (%rax), %eax
leal -0x133(%rax), %ecx
cmpl $0x2, %ecx
jae 0x1ece0
movq %rbx, 0x10(%rsp)
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0xe6c8c(%rip), %rsi     # 0x1057da
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movl $0x0, %r15d
movl $0x0, %ebx
cmpq $0xe, %r13
jl 0x1ecbf
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rax
cmpl $0x134, (%rax)          # imm = 0x134
jne 0x1eba8
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xe3fa3
movq %r14, %rdi
leaq 0xe6c52(%rip), %rsi     # 0x1057f1
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x2(%r12), %rax
movq %rax, (%rsp)
movq 0x18(%r14), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0xe3fc4
movq %r14, %rdi
leaq 0xe6c3f(%rip), %rsi     # 0x105809
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xe3fc4
movq %rax, %r15
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xe3fc4
movq %rax, %r13
leaq 0x1002e9(%rip), %rcx    # 0x11eee1
cmpl $0x6, %r13d
ja 0x1ec0f
movl %r13d, %eax
andl $0x7, %eax
leaq 0x162515(%rip), %rcx    # 0x181120
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xe6aee(%rip), %rsi     # 0x105707
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xe40bf
cmpq $0x3, %r15
movq %r15, %rcx
pushq $0x2
popq %rdx
cmovlq %rdx, %rcx
movl $0x102, %edx            # imm = 0x102
cmpq %rdx, %rcx
cmovgeq %rdx, %rcx
movq %rax, %rbp
addq $-0x2, %rcx
movq 0x18(%r14), %rdi
movq (%rsp), %rsi
movq %rcx, %rdx
pushq $0x10
popq %r8
pushq $0x3
popq %r9
callq 0xe495c
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0xeb877
movq %r14, %rdi
leaq 0xf693d(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq (%rsp), %rsi
addq %r15, %rsi
movq %rsi, (%rsp)
movq 0x18(%rsp), %rax
movq 0x28(%rax), %rax
movl (%rax), %r9d
movq %r14, %rdi
movq %rbp, %rdx
movl %r13d, %ecx
movq %rbx, %r8
callq 0x1f6bf
addq (%rsp), %rbp
movq %rbp, (%rsp)
subq %r12, %rbp
pushq $0x1
popq %r15
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe4b94
movq 0x10(%rsp), %rbx
jmp 0x1ee33
cmpl $0xd2, %eax
jne 0x1ee4d
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0xe69ed(%rip), %rsi     # 0x1056f5
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movl $0x0, %r15d
cmpq $0x6, %r13
movl $0x0, %r13d
jl 0x1ee1c
movq %rbx, 0x10(%rsp)
movq 0x18(%r14), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rax, %rbx
cmpq $0x3, %rax
pushq $0x2
popq %rcx
cmovgeq %rax, %rcx
movl $0x102, %eax            # imm = 0x102
cmpq %rax, %rcx
cmovgeq %rax, %rcx
addq $-0x2, %rcx
movq 0x18(%r14), %rdi
movq (%rsp), %rsi
movq %rcx, %rdx
pushq $0x10
popq %r8
pushq $0x3
popq %r9
callq 0xe495c
movq %rax, %r13
movq 0x18(%rax), %rdi
callq 0xeb877
movq %r14, %rdi
leaq 0xf6828(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq %rbx, (%rsp)
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, %rbx
leaq 0x10012a(%rip), %rcx    # 0x11eee1
cmpl $0x6, %ebx
ja 0x1edcc
movl %ebx, %eax
andl $0x7, %eax
leaq 0x162358(%rip), %rcx    # 0x181120
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xe6931(%rip), %rsi     # 0x105707
movl %ebx, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq (%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
movq %r13, %r8
movl $0xd2, %r9d
callq 0x1f6bf
addq (%rsp), %rbp
movq %rbp, (%rsp)
subq %r12, %rbp
pushq $0x1
popq %r15
movq 0x10(%rsp), %rbx
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
movq %r14, %rdi
movq %r13, %rsi
callq 0xe4b94
testl %r15d, %r15d
movq 0x18(%rsp), %r15
je 0x1ee4d
cmpq $0x6, %rbp
jl 0x1ee4d
addq %rbp, 0x20(%rsp)
jmp 0x1eaf7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq