// File: /workspace/github_c_makefile_star2_O3/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 0xeebeb
movq %rax, %r15
leaq 0xf36ca(%rip), %rsi     # 0x112700
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
testq %r15, %r15
jle 0x1f386
movq 0x18(%rsp), %r12
movq %rbx, 0x10(%rsp)
movq 0x18(%rbx), %rbp
addq 0x10(%rbx), %rbp
subq %r12, %rbp
jle 0x1f386
movq 0x28(%rbx), %rax
movl (%rax), %eax
leal -0x133(%rax), %ecx
cmpl $0x2, %ecx
movq %r15, 0x20(%rsp)
jae 0x1f205
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
xorl %r13d, %r13d
movq %r14, %rdi
leaq 0xf375b(%rip), %rsi     # 0x1127fa
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x0, %r15d
movl $0x0, %ebx
cmpq $0xe, %rbp
jl 0x1f344
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
cmpl $0x134, (%rax)          # imm = 0x134
jne 0x1f0fb
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xeebc8
movq %r14, %rdi
leaq 0xf371f(%rip), %rsi     # 0x112811
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
leaq 0x2(%r12), %rax
movq %rax, (%rsp)
movq 0x18(%r14), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0xeebeb
movq %r14, %rdi
leaq 0xf370c(%rip), %rsi     # 0x112829
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xeebeb
movq %rax, %r15
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0xeebeb
movq %rax, %rbp
leaq 0x10d006(%rip), %rcx    # 0x12c151
cmpl $0x6, %ebp
ja 0x1f160
movl %ebp, %eax
andl $0x7, %eax
leaq 0x15ef84(%rip), %rcx    # 0x17e0e0
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xf35bd(%rip), %rsi     # 0x112727
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xeed83
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, %r13
addq $-0x2, %rcx
movq 0x18(%r14), %rdi
movq (%rsp), %rsi
movq %rcx, %rdx
movl $0x10, %r8d
movl $0x3, %r9d
callq 0xef87c
movq %rax, %rbx
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %r14, %rdi
leaq 0x1035a7(%rip), %rsi    # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq (%rsp), %rsi
addq %r15, %rsi
movq %rsi, (%rsp)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rax
movl (%rax), %r9d
movq %r14, %rdi
movq %r13, %rdx
movl %ebp, %ecx
movq %rbx, %r8
jmp 0x1f32e
cmpl $0xd2, %eax
jne 0x1f386
movq %r12, (%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
xorl %r13d, %r13d
movq %r14, %rdi
leaq 0xf34e7(%rip), %rsi     # 0x112715
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x0, %ebx
movl $0x0, %r15d
cmpq $0x6, %rbp
jl 0x1f344
movq 0x18(%r14), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xeebeb
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 0xef87c
movq %rax, %rbp
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %r14, %rdi
leaq 0x1034c0(%rip), %rsi    # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq %rbx, (%rsp)
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xeebeb
movq %rax, %rbx
leaq 0x10ce72(%rip), %rcx    # 0x12c151
cmpl $0x6, %ebx
ja 0x1f2f4
movl %ebx, %eax
andl $0x7, %eax
leaq 0x15edf0(%rip), %rcx    # 0x17e0e0
movq (%rcx,%rax,8), %rcx
movq %r14, %rdi
leaq 0xf3429(%rip), %rsi     # 0x112727
movl %ebx, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %rsp, %rsi
callq 0xeebeb
movq %rax, %r13
movq (%rsp), %rsi
movq %r14, %rdi
movq %rax, %rdx
movl %ebx, %ecx
movq %rbp, %rbx
movq %rbp, %r8
movl $0xd2, %r9d
callq 0x1fbe1
addq (%rsp), %r13
movq %r13, (%rsp)
subq %r12, %r13
movl $0x1, %r15d
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq %r14, %rdi
movq %rbx, %rsi
callq 0xefaca
testl %r15d, %r15d
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r15
je 0x1f386
cmpq $0x6, %r13
jl 0x1f386
addq 0x18(%rsp), %r13
movq %r13, 0x18(%rsp)
movq %r13, %r12
decq %r15
jne 0x1f056
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq