// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/fmtutil-iff.c
// Function: do_iff_chunk_sequence
static int do_iff_chunk_sequence(deark *c, struct de_iffctx *ictx,
	struct de_iffchunkctx *parent, i64 pos1, i64 len, int level)
{
	i64 pos;
	i64 endpos;
	i64 chunk_len;
	struct de_fourcc saved_container_fmt4cc;
	struct de_fourcc saved_container_contentstype4cc;
	int ret;

	if(level >= 16) { // An arbitrary recursion limit.
		return 0;
	}

	endpos = pos1+len;
	saved_container_fmt4cc = ictx->curr_container_fmt4cc;
	saved_container_contentstype4cc = ictx->curr_container_contentstype4cc;

	pos = pos1;
	while(pos < endpos) {
		ictx->curr_container_fmt4cc = saved_container_fmt4cc;
		ictx->curr_container_contentstype4cc = saved_container_contentstype4cc;

		if(ictx->handle_nonchunk_data_fn) {
			i64 skip_len = 0;

			ictx->level = level;
			// TODO: Currently, this is called unconditionally. Maybe we should
			// only call it when it looks like there is non-chunk data.
			ret = ictx->handle_nonchunk_data_fn(ictx, pos, &skip_len);
			if(ret && skip_len>0) {
				pos += de_pad_to_n(skip_len, ictx->alignment);
				continue;
			}
		}

		ret = do_iff_chunk(c, ictx, parent, pos, endpos-pos, level, &chunk_len);
		if(!ret) return 0;
		pos += chunk_len;
	}

	ictx->curr_container_fmt4cc = saved_container_fmt4cc;
	ictx->curr_container_contentstype4cc = saved_container_contentstype4cc;

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, 0xc8(%rsp)
cmpl $0xf, %r9d
jle 0x1076c0
xorl %eax, %eax
jmp 0x107e49
movq %r8, %r14
movq %rsi, %rbp
movq %rdi, 0x10(%rsp)
leaq 0xc8(%rsi), %r12
movups 0xc8(%rsi), %xmm0
movups 0xd8(%rsi), %xmm1
movups 0xe8(%rsi), %xmm2
movaps %xmm2, 0x120(%rsp)
movaps %xmm1, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
leaq 0xf8(%rsi), %r13
movups 0xf8(%rsi), %xmm0
movups 0x108(%rsi), %xmm1
movups 0x118(%rsi), %xmm2
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0xe0(%rsp)
movaps %xmm2, 0xf0(%rsp)
testq %r8, %r8
jle 0x107df4
movl %r9d, %ebx
movq %rcx, %r15
addq %rcx, %r14
leaq 0x68(%rbp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x98(%rbp), %rax
movq %rax, 0xa8(%rsp)
leaq 0x108(%rbp), %rax
movq %rax, 0xb8(%rsp)
leal 0x1(%rbx), %eax
movl %eax, 0x28(%rsp)
movq %rbx, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movaps 0x120(%rsp), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movaps 0xf0(%rsp), %xmm2
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
movq 0x40(%rbp), %rax
testq %rax, %rax
je 0x10781a
movq $0x0, 0x30(%rsp)
movl %ebx, 0x64(%rbp)
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x30(%rsp), %rdx
callq *%rax
testl %eax, %eax
je 0x10781a
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
jle 0x10781a
movq 0x48(%rbp), %rsi
callq 0xe9cb4
addq %rax, %r15
cmpq %r14, %r15
jl 0x107780
jmp 0x107df4
subq %r15, %r14
movq 0x8(%rbp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x2c(%rsp), %rsi
callq 0xe8a1c
movq %r14, %rdx
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x90(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x50(%rbp), %r14
addq $0x4, %r14
movq %rdx, %rax
subq %r14, %rax
jge 0x1078a1
movq %rbx, %rdi
leaq 0x44a57(%rip), %rsi     # 0x14c2ec
movq %r15, %rcx
xorl %eax, %eax
callq 0xe8faa
jmp 0x107911
movq %rax, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq 0x18(%rbp), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%rbp)
setne %r8b
movq %r15, %rsi
leaq 0x30(%rsp), %rdx
movl $0x4, %ecx
callq 0xf1762
movl 0x34(%rsp), %eax
movq 0x18(%rsp), %rbx
orl %ebx, %eax
je 0x1078f8
movq 0x18(%rbp), %rdi
leaq 0x4(%r15), %rsi
cmpq $0x2, 0x50(%rbp)
movl 0x58(%rbp), %edx
jne 0x107921
callq 0xeef43
jmp 0x107926
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x44a18(%rip), %rsi     # 0x14c31f
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8faa
movb $0x1, %al
movl %eax, 0x8(%rsp)
movq 0x20(%rsp), %r14
jmp 0x107da1
callq 0xeeff3
movq %rax, 0x78(%rsp)
leaq (%r14,%r15), %rax
movq %rax, 0x70(%rsp)
movl %ebx, 0x64(%rbp)
leaq 0x30(%rsp), %rax
movq %rax, 0x128(%rbp)
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x107951
movq %rbp, %rdi
callq *%rax
movq 0x88(%rsp), %rcx
testq %rcx, %rcx
je 0x10797e
movl $0x50, %esi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x2449c(%rip), %rdx     # 0x12be0e
xorl %eax, %eax
callq 0xe8193
movq %rbx, %rcx
jmp 0x1079d6
cmpb $0x0, 0x5d(%rbp)
je 0x1079ce
movq 0x128(%rbp), %rax
movl 0x4(%rax), %ecx
leaq 0xad5a(%rip), %rdx      # 0x1126ef
cmpl $0x28632920, %ecx       # imm = 0x28632920
je 0x1079bd
cmpl $0x41555448, %ecx       # imm = 0x41555448
je 0x1079b6
cmpl $0x414e4e4f, %ecx       # imm = 0x414E4E4F
jne 0x1079ce
leaq 0x44a5f(%rip), %rdx     # 0x14c413
jmp 0x1079bd
leaq 0x1bc28(%rip), %rdx     # 0x1235e5
movq %rdx, 0x58(%rax)
movq 0x88(%rsp), %rcx
testq %rcx, %rcx
jne 0x10795e
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x70(%rsp), %r9
movq 0x78(%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
leaq 0x44963(%rip), %rsi     # 0x14c356
leaq 0x40(%rsp), %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x78(%rsp), %rcx
movq 0xa0(%rsp), %r8
cmpq %r8, %rcx
jle 0x107a8a
testq %r15, %r15
jne 0x107a42
cmpl $0x52494646, 0x34(%rsp) # imm = 0x52494646
jne 0x107a42
movq 0x18(%rbp), %rax
movq 0x98(%rsp), %rdx
cmpq %rdx, 0x18(%rax)
je 0x107a6a
addq 0x70(%rsp), %rcx
movq 0x10(%rsp), %rdi
leaq 0x4492b(%rip), %rsi     # 0x14c37e
movl %r15d, %edx
movq 0x20(%rsp), %r8
xorl %eax, %eax
callq 0xe8faa
movq 0xa0(%rsp), %r8
movq %r8, 0x78(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x44964(%rip), %rsi     # 0x14c3df
movq %r8, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x78(%rsp), %rcx
movq 0x18(%rsp), %rbx
movq 0x48(%rbp), %rsi
movq %rcx, %rdi
callq 0xe9cb4
addq %r14, %rax
movq %rax, 0xc0(%rsp)
movq %r15, 0x60(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x68(%rsp)
movq $0x0, 0x130(%rbp)
movl $0x0, 0x138(%rbp)
movq %rbp, %rdi
callq *0x20(%rbp)
testl %eax, %eax
je 0x107c09
cmpl $0x0, 0x134(%rbp)
movq 0x20(%rsp), %r14
je 0x107c18
movq $0x0, 0x128(%rbp)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movups %xmm0, (%r13)
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rbp), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%rbp)
setne %r8b
movq %rbx, %rsi
movq %r13, %rdx
movl $0x4, %ecx
callq 0xf1762
cmpl $0x0, 0x18(%rsp)
jne 0x107ba5
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movq 0xb0(%rsp), %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movq 0xa8(%rsp), %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
addq $0x4, %rbx
addq $-0x4, 0x8(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x44844(%rip), %rsi     # 0x14c3ff
movq 0xb8(%rsp), %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x30(%rbp), %rax
testq %rax, %rax
je 0x107c6e
leaq 0x30(%rsp), %rcx
movq %rcx, 0x128(%rbp)
movq %rbp, %rdi
callq *%rax
movq $0x0, 0x128(%rbp)
testl %eax, %eax
movq %rbx, %rcx
movq 0x18(%rsp), %rbx
movq 0x8(%rsp), %r8
jne 0x107c7b
jmp 0x107d94
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r14
jmp 0x107ccf
cmpl $0x0, 0x138(%rbp)
je 0x107cda
movq $0x0, 0x128(%rbp)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movups %xmm0, (%r13)
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %r8
jmp 0x107c7b
movq %rbx, %rcx
movq 0x18(%rsp), %rbx
movq 0x8(%rsp), %r8
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
leaq 0x30(%rsp), %rdx
movl 0x28(%rsp), %r9d
callq 0x10769a
testl %eax, %eax
je 0x107cca
movq 0x38(%rbp), %rax
testq %rax, %rax
je 0x107d94
movl %ebx, 0x64(%rbp)
leaq 0x30(%rsp), %rcx
movq %rcx, 0x128(%rbp)
movq %rbp, %rdi
callq *%rax
movq $0x0, 0x128(%rbp)
testl %eax, %eax
jne 0x107d94
movq 0x10(%rsp), %rbx
movb $0x1, %al
movl %eax, 0x8(%rsp)
jmp 0x107da1
cmpl $0x0, 0x130(%rbp)
jne 0x107d94
movq (%rbp), %rdi
movq 0x128(%rbp), %rax
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
cmpb $0x0, 0x5d(%rbp)
je 0x107d43
movl 0x4(%rax), %eax
cmpl $0x41555447, %eax       # imm = 0x41555447
jle 0x107d2b
cmpl $0x41555448, %eax       # imm = 0x41555448
je 0x107d63
cmpl $0x4e414d45, %eax       # imm = 0x4E414D45
je 0x107d6f
cmpl $0x54455854, %eax       # imm = 0x54455854
jne 0x107d43
movq %rbp, %rsi
leaq 0x24fd2(%rip), %r8      # 0x12ccfb
jmp 0x107d85
cmpl $0x28632920, %eax       # imm = 0x28632920
je 0x107d7b
cmpl $0x414e4e4f, %eax       # imm = 0x414E4E4F
jne 0x107d43
movq %rbp, %rsi
callq 0x107edb
jmp 0x107d8a
cmpl $0x3, (%rdi)
jl 0x107d8a
movq 0x18(%rbp), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
xorl %r9d, %r9d
callq 0xe8bea
jmp 0x107d8a
movq %rbp, %rsi
leaq 0x1b878(%rip), %r8      # 0x1235e5
jmp 0x107d85
movq %rbp, %rsi
leaq 0x20ad9(%rip), %r8      # 0x128852
jmp 0x107d85
movq %rbp, %rsi
leaq 0xa96a(%rip), %r8       # 0x1126ef
callq 0x107e5b
movl $0x1, 0x130(%rbp)
movl $0x0, 0x8(%rsp)
movq 0x10(%rsp), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%r12)
movups %xmm0, 0x40(%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
cmpb $0x0, 0x8(%rsp)
jne 0x1076b9
addq 0xc0(%rsp), %r15
cmpq %r14, %r15
movq 0x18(%rsp), %rbx
jl 0x107780
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movaps 0x120(%rsp), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movaps 0xf0(%rsp), %xmm2
movups %xmm2, 0x20(%r13)
movups %xmm1, 0x10(%r13)
movups %xmm0, (%r13)
movl $0x1, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq