// File: /workspace/github_c_makefile_star2_O2/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 $0x148, %rsp            # imm = 0x148
movq %rdx, 0xd0(%rsp)
cmpl $0xf, %r9d
jle 0xfadbb
xorl %eax, %eax
jmp 0xfb582
movq %r8, %rbx
movq %rcx, %r15
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
addq %rcx, %rbx
leaq 0xc8(%rsi), %rbp
movups 0xc8(%rsi), %xmm0
movups 0xd8(%rsi), %xmm1
movups 0xe8(%rsi), %xmm2
movaps %xmm2, 0x130(%rsp)
movaps %xmm1, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
leaq 0xf8(%rsi), %r12
movups 0xf8(%rsi), %xmm0
movups 0x108(%rsi), %xmm1
movups 0x118(%rsi), %xmm2
movaps %xmm0, 0xe0(%rsp)
movaps %xmm1, 0xf0(%rsp)
movaps %xmm2, 0x100(%rsp)
leaq 0x68(%rsi), %rax
movq %rax, 0xb8(%rsp)
leaq 0x98(%rsi), %rax
movq %rax, 0xb0(%rsp)
leaq 0x108(%rsi), %rax
movq %rax, 0xc0(%rsp)
movq %r9, 0x28(%rsp)
leal 0x1(%r9), %eax
movl %eax, 0x38(%rsp)
movq %rbx, %r14
movaps 0x110(%rsp), %xmm0
movaps 0x120(%rsp), %xmm1
movaps 0x130(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
movaps 0xe0(%rsp), %xmm0
movaps 0xf0(%rsp), %xmm1
movaps 0x100(%rsp), %xmm2
movups %xmm2, 0x20(%r12)
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
subq %r15, %r14
jle 0xfb57f
movq 0x40(%r13), %rax
testq %rax, %rax
je 0xfaf08
andq $0x0, 0x40(%rsp)
movq 0x28(%rsp), %rcx
movl %ecx, 0x64(%r13)
movq %r13, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
callq *%rax
testl %eax, %eax
je 0xfaf08
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
jle 0xfaf08
movq 0x48(%r13), %rsi
callq 0xdfbb6
addq %rax, %r15
jmp 0xfae6b
movq 0x8(%r13), %rax
movq %rax, 0x18(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x3c(%rsp), %rsi
callq 0xdebae
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0xa0(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x50(%r13), %rax
addq $0x4, %rax
movq %r14, %rcx
subq %rax, %rcx
jge 0xfaf90
movq 0x10(%rsp), %rdi
leaq 0x43e70(%rip), %rsi     # 0x13edec
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xdf05a
movq 0x10(%rsp), %rdi
jmp 0xfaffa
movq %rcx, 0x30(%rsp)
movq %rax, 0x20(%rsp)
movq 0x18(%r13), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%r13)
setne %r8b
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
pushq $0x4
popq %rcx
callq 0xe657c
movl 0x44(%rsp), %eax
orl 0x28(%rsp), %eax
je 0xfafde
movq 0x18(%r13), %rdi
leaq 0x4(%r15), %rsi
cmpq $0x2, 0x50(%r13)
movl 0x58(%r13), %edx
jne 0xfb002
callq 0xe41b1
jmp 0xfb007
movq 0x10(%rsp), %r14
movq %r14, %rdi
leaq 0x43e32(%rip), %rsi     # 0x13ee1f
movq %r15, %rdx
xorl %eax, %eax
callq 0xdf05a
movq %r14, %rdi
movb $0x1, %r14b
jmp 0xfb4e5
callq 0xe41cb
movq %rax, 0x88(%rsp)
movq 0x20(%rsp), %rax
addq %r15, %rax
movq %rax, 0x80(%rsp)
movq 0x28(%rsp), %rax
movl %eax, 0x64(%r13)
leaq 0x40(%rsp), %rax
movq %rax, 0x128(%r13)
movq 0x28(%r13), %rax
testq %rax, %rax
je 0xfb042
movq %r13, %rdi
callq *%rax
movq 0x98(%rsp), %rcx
testq %rcx, %rcx
je 0xfb06c
movq 0x18(%rsp), %rdi
pushq $0x50
popq %rsi
leaq 0x23b40(%rip), %rdx     # 0x11eb9e
xorl %eax, %eax
callq 0xde40c
movq 0x18(%rsp), %rcx
jmp 0xfb0c5
cmpb $0x0, 0x5d(%r13)
je 0xfb0bd
movq 0x128(%r13), %rax
movl 0x4(%rax), %ecx
leaq 0xa64b(%rip), %rdx      # 0x1056cf
cmpl $0x28632920, %ecx       # imm = 0x28632920
je 0xfb0ac
cmpl $0x41555448, %ecx       # imm = 0x41555448
je 0xfb0a5
cmpl $0x414e4e4f, %ecx       # imm = 0x414E4E4F
jne 0xfb0bd
leaq 0x43e70(%rip), %rdx     # 0x13ef13
jmp 0xfb0ac
leaq 0x1b379(%rip), %rdx     # 0x116425
movq %rdx, 0x58(%rax)
movq 0x98(%rsp), %rcx
testq %rcx, %rcx
jne 0xfb04f
movq 0x18(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x80(%rsp), %r9
movq 0x88(%rsp), %rax
movq %rax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x43d71(%rip), %rsi     # 0x13ee56
leaq 0x50(%rsp), %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0xde896
movq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x88(%rsp), %rcx
movq 0x30(%rsp), %rdx
cmpq %rdx, %rcx
jle 0xfb175
testq %r15, %r15
jne 0xfb12c
cmpl $0x52494646, 0x44(%rsp) # imm = 0x52494646
jne 0xfb12c
movq 0x18(%r13), %rax
cmpq %r14, 0x18(%rax)
je 0xfb152
addq 0x80(%rsp), %rcx
movq 0x10(%rsp), %rdi
leaq 0x43d3e(%rip), %rsi     # 0x13ee7e
movl %r15d, %edx
movq %rbx, %r8
xorl %eax, %eax
callq 0xdf05a
movq 0x30(%rsp), %rdx
movq %rdx, 0x88(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x43d79(%rip), %rsi     # 0x13eedf
xorl %eax, %eax
callq 0xde896
movq 0x88(%rsp), %rcx
movq 0x48(%r13), %rsi
movq %rcx, %rdi
callq 0xdfbb6
movq %r15, 0x70(%rsp)
movq %r14, 0x78(%rsp)
andq $0x0, 0x130(%r13)
addq 0x20(%rsp), %rax
movq %rax, 0xc8(%rsp)
andl $0x0, 0x138(%r13)
movq %r13, %rdi
callq *0x20(%r13)
movb $0x1, %r14b
testl %eax, %eax
je 0xfb4e0
cmpl $0x0, 0x134(%r13)
je 0xfb2db
andq $0x0, 0x128(%r13)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movaps 0x60(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movq 0x80(%rsp), %r14
movq 0x88(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%r13), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%r13)
setne %r8b
movq %r14, %rsi
movq %r12, %rdx
pushq $0x4
popq %rcx
callq 0xe657c
cmpl $0x0, 0x28(%rsp)
jne 0xfb27c
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups 0x20(%rbp), %xmm2
movq 0xb8(%rsp), %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
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)
addq $0x4, %r14
addq $-0x4, 0x18(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x43c6d(%rip), %rsi     # 0x13eeff
movq 0xc0(%rsp), %rdx
xorl %eax, %eax
callq 0xde896
movq 0x30(%r13), %rax
testq %rax, %rax
je 0xfb332
leaq 0x40(%rsp), %rcx
movq %rcx, 0x128(%r13)
movq %r13, %rdi
callq *%rax
andq $0x0, 0x128(%r13)
testl %eax, %eax
movq %r14, %rcx
movb $0x1, %r14b
movq 0x18(%rsp), %r8
jne 0xfb33d
jmp 0xfb4dd
cmpl $0x0, 0x138(%r13)
je 0xfb398
andq $0x0, 0x128(%r13)
movaps 0x40(%rsp), %xmm0
movaps 0x50(%rsp), %xmm1
movaps 0x60(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movq 0x80(%rsp), %rcx
movq 0x88(%rsp), %r8
jmp 0xfb33d
movq %r14, %rcx
movb $0x1, %r14b
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0x40(%rsp), %rdx
movl 0x38(%rsp), %r9d
callq 0xfad95
testl %eax, %eax
je 0xfb4e0
movq 0x38(%r13), %rax
testq %rax, %rax
je 0xfb4dd
movq 0x28(%rsp), %rcx
movl %ecx, 0x64(%r13)
leaq 0x40(%rsp), %rcx
movq %rcx, 0x128(%r13)
movq %r13, %rdi
callq *%rax
andq $0x0, 0x128(%r13)
testl %eax, %eax
jne 0xfb4dd
jmp 0xfb4e0
cmpl $0x0, 0x130(%r13)
jne 0xfb4dd
movq (%r13), %rdi
movq 0x128(%r13), %rax
movq 0x40(%rax), %rdx
movq 0x48(%rax), %r14
cmpb $0x0, 0x5d(%r13)
je 0xfb404
movl 0x4(%rax), %eax
cmpl $0x54455854, %eax       # imm = 0x54455854
je 0xfb4c0
cmpl $0x414e4e4f, %eax       # imm = 0x414E4E4F
je 0xfb42e
cmpl $0x41555448, %eax       # imm = 0x41555448
je 0xfb4b1
cmpl $0x4e414d45, %eax       # imm = 0x4E414D45
je 0xfb4a2
cmpl $0x28632920, %eax       # imm = 0x28632920
jne 0xfb404
movq %r13, %rsi
movq %r14, %rcx
leaq 0xa2d0(%rip), %r8       # 0x1056cf
jmp 0xfb4cd
cmpl $0x3, (%rdi)
jl 0xfb4d2
movq 0x18(%r13), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %r14, %rcx
xorl %r9d, %r9d
callq 0xded3a
jmp 0xfb4d2
testq %r14, %r14
jle 0xfb4d2
movq %rdi, 0x20(%rsp)
movq 0x18(%r13), %rdi
xorl %esi, %esi
movq %rdx, 0x18(%rsp)
movq 0x18(%rsp), %rdx
movq %r14, %rcx
leaq 0xd8(%rsp), %r8
callq 0xe4b21
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq 0xd8(%rsp), %rdx
subq %rsi, %rdx
testl %eax, %eax
cmoveq %r14, %rdx
testq %rdx, %rdx
jle 0xfb4d2
cmpl $0x2, 0x90(%rcx)
jl 0xfb51f
movq 0x18(%r13), %rdi
leaq 0x43a8a(%rip), %rcx     # 0x13ef1e
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0xe4e0b
jmp 0xfb4d2
movq %r13, %rsi
movq %r14, %rcx
leaq 0x20163(%rip), %r8      # 0x11b612
jmp 0xfb4cd
movq %r13, %rsi
movq %r14, %rcx
leaq 0x1af67(%rip), %r8      # 0x116425
jmp 0xfb4cd
movq %r13, %rsi
movq %r14, %rcx
leaq 0x245be(%rip), %r8      # 0x11fa8b
callq 0xfb594
movl $0x1, 0x130(%r13)
xorl %r14d, %r14d
movq 0x10(%rsp), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rbp)
movups %xmm0, 0x40(%rbp)
movups %xmm0, 0x30(%rbp)
movups %xmm0, 0x20(%rbp)
movups %xmm0, 0x10(%rbp)
movups %xmm0, (%rbp)
movl 0x3c(%rsp), %esi
callq 0xdebb7
addq 0xc8(%rsp), %r15
testb %r14b, %r14b
je 0xfae6b
jmp 0xfadb4
movq %rcx, %rdi
movq %rdx, 0x30(%rsp)
callq 0xeac74
movq %rax, %r14
movq 0x18(%r13), %rdi
movl 0x60(%r13), %eax
movl %eax, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r14, %r8
xorl %r9d, %r9d
callq 0xe4ced
movq %r14, %rdi
callq 0xeb7e4
movq 0x20(%rsp), %rdi
leaq 0x200f4(%rip), %rsi     # 0x11b65c
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
callq 0xeaf3c
jmp 0xfb4d2
pushq $0x1
popq %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq