// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/amigaicon.c
// Function: my_iff_chunk_handler
static int my_iff_chunk_handler(struct de_iffctx *ictx)
{
	deark *c = ictx->c;
	lctx *d = (lctx*)ictx->userdata;
	i64 dpos, dlen;

	if(ictx->chunkctx->chunk4cc.id == CODE_FORM) {
		ictx->is_std_container = 1;
		return 1;
	}

	if(ictx->level!=1) {
		return 1;
	}

	if(ictx->curr_container_contentstype4cc.id != CODE_ICON) {
		return 1;
	}

	dpos = ictx->chunkctx->dpos;
	dlen = ictx->chunkctx->dlen;

	switch(ictx->chunkctx->chunk4cc.id) {
	case CODE_FACE: // FACE (parameters)
		ictx->handled = 1;
		d->glowicons_width = 1+(i64)dbuf_getbyte(ictx->f, dpos);
		d->glowicons_height = 1+(i64)dbuf_getbyte(ictx->f, dpos+1);
		de_dbg_dimensions(c, d->glowicons_width, d->glowicons_height);
		break;
	case CODE_IMAG: // IMAG (one of the images that make up this icon)
		ictx->handled = 1;
		do_glowicons_IMAG(c, d, dpos, dlen);
		break;
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r15
movq 0x128(%rdi), %rcx
movl 0x4(%rcx), %eax
cmpl $0x464f524d, %eax       # imm = 0x464F524D
jne 0x1bfd6
movl $0x1, 0x134(%r15)
jmp 0x1c173
cmpl $0x1, 0x64(%r15)
jne 0x1c173
cmpl $0x49434f4e, 0xfc(%r15) # imm = 0x49434F4E
jne 0x1c173
movq (%r15), %rbx
movq 0x10(%r15), %r14
movq 0x40(%rcx), %r12
cmpl $0x494d4147, %eax       # imm = 0x494D4147
je 0x1c05d
cmpl $0x46414345, %eax       # imm = 0x46414345
jne 0x1c173
movl $0x1, 0x130(%r15)
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0xef0d5
movzbl %al, %eax
incq %rax
movq %rax, 0x78(%r14)
movq 0x18(%r15), %rdi
incq %r12
movq %r12, %rsi
callq 0xef0d5
movzbl %al, %edx
incq %rdx
movq %rdx, 0x80(%r14)
movq 0x78(%r14), %rsi
movq %rbx, %rdi
callq 0xe9b05
jmp 0x1c173
movl $0x1, 0x130(%r15)
cmpq $0x0, 0x78(%r14)
jle 0x1c142
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef0d5
movzbl %al, %edx
leaq 0xf5830(%rip), %rsi     # 0x1118b9
movq %rbx, %rdi
movq %rdx, 0x48(%rsp)
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x1(%r12), %rsi
callq 0xef0d5
movzbl %al, %eax
movq %rax, 0x50(%rsp)
leal 0x1(%rax), %edx
leaq 0xf5761(%rip), %rsi     # 0x111819
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x2(%r12), %rsi
callq 0xef0d5
movzbl %al, %ebp
movl %ebp, %edx
andl $0x1, %edx
andl $0x2, %ebp
movl %ebp, %r15d
shrl %r15d
leaq 0xf57eb(%rip), %rsi     # 0x1118d3
movq %rbx, %rdi
movl %edx, 0x2c(%rsp)
xorl %eax, %eax
callq 0xe9226
leaq 0xf57eb(%rip), %rsi     # 0x1118e8
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
leaq 0x3(%r12), %rsi
callq 0xef0d5
movl %eax, %r13d
movzbl %al, %r15d
leaq 0x1001a1(%rip), %rsi    # 0x11c2c7
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
cmpb $0x2, %r15b
jb 0x1c187
leaq 0xf57b8(%rip), %rsi     # 0x1118f8
jmp 0x1c149
leaq 0xf5759(%rip), %rsi     # 0x1118a2
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %r13d, %r13d
testq %r13, %r13
je 0x1c166
movq %r13, %rdi
callq 0xf0b13
testq %r15, %r15
je 0x1c173
movq %r15, %rdi
callq 0xf28d4
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
jne 0x1c195
movl $0x0, 0x14(%rsp)
jmp 0x1c1d1
movq 0x18(%rbx), %rdi
leaq 0x4(%r12), %rsi
callq 0xef0d5
movl %eax, 0x14(%rsp)
movzbl %al, %r15d
leaq 0xf5763(%rip), %rsi     # 0x111915
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
cmpb $0x2, %r15b
jb 0x1c1d1
leaq 0xf5766(%rip), %rsi     # 0x111932
jmp 0x1c149
movq 0x18(%rbx), %rdi
leaq 0x5(%r12), %rsi
callq 0xef0d5
movzbl %al, %r15d
leaq 0xf576d(%rip), %rsi     # 0x111957
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
leal -0x9(%r15), %eax
cmpb $-0x9, %al
ja 0x1c21b
leaq 0xf5764(%rip), %rsi     # 0x11196a
movq %r15, %rdx
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x1c156
movb %r13b, 0x13(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x6(%r12), %rsi
callq 0xef169
movq %rax, 0x38(%rsp)
incq %rax
movq %rax, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%r12), %rsi
callq 0xef169
movq %rax, 0x40(%rsp)
leaq 0xa(%r12), %rax
movq %rax, 0x18(%rsp)
movl $0x2800, %esi           # imm = 0x2800
movq %rbx, %rdi
xorl %edx, %edx
callq 0xf0faf
movq %rax, %r13
movl $0x100000, %esi         # imm = 0x100000
movq %rax, %rdi
callq 0xf1066
leaq 0xf5717(%rip), %rsi     # 0x111995
movq %rbx, %rdi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
xorl %eax, %eax
callq 0xe9226
testl %ebp, %ebp
movl 0x2c(%rsp), %ebp
je 0x1c380
movq %r15, 0x30(%rsp)
movq 0x40(%rsp), %rax
incq %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%r12), %r15
addq $0xb, %r15
movq %rax, %r12
leaq 0xf56ec(%rip), %rsi     # 0x1119ae
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
cmpb $0x0, 0x14(%rsp)
je 0x1c300
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movl $0x8, %r8d
callq 0x1c422
jmp 0x1c30e
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xefabc
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq 0x50(%rsp), %r15
jbe 0x1c329
movl $0xff000000, 0x88(%r14,%r15,4) # imm = 0xFF000000
jmp 0x1c35e
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xefa60
movl %eax, %edx
andl $0xffffff, %edx         # imm = 0xFFFFFF
cmpq %r15, 0x48(%rsp)
cmovnel %eax, %edx
testl %ebp, %ebp
cmovel %eax, %edx
movl %edx, 0x88(%r14,%r15,4)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9d68
incq %r15
addq $0x3, %r12
cmpq $0x100, %r15            # imm = 0x100
jne 0x1c314
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x30(%rsp), %r15
movq %r13, %rdi
callq 0xf1a5f
movq 0x18(%rbx), %rdi
cmpb $0x0, 0x13(%rsp)
je 0x1c3aa
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rcx
movl %r15d, %r8d
callq 0x1c422
jmp 0x1c3bc
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %r13, %rcx
callq 0xefabc
movq 0x78(%r14), %rsi
movq 0x80(%r14), %rdx
addl $0x3, %ebp
movq %rbx, %rdi
movl %ebp, %ecx
callq 0xf2cab
movq %rax, %r15
movq 0x78(%r14), %rcx
addq $0x88, %r14
movl $0x0, (%rsp)
xorl %r12d, %r12d
movl $0x8, %edx
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %r8
movq %rax, %r9
callq 0xf35b8
cmpb $0x0, 0xd0(%rbx)
leaq 0x116744(%rip), %rsi    # 0x132b53
cmoveq %r12, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xf2923
jmp 0x1c159