// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/misc2.c
// Function: de_run_fmtowns_icn
static void de_run_fmtowns_icn(deark *c, de_module_params *mparams)
{
	struct fmtownsicn_ctx *d = NULL;
	u8 b;

	d = de_malloc(c, sizeof(struct fmtownsicn_ctx));
	fmtownsicn_make_palettes(c, d);

	b = de_getbyte(6);
	if(b=='E') {
		do_fmtownsicn_ICNFILE(c, d);
	}
	else if(b=='2') {
		d->is_le = 1;
		do_fmtownsicn_FJ(c, d);
	}
	else if(b=='J') {
		d->is_le = 0;
		do_fmtownsicn_FJ(c, d);
	}
	else {
		d->need_errmsg = 1;
		goto done;
	}

done:
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported file");
		}
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
pushq $0x58
popq %rsi
callq 0xdecaf
movq %rax, %rbp
leaq 0x50(%rax), %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %rdi, 0x48(%rsp)
callq 0xe87a8
movq %rbp, %rsi
addq $0x10, %rsi
leaq 0xaff63(%rip), %rdi     # 0x117d30
pushq $0x10
popq %rdx
movq %rsi, 0x40(%rsp)
callq 0xe1b9f
movq 0x18(%rbx), %rdi
pushq $0x6
popq %rsi
callq 0xe3eb4
cmpb $0x32, %al
je 0x68204
movzbl %al, %eax
cmpl $0x4a, %eax
je 0x681fe
cmpl $0x45, %eax
jne 0x68218
leaq 0xae3b5(%rip), %rsi     # 0x1161bf
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x80(%rsp), %rsi
movq $0xc, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3fc4
movq %rax, 0x8(%rbp)
leaq 0xb087d(%rip), %rsi     # 0x1186c1
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x14(%rsp), %r12
xorl %r13d, %r13d
movq %rbp, 0x18(%rsp)
cmpq 0x8(%rbp), %r13
jge 0x6821c
cmpb $0x0, (%rbp)
jne 0x6821c
movq %r13, %r15
shlq $0x5, %r15
leaq 0x20(%r15), %r14
movq %r14, 0x20(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xdebae
leaq 0x40(%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
movq %r13, 0x58(%rsp)
jle 0x67eb1
xorl %esi, %esi
jmp 0x681d7
movq %rbx, %rdi
pushq $0x18
popq %rsi
callq 0xdecaf
movq %rax, %r12
movq %r13, (%rax)
movq %rbx, %rdi
leaq 0xb0804(%rip), %rsi     # 0x1186d0
movq %r13, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
addq $0x22, %r15
movq %r15, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x8(%r12)
movq %rbx, %rdi
leaq 0xb07d5(%rip), %rsi     # 0x1186e2
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
addq $0x4, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, 0x10(%r12)
movq %rbx, %rdi
leaq 0xb07b9(%rip), %rsi     # 0x1186f0
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r12, %rsi
cmpq %r14, 0x10(%r12)
jle 0x681d2
xorl %r12d, %r12d
xorl %eax, %eax
movq %rsi, 0x78(%rsp)
cmpq 0x8(%rsi), %rax
jge 0x681cb
cmpb $0x0, (%rbp)
jne 0x681cb
movq %rax, 0x38(%rsp)
movq 0x10(%rsi), %r13
leaq (%r12,%r13), %r14
movq %r14, 0x28(%rsp)
movq %rbx, %rdi
movq %r12, %r15
movq %rsi, %r12
leaq 0x34(%rsp), %rsi
callq 0xdebae
movq 0x18(%rbx), %rax
cmpq %r14, 0x18(%rax)
jle 0x680a2
movl (%r12), %edx
movq %rbx, %rdi
leaq 0xb075c(%rip), %rsi     # 0x11870a
movq 0x38(%rsp), %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
leaq (%r15,%r13), %rax
addq $0x6, %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x28(%rsp), %r13
movq %r13, %rsi
callq 0xe3fc4
movq %rax, %r12
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rbx, %rdi
movq %r12, 0x68(%rsp)
movq %r12, %rsi
movq %rax, 0x60(%rsp)
movq %rax, %rdx
callq 0xdf038
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq %rbx, %rdi
leaq 0xb070f(%rip), %rsi     # 0x118732
movq %rax, 0x70(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xc47b4(%rip), %rsi     # 0x12c7fe
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4, 0x28(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq %rax, %r13
movq %rbx, %rdi
leaq 0xb06ce(%rip), %rsi     # 0x118741
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpq %r14, %r13
movq %r15, %r12
jle 0x68092
addq %r13, %rbp
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rbp
jle 0x680d8
movq 0x18(%rsp), %rbp
movw $0x101, (%rbp)          # imm = 0x101
xorl %r14d, %r14d
jmp 0x680ae
movw $0x101, (%rbp)          # imm = 0x101
xorl %r14d, %r14d
movq %r15, %r12
movq %r14, %rdi
callq 0xe7084
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x38(%rsp), %rax
incq %rax
addq $0x30, %r12
movq 0x78(%rsp), %rsi
jmp 0x67f59
pushq $0x1
popq %rax
movq 0x70(%rsp), %rbp
cmpl $0x2, %ebp
je 0x680ed
pushq $0x4
popq %rax
cmpl $0x10, %ebp
jne 0x6815c
movq %rax, 0x50(%rsp)
movq %rbx, %rdi
movq 0x68(%rsp), %r15
movq %r15, %rsi
movq 0x60(%rsp), %r14
movq %r14, %rdx
callq 0xe6be1
testl %eax, %eax
je 0x6816d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
pushq $0x3
popq %rcx
callq 0xe7437
movq %rax, %r14
cmpl $0x2, %ebp
jne 0x6817a
movq %r15, %rdi
pushq $0x8
popq %rbp
movq %rbp, %rsi
callq 0xdfbb6
cqto
idivq %rbp
movq 0x18(%rbx), %rdi
andl $0x0, (%rsp)
movq %r13, %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
movq 0x48(%rsp), %r8
movq %r14, %r9
callq 0xe7cbc
pushq $0x8
jmp 0x681b6
movq %rbx, %rdi
leaq 0xa2524(%rip), %rsi     # 0x10a68a
xorl %eax, %eax
callq 0xdf2a5
xorl %r14d, %r14d
movq 0x18(%rsp), %rbp
jmp 0x680ae
movq 0x50(%rsp), %rdi
imulq %r15, %rdi
pushq $0x20
popq %rsi
callq 0xdfbb6
cqto
pushq $0x8
popq %rcx
idivq %rcx
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movq %r13, %rsi
pushq $0x4
popq %rdx
movq %rax, %rcx
movq 0x40(%rsp), %r8
movq %r14, %r9
callq 0xe7cbc
pushq $0x2
popq %rdx
movq 0x18(%rsp), %rbp
movq %r14, %rdi
xorl %esi, %esi
callq 0xe70b7
jmp 0x680ae
leaq 0x14(%rsp), %r12
jmp 0x681dd
leaq 0x14(%rsp), %r12
movw $0x101, (%rbp)          # imm = 0x101
movq %rbx, %rdi
callq 0xded32
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x58(%rsp), %r13
incq %r13
jmp 0x67e68
andl $0x0, 0x4(%rbp)
jmp 0x6820b
movl $0x1, 0x4(%rbp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x69690
jmp 0x6821c
movb $0x1, 0x1(%rbp)
cmpb $0x0, 0x1(%rbp)
je 0x68233
leaq 0xa3c76(%rip), %rsi     # 0x10be9f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xded32
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq