// File: /workspace/github_c_makefile_star2_O3/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 0x79404
movq %rdi, %r14
movq (%rdi), %r15
movq 0x128(%rdi), %rax
movl 0x4(%rax), %ecx
cmpl $0x464f524d, %ecx       # imm = 0x464F524D
jne 0x79084
movl 0x64(%r14), %edx
testl %edx, %edx
jne 0x7907f
movq 0x48(%rax), %rsi
addq 0x40(%rax), %rsi
movq %rsi, 0x10(%rbx)
cmpl 0x18(%rbx), %edx
jle 0x790ea
cmpq $0x0, 0xb0(%rbx)
je 0x79404
cmpl $0x4354424b, %ecx       # imm = 0x4354424B
jg 0x790fa
cmpl $0x424f4458, %ecx       # imm = 0x424F4458
jle 0x79163
cmpl $0x434c5553, %ecx       # imm = 0x434C5553
jg 0x791fa
cmpl $0x424f4459, %ecx       # imm = 0x424F4459
je 0x792e7
cmpl $0x43414d47, %ecx       # imm = 0x43414D47
je 0x7938a
cmpl $0x43435254, %ecx       # imm = 0x43435254
jne 0x79404
movq 0x40(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a303
jmp 0x793e2
movl $0x1, 0x134(%r14)
jmp 0x79404
cmpl $0x47524141, %ecx       # imm = 0x47524141
jle 0x791b6
cmpl $0x5348414c, %ecx       # imm = 0x5348414C
jg 0x79236
cmpl $0x47524142, %ecx       # imm = 0x47524142
je 0x793cf
cmpl $0x50434847, %ecx       # imm = 0x50434847
je 0x7939f
cmpl $0x53424459, %ecx       # imm = 0x53424459
jne 0x79404
cmpl $0x0, (%rbx)
je 0x79404
cmpb $0x0, 0x44(%rbx)
jne 0x79404
leaq 0xafa77(%rip), %rsi     # 0x128bc7
movq %r15, %rdi
xorl %eax, %eax
callq 0xe9393
movb $0x1, 0x44(%rbx)
jmp 0x79404
cmpl $0x414e5350, %ecx       # imm = 0x414E5350
jle 0x79273
cmpl $0x414e5351, %ecx       # imm = 0x414E5351
je 0x7935e
cmpl $0x4245414d, %ecx       # imm = 0x4245414D
je 0x7933d
cmpl $0x424d4844, %ecx       # imm = 0x424D4844
jne 0x79404
movl $0x1, 0x130(%r14)
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x796c9
jmp 0x79329
cmpl $0x4450414d, %ecx       # imm = 0x4450414D
jle 0x7929f
cmpl $0x4450414e, %ecx       # imm = 0x4450414E
je 0x79370
cmpl $0x44504920, %ecx       # imm = 0x44504920
je 0x79346
cmpl $0x44524e47, %ecx       # imm = 0x44524E47
jne 0x79404
movq 0x40(%rax), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a2a9
jmp 0x793e2
cmpl $0x434c5554, %ecx       # imm = 0x434C5554
je 0x793ef
cmpl $0x434d4150, %ecx       # imm = 0x434D4150
je 0x793a5
cmpl $0x43524e47, %ecx       # imm = 0x43524E47
jne 0x79404
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a205
jmp 0x793e2
cmpl $0x5348414d, %ecx       # imm = 0x5348414D
je 0x793f5
cmpl $0x54494e59, %ecx       # imm = 0x54494E59
je 0x793ba
cmpl $0x58533234, %ecx       # imm = 0x58533234
jne 0x79404
movq 0x18(%r14), %rsi
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
callq 0x7a01b
jmp 0x793e2
cmpl $0x41424954, %ecx       # imm = 0x41424954
je 0x792e7
cmpl $0x414e4844, %ecx       # imm = 0x414E4844
jne 0x79404
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x798d0
jmp 0x793e2
cmpl $0x4354424c, %ecx       # imm = 0x4354424C
je 0x79384
cmpl $0x444c5441, %ecx       # imm = 0x444C5441
jne 0x79404
movl $0x1, 0x130(%r14)
cmpl $0x494c424d, 0xfc(%r14) # imm = 0x494C424D
jne 0x79331
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79cdc
jmp 0x79404
movl $0x1, 0x130(%r14)
movq 0x40(%rax), %r14
movq 0x48(%rax), %r12
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movq %r15, %rdi
callq 0xf1db1
testl %eax, %eax
je 0x79331
movq 0xb0(%rbx), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x7a445
testl %eax, %eax
jne 0x79404
movl $0x1, 0x1c(%rbx)
jmp 0x79404
movb $0x1, 0x41(%rbx)
jmp 0x793f9
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a109
jmp 0x793e2
movq 0x40(%rax), %rsi
movq 0x48(%rax), %rdx
movq %r15, %rdi
callq 0x7a376
jmp 0x793e2
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movl (%rbx), %esi
movq %r15, %rdi
callq 0x7a1cc
jmp 0x793e2
movb $0x1, 0x3f(%rbx)
jmp 0x793f9
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79c1a
jmp 0x793e2
movb $0x1, 0x40(%rbx)
jmp 0x793f9
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79b87
jmp 0x793e2
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x79f2f
jmp 0x793e2
movq 0x40(%rax), %rdx
movq 0x48(%rax), %rcx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a167
movl $0x1, 0x130(%r14)
jmp 0x79404
movb $0x1, 0x42(%rbx)
jmp 0x79404
movb $0x1, 0x3e(%rbx)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7a340
xorl %eax, %eax
cmpl $0x2710, %ebp           # imm = 0x2710
setl %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq