// File: /workspace/github_c_makefile_star2_O2/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, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %rbx
leaq 0x10(%rsp), %rsi
callq 0xdebae
movl %ebp, 0xc(%rsp)
cmpl $0xf, %ebp
jg 0x1deaf
movq 0x18(%rsp), %r15
addq %r15, 0x20(%rsp)
leaq 0x50(%rsp), %r13
xorl %r12d, %r12d
cmpl $0x0, 0x8(%rsp)
setne %al
movq 0x20(%rsp), %r14
subq %r15, %r14
cmpq 0xc0(%rsp), %r12
setge %cl
testb %cl, %al
jne 0x1de58
cmpq $0x18, %r14
jl 0x1de58
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xdebae
movq %rbx, %rdi
leaq 0xe7a27(%rip), %rsi     # 0x1056f9
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
pushq $0x30
popq %rsi
callq 0xdecaf
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 %r13, %rcx
callq 0x1decd
pushq $0x25
popq %rcx
leaq 0x162bbb(%rip), %rax    # 0x1808d8
movq %r12, 0x38(%rsp)
decq %rcx
je 0x1dd55
movdqu 0x30(%rax), %xmm0
addq $0x28, %rax
pcmpeqb 0x40(%rsp), %xmm0
pmovmskb %xmm0, %edx
cmpl $0xffff, %edx           # imm = 0xFFFF
jne 0x1dd22
leaq 0x28(%rbp), %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x28(%rbp)
movq 0x18(%rax), %rcx
jmp 0x1dd65
leaq 0x28(%rbp), %rax
movq %rax, 0x28(%rsp)
andq $0x0, 0x28(%rbp)
xorl %ecx, %ecx
testq %rcx, %rcx
leaq 0x101172(%rip), %rax    # 0x11eee1
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0xe739f(%rip), %rsi     # 0x10511c
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x10(%r15), %rsi
callq 0xe418b
movq %rbp, %rdi
addq $0x8, %rdi
movq %rax, 0x8(%rbp)
callq 0xe10b1
leaq 0x18(%r15), %rcx
movq %rcx, 0x10(%rbp)
movq 0x8(%rbp), %rdx
leaq -0x18(%rdx), %r8
movq %r8, 0x18(%rbp)
movq %rbx, %rdi
leaq 0xe736a(%rip), %rsi     # 0x10512c
xorl %eax, %eax
callq 0xde896
movq 0x8(%rbp), %r13
movb $0x1, %r12b
cmpq $0x18, %r13
jl 0x1ddf2
cmpq %r14, %r13
jle 0x1ddf7
movq %rbx, %rdi
leaq 0xe7365(%rip), %rsi     # 0x10514a
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xdf05a
xorl %r13d, %r13d
jmp 0x1de21
movq 0x28(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x1de1e
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x1de1e
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
movq %rbp, %rdx
callq *%rax
movq 0x8(%rbp), %r13
xorl %r12d, %r12d
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xded32
testb %r12b, %r12b
movq 0x38(%rsp), %r12
jne 0x1deaf
cmpq $0x18, %r13
jl 0x1deaf
incq %r12
addq %r13, %r15
leaq 0x50(%rsp), %r13
jmp 0x1dc8e
testq %r14, %r14
jle 0x1de74
leaq 0xe7276(%rip), %rsi     # 0x1050da
movq %rbx, %rdi
movl %r14d, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0xde896
cmpl $0x0, 0x8(%rsp)
setne %al
cmpq 0xc0(%rsp), %r12
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1deaf
leaq 0xe725d(%rip), %rsi     # 0x1050f2
movq %rbx, %rdi
movq 0xc0(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xdf05a
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq