// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/ilbm.c
// Function: my_iff_chunk_handler
static int my_iff_chunk_handler(struct de_iffctx *ictx)
{
	deark *c = ictx->c;
	int quitflag = 0;
	lctx *d = (lctx*)ictx->userdata;

	if(d->num_frames_finished >= ANIM_MAX_FRAMES) {
		quitflag = 1;
		goto done;
	}

	// Chunks that we support even if they are not in FORM:ILBM, FORM:PBM, etc. chunk.

	switch(ictx->chunkctx->chunk4cc.id) {
	case CODE_FORM:
		if(ictx->level==0) {
			// Remember this for later
			d->main_chunk_endpos = ictx->chunkctx->dpos + ictx->chunkctx->dlen;
		}
		if(ictx->level>d->FORM_level) break;
		ictx->is_std_container = 1;
		goto done;
	}

	// Chunks that we process only inside a FORM:ILBM, etc. chunk.

	if(!d->frctx) goto done;

	switch(ictx->chunkctx->chunk4cc.id) {
	case CODE_BMHD:
		ictx->handled = 1;
		if(!do_bmhd(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen)) {
			d->errflag = 1;
			goto done;
		}
		break;

	case CODE_ANHD:
		do_anim_anhd(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;

	case CODE_CMAP:
		do_cmap(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;

	case CODE_CAMG:
		do_camg(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;

	case CODE_BODY:
	case CODE_ABIT:
		ictx->handled = 1;
		do_body_or_abit(c, d, ictx, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		break;

	case CODE_DLTA:
		ictx->handled = 1;
		if(ictx->curr_container_contentstype4cc.id != CODE_ILBM) {
			d->errflag = 1;
			goto done;
		}
		do_dlta(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		break;

	case CODE_TINY:
		do_tiny(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_XS24:
		do_xs24(c, ictx->f, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;

	case CODE_DPI:
		do_dpi(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_GRAB:
		do_grab(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_DPAN:
		do_dpan(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_CRNG:
		do_crng(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_DRNG:
		do_drng(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_CCRT:
		do_ccrt(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_SHAM:
		d->is_sham = 1;
		on_multipalette_enabled(c, d);
		break;
	case CODE_PCHG:
		d->is_pchg = 1;
		on_multipalette_enabled(c, d);
		break;
	case CODE_CTBL:
		d->is_ctbl = 1;
		on_multipalette_enabled(c, d);
		break;
	case CODE_BEAM:
		d->is_beam = 1;
		on_multipalette_enabled(c, d);
		break;
	case CODE_CLUT:
		d->found_clut = 1;
		break;
	case CODE_ANSQ:
		do_ansq(c, d, ictx->chunkctx->dpos, ictx->chunkctx->dlen);
		ictx->handled = 1;
		break;
	case CODE_SBDY:
		if(d->is_anim && !d->found_audio) {
			de_info(c, "Note: This file includes AnimFX-style audio, which is "
				"not supported.");
			d->found_audio = 1;
		}
		break;
	}

done:
	return (quitflag) ? 0 : 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x10(%rdi), %rbx
movl 0x24(%rbx), %ebp
cmpl $0x270f, %ebp           # imm = 0x270F
jg 0x79807
movq %rdi, %r14
movq (%rdi), %r15
movq 0x128(%rdi), %rax
movl 0x4(%rax), %ecx
cmpl $0x464f524d, %ecx       # imm = 0x464F524D
jne 0x79486
movl 0x64(%r14), %edx
testl %edx, %edx
jne 0x79481
movq 0x48(%rax), %rsi
addq 0x40(%rax), %rsi
movq %rsi, 0x10(%rbx)
cmpl 0x18(%rbx), %edx
jle 0x794ec
cmpq $0x0, 0xb0(%rbx)
je 0x79807
cmpl $0x4354424b, %ecx       # imm = 0x4354424B
jg 0x794fc
cmpl $0x424f4458, %ecx       # imm = 0x424F4458
jle 0x79565
cmpl $0x434c5553, %ecx       # imm = 0x434C5553
jg 0x795fc
cmpl $0x424f4459, %ecx       # imm = 0x424F4459
je 0x796e9
cmpl $0x43414d47, %ecx       # imm = 0x43414D47
je 0x7978d
cmpl $0x43435254, %ecx       # imm = 0x43435254
jne 0x79807
movq 0x40(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a710
jmp 0x797e5
movl $0x1, 0x134(%r14)
jmp 0x79807
cmpl $0x47524141, %ecx       # imm = 0x47524141
jle 0x795b8
cmpl $0x5348414c, %ecx       # imm = 0x5348414C
jg 0x79638
cmpl $0x47524142, %ecx       # imm = 0x47524142
je 0x797d2
cmpl $0x50434847, %ecx       # imm = 0x50434847
je 0x797a2
cmpl $0x53424459, %ecx       # imm = 0x53424459
jne 0x79807
cmpl $0x0, (%rbx)
je 0x79807
cmpb $0x0, 0x44(%rbx)
jne 0x79807
leaq 0xaf445(%rip), %rsi     # 0x128997
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9ef5
movb $0x1, 0x44(%rbx)
jmp 0x79807
cmpl $0x414e5350, %ecx       # imm = 0x414E5350
jle 0x79675
cmpl $0x414e5351, %ecx       # imm = 0x414E5351
je 0x79760
cmpl $0x4245414d, %ecx       # imm = 0x4245414D
je 0x7973f
cmpl $0x424d4844, %ecx       # imm = 0x424D4844
jne 0x79807
movl $0x1, 0x130(%r14)
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79ac5
jmp 0x7972b
cmpl $0x4450414d, %ecx       # imm = 0x4450414D
jle 0x796a1
cmpl $0x4450414e, %ecx       # imm = 0x4450414E
je 0x79772
cmpl $0x44504920, %ecx       # imm = 0x44504920
je 0x79748
cmpl $0x44524e47, %ecx       # imm = 0x44524E47
jne 0x79807
movq 0x40(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a6b6
jmp 0x797e5
cmpl $0x434c5554, %ecx       # imm = 0x434C5554
je 0x797f2
cmpl $0x434d4150, %ecx       # imm = 0x434D4150
je 0x797a8
cmpl $0x43524e47, %ecx       # imm = 0x43524E47
jne 0x79807
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a612
jmp 0x797e5
cmpl $0x5348414d, %ecx       # imm = 0x5348414D
je 0x797f8
cmpl $0x54494e59, %ecx       # imm = 0x54494E59
je 0x797bd
cmpl $0x58533234, %ecx       # imm = 0x58533234
jne 0x79807
movq 0x18(%r14), %rsi
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
callq 0x7a42d
jmp 0x797e5
cmpl $0x41424954, %ecx       # imm = 0x41424954
je 0x796e9
cmpl $0x414e4844, %ecx       # imm = 0x414E4844
jne 0x79807
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79ccc
jmp 0x797e5
cmpl $0x4354424c, %ecx       # imm = 0x4354424C
je 0x79787
cmpl $0x444c5441, %ecx       # imm = 0x444C5441
jne 0x79807
movl $0x1, 0x130(%r14)
cmpl $0x494c424d, 0xfc(%r14) # imm = 0x494C424D
jne 0x79733
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a0e4
jmp 0x79807
movl $0x1, 0x130(%r14)
movq 0x40(%rax), %r14
movq 0x48(%rax), %r12
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r15, %rdi
callq 0xf241d
testl %eax, %eax
je 0x79733
movq 0xb0(%rbx), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x7a851
testl %eax, %eax
jne 0x79807
movl $0x1, 0x1c(%rbx)
jmp 0x79807
movb $0x1, 0x41(%rbx)
jmp 0x797fc
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a51b
jmp 0x797e5
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %r15, %rdi
callq 0x7a782
jmp 0x797e5
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a5de
jmp 0x797e5
movb $0x1, 0x3f(%rbx)
jmp 0x797fc
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a022
jmp 0x797e5
movb $0x1, 0x40(%rbx)
jmp 0x797fc
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79f8f
jmp 0x797e5
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a333
jmp 0x797e5
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a579
movl $0x1, 0x130(%r14)
jmp 0x79807
movb $0x1, 0x42(%rbx)
jmp 0x79807
movb $0x1, 0x3e(%rbx)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a74d
xorl %eax, %eax
cmpl $0x2710, %ebp           # imm = 0x2710
setl %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq