// File: /workspace/github_c_makefile_star2_O1/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 0x107c04
xorl %eax, %eax
jmp 0x10837e
movl %r9d, %ebx
movq %r8, %r14
movq %rcx, %r15
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
addq %rcx, %r14
leaq 0xc8(%rsi), %rbp
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), %rax
movups 0xf8(%rsi), %xmm0
movups 0x108(%rsi), %xmm1
movups 0x118(%rsi), %xmm2
movaps %xmm0, 0xd0(%rsp)
movaps %xmm1, 0xe0(%rsp)
movaps %xmm2, 0xf0(%rsp)
leaq 0x68(%rsi), %rcx
movq %rcx, 0xa8(%rsp)
leaq 0x98(%rsi), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0x108(%rsi), %rcx
movq %rcx, 0xb0(%rsp)
leal 0x1(%rbx), %ecx
movl %ecx, 0x28(%rsp)
leaq 0x30(%rsp), %rdx
movq %rax, 0x18(%rsp)
movaps 0x100(%rsp), %xmm0
movaps 0x110(%rsp), %xmm1
movaps 0x120(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
movaps 0xd0(%rsp), %xmm0
movaps 0xe0(%rsp), %xmm1
movaps 0xf0(%rsp), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
cmpq %r14, %r15
jge 0x108379
movq 0x40(%r13), %rax
testq %rax, %rax
je 0x107d67
movq %r14, %r12
movq $0x0, 0x30(%rsp)
movq %rbx, %r14
movl %ebx, 0x64(%r13)
movq %r13, %rdi
movq %r15, %rsi
callq *%rax
testl %eax, %eax
sete %al
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
setle %bl
orb %al, %bl
jne 0x107d4f
movq 0x48(%r13), %rsi
callq 0xea80b
addq %rax, %r15
movq 0x18(%rsp), %rax
testb %bl, %bl
movq %r14, %rbx
movq %r12, %r14
leaq 0x30(%rsp), %rdx
je 0x107cbb
movq %r14, %r12
subq %r15, %r12
movq 0x8(%r13), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
callq 0xe958c
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(%r13), %rax
addq $0x4, %rax
movq %r12, %rcx
subq %rax, %rcx
jge 0x107df5
movq 0x8(%rsp), %rdi
leaq 0x43eeb(%rip), %rsi     # 0x14bccc
movq %r12, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe9b27
movq 0x8(%rsp), %rdi
jmp 0x107e6a
movq %rcx, 0x98(%rsp)
movq %rax, 0x20(%rsp)
movq %r12, 0xb8(%rsp)
movq 0x18(%r13), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%r13)
setne %r8b
movq %r15, %rsi
leaq 0x30(%rsp), %rdx
movl $0x4, %ecx
callq 0xf1d74
movl 0x34(%rsp), %eax
orl %ebx, %eax
je 0x107e4e
movq 0x18(%r13), %rdi
leaq 0x4(%r15), %rsi
cmpq $0x2, 0x50(%r13)
jne 0x107e72
movl 0x58(%r13), %edx
callq 0xef570
jmp 0x107e7b
movq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x43ea2(%rip), %rsi     # 0x14bcff
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9b27
movq %r12, %rdi
movb $0x1, %r12b
jmp 0x108335
movl 0x58(%r13), %edx
callq 0xef614
movq %rax, 0x78(%rsp)
movq 0x20(%rsp), %rax
addq %r15, %rax
movq %rax, 0x70(%rsp)
movl %ebx, 0x64(%r13)
leaq 0x30(%rsp), %rax
movq %rax, 0x128(%r13)
movq 0x28(%r13), %rax
testq %rax, %rax
je 0x107eab
movq %r13, %rdi
callq *%rax
cmpq $0x0, 0x88(%rsp)
je 0x107ee3
movq 0x88(%rsp), %rcx
testq %rcx, %rcx
je 0x107f26
movl $0x50, %esi
movq 0x10(%rsp), %r12
movq %r12, %rdi
leaq 0x23c4f(%rip), %rdx     # 0x12bb26
xorl %eax, %eax
callq 0xe8d67
movq %r12, %rcx
jmp 0x107f2e
cmpb $0x0, 0x5d(%r13)
je 0x107eb6
movq 0x128(%r13), %rax
movl 0x4(%rax), %ecx
cmpl $0x41555448, %ecx       # imm = 0x41555448
je 0x108270
cmpl $0x414e4e4f, %ecx       # imm = 0x414E4E4F
je 0x108265
cmpl $0x28632920, %ecx       # imm = 0x28632920
jne 0x10827b
xorl %ecx, %ecx
leaq 0xa7be(%rip), %rdx      # 0x1126df
jmp 0x10827f
movq 0x10(%rsp), %rcx
movb $0x0, (%rcx)
movq 0x70(%rsp), %r9
movq 0x78(%rsp), %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x43deb(%rip), %rsi     # 0x14bd36
leaq 0x40(%rsp), %rdx
movq %r15, %r8
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x78(%rsp), %rcx
movq 0x98(%rsp), %rdx
cmpq %rdx, %rcx
movq 0xb8(%rsp), %r12
jle 0x107fd8
testq %r15, %r15
jne 0x107f9a
cmpl $0x52494646, 0x34(%rsp) # imm = 0x52494646
jne 0x107f9a
movq 0x18(%r13), %rax
cmpq %r12, 0x18(%rax)
je 0x107fc0
addq 0x70(%rsp), %rcx
movq 0x8(%rsp), %rdi
leaq 0x43db3(%rip), %rsi     # 0x14bd5e
movl %r15d, %edx
movq %r14, %r8
xorl %eax, %eax
callq 0xe9b27
movq 0x98(%rsp), %rdx
movq %rdx, 0x78(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x43dee(%rip), %rsi     # 0x14bdbf
xorl %eax, %eax
callq 0xe9226
movq 0x78(%rsp), %rdi
movq 0x48(%r13), %rsi
callq 0xea80b
addq 0x20(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %r15, 0x60(%rsp)
movq %r12, 0x68(%rsp)
movq $0x0, 0x130(%r13)
movl $0x0, 0x138(%r13)
movq %r13, %rdi
callq *0x20(%r13)
movb $0x1, %r12b
testl %eax, %eax
je 0x108330
movl 0x134(%r13), %eax
testl %eax, %eax
je 0x10813b
movq $0x0, 0x128(%r13)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
movq 0x18(%rsp), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
movq 0x70(%rsp), %r12
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%r13), %rdi
xorl %r8d, %r8d
cmpb $0x0, 0x5c(%r13)
setne %r8b
movq %r12, %rsi
movl $0x4, %ecx
callq 0xf1d74
testl %ebx, %ebx
jne 0x1080df
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movups 0x20(%rbp), %xmm2
movq 0xa8(%rsp), %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movq 0x18(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movq 0xa0(%rsp), %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
addq $0x4, %r12
movq %r12, 0x20(%rsp)
addq $-0x4, 0x10(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x43ce5(%rip), %rsi     # 0x14bddf
movq 0xb0(%rsp), %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x30(%r13), %rax
testq %rax, %rax
je 0x10819e
leaq 0x30(%rsp), %r12
movq %r12, 0x128(%r13)
movq %r13, %rdi
callq *%rax
movq $0x0, 0x128(%r13)
testl %eax, %eax
jne 0x1081a3
jmp 0x10832d
cmpl $0x0, 0x138(%r13)
movq 0x18(%rsp), %rdx
je 0x108207
movq $0x0, 0x128(%r13)
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movups %xmm2, 0x20(%rbp)
movups %xmm1, 0x10(%rbp)
movups %xmm0, (%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
testl %eax, %eax
jne 0x10806d
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x30(%rsp), %r12
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %r8
movl 0x28(%rsp), %r9d
callq 0x107bde
testl %eax, %eax
je 0x107dee
movq 0x38(%r13), %rax
testq %rax, %rax
movb $0x1, %r12b
je 0x10832d
movl %ebx, 0x64(%r13)
leaq 0x30(%rsp), %rcx
movq %rcx, 0x128(%r13)
movq %r13, %rdi
callq *%rax
movq $0x0, 0x128(%r13)
testl %eax, %eax
jne 0x10832d
jmp 0x108330
cmpl $0x0, 0x130(%r13)
jne 0x10832d
movq (%r13), %r12
cmpb $0x0, 0x5d(%r13)
je 0x1082e6
movq 0x128(%r13), %rax
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movl 0x4(%rax), %eax
cmpl $0x41555447, %eax       # imm = 0x41555447
jle 0x108290
cmpl $0x41555448, %eax       # imm = 0x41555448
je 0x1082ab
cmpl $0x4e414d45, %eax       # imm = 0x4E414D45
je 0x1082ba
cmpl $0x54455854, %eax       # imm = 0x54455854
jne 0x1082e6
movq %r12, %rdi
movq %r13, %rsi
leaq 0x247b0(%rip), %r8      # 0x12ca13
jmp 0x1082d6
xorl %ecx, %ecx
leaq 0x43b85(%rip), %rdx     # 0x14bdf3
jmp 0x10827f
xorl %ecx, %ecx
leaq 0x1b18c(%rip), %rdx     # 0x123405
jmp 0x10827f
movb $0x1, %cl
xorl %edx, %edx
testb %cl, %cl
jne 0x107eb6
movq %rdx, 0x58(%rax)
jmp 0x107eb6
cmpl $0x28632920, %eax       # imm = 0x28632920
je 0x1082c9
cmpl $0x414e4e4f, %eax       # imm = 0x414E4E4F
jne 0x1082e6
movq %r12, %rdi
movq %r13, %rsi
callq 0x108410
jmp 0x1082db
movq %r12, %rdi
movq %r13, %rsi
leaq 0x1b14d(%rip), %r8      # 0x123405
jmp 0x1082d6
movq %r12, %rdi
movq %r13, %rsi
leaq 0x2035b(%rip), %r8      # 0x128622
jmp 0x1082d6
movq %r12, %rdi
movq %r13, %rsi
leaq 0xa409(%rip), %r8       # 0x1126df
callq 0x108390
movl $0x1, 0x130(%r13)
cmpl $0x0, 0x130(%r13)
jne 0x10832d
cmpl $0x3, (%r12)
jl 0x108322
movq 0x18(%r13), %rsi
movq 0x128(%r13), %rax
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %r12, %rdi
xorl %r9d, %r9d
callq 0xe975a
movl $0x1, 0x130(%r13)
xorl %r12d, %r12d
movq 0x8(%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 0x2c(%rsp), %esi
callq 0xe9595
addq 0xc0(%rsp), %r15
testb %r12b, %r12b
movq 0x18(%rsp), %rax
leaq 0x30(%rsp), %rdx
je 0x107cbb
jmp 0x107bfd
movl $0x1, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq