// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/asf.c
// Function: do_object_sequence
static int do_object_sequence(deark *c, lctx *d, i64 pos1, i64 len, int level,
	int known_object_count, i64 num_objects_expected)
{
	int retval = 0;
	i64 pos = pos1;
	int saved_indent_level;
	i64 bytes_remaining;
	i64 objects_found = 0;

	de_dbg_indent_save(c, &saved_indent_level);

	if(level >= 16) { // An arbitrary recursion limit
		goto done;
	}

	while(1) {
		int ret;
		i64 bytes_consumed = 0;

		bytes_remaining = pos1+len-pos;
		if(known_object_count && objects_found>=num_objects_expected) {
			break;
		}

		if(bytes_remaining<24) {
			break;
		}

		ret = do_object(c, d, pos, bytes_remaining, level, &bytes_consumed);
		if(!ret) goto done;
		if(bytes_consumed<24) goto done;

		objects_found++;
		pos += bytes_consumed;
	}

	bytes_remaining = pos1+len-pos;
	if(bytes_remaining>0) {
		de_dbg(c, "[%d extra bytes at %"I64_FMT"]", (int)bytes_remaining, pos);
	}

	if(known_object_count && objects_found<num_objects_expected) {
		de_warn(c, "Expected %d objects at %"I64_FMT", only found %d", (int)num_objects_expected,
			pos1, (int)objects_found);
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, %r12d
movl %r8d, %ebp
movq %rcx, %r13
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
callq 0xe958c
movl %ebp, 0x4(%rsp)
cmpl $0xf, %ebp
jg 0x1e282
movq %r14, 0x28(%rsp)
movq 0xb0(%rsp), %r14
movq 0x10(%rsp), %r15
addq %r15, %r13
xorl %r8d, %r8d
movq %r13, 0x18(%rsp)
movl %r12d, (%rsp)
testl %r12d, %r12d
setne %cl
cmpq %r14, %r8
setge %dl
movl $0x4, %eax
testb %dl, %cl
jne 0x1e227
movq %r13, %rbp
subq %r15, %rbp
cmpq $0x18, %rbp
jl 0x1e227
movq %r8, 0x20(%rsp)
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe958c
movq %rbx, %rdi
leaq 0xf4687(%rip), %rsi     # 0x112709
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0x30, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r14
movq %rax, %r12
movq %r15, (%rax)
movl 0x4(%rsp), %eax
movl %eax, 0x20(%r14)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %rsi
movq %r15, %rdx
leaq 0x40(%rsp), %rcx
callq 0x1e29d
movl $0x24, %ecx
leaq 0x15f747(%rip), %rax    # 0x17d820
movdqu 0x8(%rax), %xmm0
pcmpeqb 0x30(%rsp), %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0x1e0fb
addq $0x28, %rax
decq %rcx
jne 0x1e0d9
xorl %eax, %eax
movq %rax, 0x28(%r12)
testq %rax, %rax
je 0x1e10b
movq 0x18(%rax), %rcx
jmp 0x1e10d
xorl %ecx, %ecx
testq %rcx, %rcx
leaq 0x10dd52(%rip), %rax    # 0x12be69
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0xf4007(%rip), %rsi     # 0x11212c
leaq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x10(%r15), %rsi
callq 0xef536
addq $0x8, %r14
movq %rax, 0x8(%r12)
movq %r14, %rdi
callq 0xec0d1
leaq 0x18(%r15), %rcx
movq %rcx, 0x10(%r12)
movq 0x8(%r12), %rdx
leaq -0x18(%rdx), %r8
movq %r8, 0x18(%r12)
movq %rbx, %rdi
leaq 0xf3fcc(%rip), %rsi     # 0x11213c
xorl %eax, %eax
callq 0xe9226
movq 0x8(%r12), %rcx
movb $0x1, %r13b
cmpq $0x18, %rcx
jl 0x1e19e
cmpq %rbp, %rcx
jle 0x1e1a3
movq %rbx, %rdi
leaq 0xf3fc6(%rip), %rsi     # 0x11215a
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9b27
xorl %r14d, %r14d
jmp 0x1e1c9
movq 0x28(%r12), %rax
testq %rax, %rax
je 0x1e1c3
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x1e1c3
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
movq %r12, %rdx
callq *%rax
movq (%r14), %r14
xorl %r13d, %r13d
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
cmpq $0x18, %r14
setl %al
orb %r13b, %al
movl $0x2, %eax
je 0x1e209
movq 0xb0(%rsp), %r14
movl (%rsp), %r12d
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %r8
jmp 0x1e227
movq 0x20(%rsp), %r8
incq %r8
addq %r14, %r15
xorl %eax, %eax
movq 0xb0(%rsp), %r14
movl (%rsp), %r12d
movq 0x18(%rsp), %r13
testl %eax, %eax
je 0x1e03d
cmpl $0x2, %eax
je 0x1e282
subq %r15, %r13
jle 0x1e256
leaq 0xf3eaa(%rip), %rsi     # 0x1120ea
movq %rbx, %rdi
movl %r13d, %edx
movq %r15, %rcx
xorl %eax, %eax
movq %r8, %r15
callq 0xe9226
movq %r15, %r8
testl %r12d, %r12d
setne %al
cmpq %r14, %r8
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1e282
leaq 0xf3e92(%rip), %rsi     # 0x112102
movq %rbx, %rdi
movl %r14d, %edx
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0xe9b27
movl 0x8(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq