// File: /workspace/github_c_makefile_star2_O3/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 $0x88, %rsp
movl %r9d, 0x8(%rsp)
movl %r8d, %ebp
movq %rcx, %r12
movq %rdx, 0x18(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %rbx
leaq 0x10(%rsp), %rsi
callq 0xe8a1c
movl %ebp, 0xc(%rsp)
cmpl $0xf, %ebp
jg 0x1e1c0
movq 0x18(%rsp), %r15
leaq (%r12,%r15), %rdx
cmpl $0x0, 0x8(%rsp)
setne %al
cmpq $0x0, 0xc0(%rsp)
setle %cl
andb %al, %cl
cmpq $0x18, %r12
setl %al
orb %cl, %al
je 0x1e1de
xorl %r13d, %r13d
subq %r15, %rdx
jle 0x1e185
leaq 0xf3f82(%rip), %rsi     # 0x1120fa
movq %rbx, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0xe8617
cmpl $0x0, 0x8(%rsp)
setne %al
cmpq 0xc0(%rsp), %r13
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1e1c0
leaq 0xf3f6c(%rip), %rsi     # 0x112112
movq %rbx, %rdi
movq 0xc0(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0xe8faa
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %r14
xorl %r13d, %r13d
movq %rdx, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe8a1c
movq %rbx, %rdi
leaq 0xf4517(%rip), %rsi     # 0x112719
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x30, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %rbp
movq %r15, (%rax)
movl 0xc(%rsp), %eax
movl %eax, 0x20(%rbp)
movq 0x18(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1e3cf
movl $0x24, %ecx
leaq 0x15f66d(%rip), %rax    # 0x17d8c0
movq %r13, 0x38(%rsp)
movdqu 0x8(%rax), %xmm0
pcmpeqb 0x40(%rsp), %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
je 0x1e28d
addq $0x28, %rax
decq %rcx
jne 0x1e258
leaq 0x28(%rbp), %rax
movq %rax, 0x28(%rsp)
movq $0x0, 0x28(%rbp)
xorl %ecx, %ecx
jmp 0x1e29e
leaq 0x28(%rbp), %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x28(%rbp)
movq 0x18(%rax), %rcx
testq %rcx, %rcx
leaq 0x10dea9(%rip), %rax    # 0x12c151
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0xf3e86(%rip), %rsi     # 0x11213c
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
leaq 0x10(%r15), %rsi
callq 0xeef09
movq %rbp, %rdi
addq $0x8, %rdi
movq %rax, 0x8(%rbp)
callq 0xebad2
leaq 0x18(%r15), %rcx
movq %rcx, 0x10(%rbp)
movq 0x8(%rbp), %rdx
leaq -0x18(%rdx), %r8
movq %r8, 0x18(%rbp)
movq %rbx, %rdi
leaq 0xf3e51(%rip), %rsi     # 0x11214c
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rbp), %r14
movb $0x1, %r13b
cmpq $0x18, %r14
jl 0x1e32b
cmpq %r12, %r14
jle 0x1e330
movq %rbx, %rdi
leaq 0xf3e4c(%rip), %rsi     # 0x11216a
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xe8faa
xorl %r14d, %r14d
jmp 0x1e35a
movq 0x28(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x1e357
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x1e357
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movq %rbp, %rdx
callq *%rax
movq 0x8(%rbp), %r14
xorl %r13d, %r13d
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe8be2
testb %r13b, %r13b
movq 0x38(%rsp), %r13
jne 0x1e1c0
cmpq $0x18, %r14
jl 0x1e1c0
cmpl $0x0, 0x8(%rsp)
setne %al
incq %r13
addq %r14, %r15
cmpq 0xc0(%rsp), %r13
setge %cl
testb %cl, %al
jne 0x1e3c5
movq 0x20(%rsp), %rdx
movq %rdx, %r12
subq %r15, %r12
cmpq $0x17, %r12
leaq 0x50(%rsp), %r14
jg 0x1e1eb
jmp 0x1e16c
movq 0x20(%rsp), %rdx
jmp 0x1e16c