// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rdi, %r14
movq 0x10(%rdx), %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
movq 0x18(%rdi), %rdi
callq 0xef1ed
movq %rax, %r15
leaq 0xf37a0(%rip), %rsi     # 0x1126f0
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
testq %r15, %r15
jle 0x1f295
movq %rbx, 0x10(%rsp)
movq 0x18(%rsp), %r13
movq 0x18(%rbx), %rbp
addq 0x10(%rbx), %rbp
subq %r13, %rbp
jle 0x1f295
movq 0x28(%rbx), %rax
movl (%rax), %eax
leal -0x133(%rax), %ecx
cmpl $0x2, %ecx
movq %r15, 0x20(%rsp)
jae 0x1f11c
movq %r13, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe958c
xorl %r12d, %r12d
movq %r14, %rdi
leaq 0xf3831(%rip), %rsi     # 0x1127ea
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0x0, %r15d
movl $0x0, %ebx
cmpq $0xe, %rbp
jl 0x1f25b
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
cmpl $0x134, (%rax)          # imm = 0x134
jne 0x1f016
movq 0x18(%r14), %rdi
movq (%rsp), %rsi
callq 0xef1ca
movq %r14, %rdi
leaq 0xf37f4(%rip), %rsi     # 0x112801
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
addq $0x2, (%rsp)
movq 0x18(%r14), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0xef1ed
movq %r14, %rdi
leaq 0xf37e5(%rip), %rsi     # 0x112819
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xef1ed
movq %rax, %r15
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xef1ed
movq %rax, %rbp
leaq 0x10ce07(%rip), %rcx    # 0x12be69
cmpl $0x6, %ebp
ja 0x1f077
movl %ebp, %eax
andl $0x7, %eax
leaq 0x15efcd(%rip), %rcx    # 0x17e040
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xf3696(%rip), %rsi     # 0x112717
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xef3a0
cmpq $0x3, %r15
movq %r15, %rcx
movl $0x2, %edx
cmovlq %rdx, %rcx
movl $0x102, %edx            # imm = 0x102
cmpq %rdx, %rcx
cmovgeq %rdx, %rcx
movq %rax, %r12
addq $-0x2, %rcx
movq 0x18(%r14), %rdi
movq (%rsp), %rsi
movq %rcx, %rdx
movl $0x10, %r8d
movl $0x3, %r9d
callq 0xefe67
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0xf7557
movq %r14, %rdi
leaq 0x103488(%rip), %rsi    # 0x122573
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %rsi
addq %r15, %rsi
movq %rsi, (%rsp)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
movl (%rax), %r9d
movq %r14, %rdi
movq %r12, %rdx
movl %ebp, %ecx
movq %rbx, %r8
jmp 0x1f245
cmpl $0xd2, %eax
jne 0x1f295
movq %r13, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe958c
xorl %r12d, %r12d
movq %r14, %rdi
leaq 0xf35c0(%rip), %rsi     # 0x112705
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0x0, %ebx
movl $0x0, %r15d
cmpq $0x6, %rbp
jl 0x1f25b
movq 0x18(%r14), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xef1ed
movq %rax, %rbx
cmpq $0x3, %rax
movl $0x2, %ecx
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
movl $0x10, %r8d
movl $0x3, %r9d
callq 0xefe67
movq %rax, %rbp
movq 0x18(%rax), %rdi
callq 0xf7557
movq %r14, %rdi
leaq 0x1033a1(%rip), %rsi    # 0x122573
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq %rbx, (%rsp)
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xef1ed
movq %rax, %rbx
leaq 0x10cc73(%rip), %rcx    # 0x12be69
cmpl $0x6, %ebx
ja 0x1f20b
movl %ebx, %eax
andl $0x7, %eax
leaq 0x15ee39(%rip), %rcx    # 0x17e040
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xf3502(%rip), %rsi     # 0x112717
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xef1ed
movq %rax, %r12
movq (%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
movq %rbp, %rbx
movq %rbp, %r8
movl $0xd2, %r9d
callq 0x1fae2
addq (%rsp), %r12
movq %r12, (%rsp)
subq %r13, %r12
movl $0x1, %r15d
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe9595
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf00aa
testl %r15d, %r15d
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r15
je 0x1f295
cmpq $0x6, %r12
jl 0x1f295
addq %r12, 0x18(%rsp)
decq %r15
jne 0x1ef6b
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq