// File: /workspace/github_c_makefile_star2_O2/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 0x1bcfe
movl $0x1, 0x134(%r15)
jmp 0x1be7a
cmpl $0x1, 0x64(%r15)
jne 0x1be7a
cmpl $0x49434f4e, 0xfc(%r15) # imm = 0x49434F4E
jne 0x1be7a
movq (%r15), %rbx
movq 0x10(%r15), %r14
movq 0x40(%rcx), %r13
cmpl $0x494d4147, %eax       # imm = 0x494D4147
je 0x1bd85
cmpl $0x46414345, %eax       # imm = 0x46414345
jne 0x1be7a
movl $0x1, 0x130(%r15)
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xe3eb4
movzbl %al, %eax
incq %rax
movq %rax, 0x78(%r14)
movq 0x18(%r15), %rdi
incq %r13
movq %r13, %rsi
callq 0xe3eb4
movzbl %al, %edx
incq %rdx
movq %rdx, 0x80(%r14)
movq 0x78(%r14), %rsi
movq %rbx, %rdi
callq 0xdf038
jmp 0x1be7a
movl $0x1, 0x130(%r15)
cmpq $0x0, 0x78(%r14)
jle 0x1be69
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3eb4
movzbl %al, %edx
leaq 0xe8af4(%rip), %rsi     # 0x1048a5
movq %rbx, %rdi
movq %rdx, 0x30(%rsp)
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x1(%r13), %rsi
callq 0xe3eb4
movzbl %al, %eax
movq %rax, 0x50(%rsp)
leal 0x1(%rax), %edx
leaq 0xe8a26(%rip), %rsi     # 0x104805
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x2(%r13), %rsi
callq 0xe3eb4
movzbl %al, %ebp
movl %ebp, %r12d
andl $0x1, %r12d
andl $0x2, %ebp
movl %ebp, %r15d
shrl %r15d
leaq 0xe8aaf(%rip), %rsi     # 0x1048bf
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
leaq 0xe8ab0(%rip), %rsi     # 0x1048d4
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
leaq 0x3(%r13), %rsi
callq 0xe3eb4
movb %al, 0x13(%rsp)
movzbl %al, %r15d
leaq 0xf349a(%rip), %rsi     # 0x10f2e7
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
cmpb $0x2, %r15b
jb 0x1be8c
leaq 0xe8a7d(%rip), %rsi     # 0x1048e4
jmp 0x1be70
leaq 0xe8a1e(%rip), %rsi     # 0x10488e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
pushq $0x1
popq %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %ebp, %ebp
jne 0x1be9a
movl $0x0, 0x14(%rsp)
jmp 0x1bed2
movq 0x18(%rbx), %rdi
leaq 0x4(%r13), %rsi
callq 0xe3eb4
movl %eax, 0x14(%rsp)
movzbl %al, %r15d
leaq 0xe8a4b(%rip), %rsi     # 0x104901
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
cmpb $0x2, %r15b
jb 0x1bed2
leaq 0xe8a4e(%rip), %rsi     # 0x10491e
jmp 0x1be70
movq 0x18(%rbx), %rdi
leaq 0x5(%r13), %rsi
callq 0xe3eb4
movzbl %al, %r15d
leaq 0xe8a59(%rip), %rsi     # 0x104943
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
leal -0x9(%r15), %eax
cmpb $-0x9, %al
ja 0x1bf18
leaq 0xe8a50(%rip), %rsi     # 0x104956
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xdf2a5
jmp 0x1be7a
movq 0x18(%rbx), %rdi
leaq 0x6(%r13), %rsi
callq 0xe3f46
movq %rax, 0x40(%rsp)
incq %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%r13), %rsi
callq 0xe3f46
movq %rax, 0x48(%rsp)
leaq 0xa(%r13), %rax
movq %rax, 0x20(%rsp)
movl $0x2800, %esi           # imm = 0x2800
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe59cd
movl $0x100000, %esi         # imm = 0x100000
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0xe5a74
leaq 0xe8a0c(%rip), %rsi     # 0x104981
movq %rbx, %rdi
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
xorl %eax, %eax
callq 0xde896
testl %ebp, %ebp
je 0x1c075
movq %r15, 0x38(%rsp)
movq 0x48(%rsp), %rbp
incq %rbp
movq 0x40(%rsp), %rax
leaq (%rax,%r13), %r15
addq $0xb, %r15
leaq 0xe89e8(%rip), %rsi     # 0x10499a
movq %rbx, %rdi
movl %r15d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
cmpb $0x0, 0x14(%rsp)
je 0x1bfed
pushq $0x8
popq %r8
movq %r15, %rsi
movq %rbp, %rdx
movq 0x18(%rsp), %rcx
callq 0x1c137
jmp 0x1bffd
movq %r15, %rsi
movq %rbp, %rdx
movq 0x18(%rsp), %rcx
callq 0xe45f4
movq 0x30(%rsp), %rbp
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq $0x100, %r15            # imm = 0x100
je 0x1c065
cmpq 0x50(%rsp), %r15
jbe 0x1c026
movl $0xff000000, 0x88(%r14,%r15,4) # imm = 0xFF000000
jmp 0x1c05c
movq 0x18(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xe45a4
movl %eax, %edx
andl $0xffffff, %edx         # imm = 0xFFFFFF
cmpq %r15, %rbp
cmovnel %eax, %edx
testl %r12d, %r12d
cmovel %eax, %edx
movl %edx, 0x88(%r14,%r15,4)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xdf23b
incq %r15
addq $0x3, %r13
jmp 0x1c008
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x38(%rsp), %r15
movq 0x18(%rsp), %r13
movq %r13, %rdi
callq 0xe62cf
movq 0x18(%rbx), %rdi
cmpb $0x0, 0x13(%rsp)
je 0x1c0a4
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %r13, %rcx
movl %r15d, %r8d
callq 0x1c137
jmp 0x1c0b6
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %r13, %rcx
callq 0xe45f4
movq 0x78(%r14), %rsi
movq 0x80(%r14), %rdx
addl $0x3, %r12d
movq %rbx, %rdi
movl %r12d, %ecx
callq 0xe7437
movq %rax, %r15
movq 0x78(%r14), %rcx
addq $0x88, %r14
andl $0x0, (%rsp)
xorl %r12d, %r12d
pushq $0x8
popq %rdx
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %r8
movq %rax, %r9
callq 0xe7cbc
cmpb $0x0, 0xd0(%rbx)
leaq 0x109b6d(%rip), %rsi    # 0x125c73
cmoveq %r12, %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0xe70b7
testq %r13, %r13
je 0x1c121
movq %r13, %rdi
callq 0xe5591
testq %r15, %r15
je 0x1be7a
movq %r15, %rdi
callq 0xe7084
jmp 0x1be7a