// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %rdi, %rbx
movl $0x58, %esi
callq 0xe969b
movq %rax, %r14
leaq 0x50(%rax), %r15
movl $0x2, %esi
movq %r15, %rdi
movl $0x1, %edx
callq 0xf41f4
leaq 0x10(%r14), %r13
leaq 0xb90a5(%rip), %rdi     # 0x124d10
movl $0x10, %edx
movq %r13, %rsi
callq 0xecc60
movq 0x18(%rbx), %rdi
movl $0x6, %esi
callq 0xef0d5
cmpb $0x32, %al
je 0x6c0c7
movzbl %al, %eax
cmpl $0x4a, %eax
je 0x6c0bd
cmpl $0x45, %eax
jne 0x6c0dc
movq %r15, 0x40(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x70(%rsp), %r14
movq $0x0, (%r14)
leaq 0xb74df(%rip), %rsi     # 0x12319f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
addq $0xc, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
movq 0x10(%rsp), %r14
callq 0xef1ed
movq %rax, 0x8(%r14)
leaq 0xb9998(%rip), %rsi     # 0x125691
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpq $0x0, 0x8(%r14)
jle 0x6c0e1
xorl %ebp, %ebp
movq %r13, 0x38(%rsp)
cmpb $0x0, (%r14)
jne 0x6c0e1
movq %rbp, %r15
shlq $0x5, %r15
leaq 0x20(%r15), %r14
movq %r14, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0xe958c
addq $0x40, %r15
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r15
movq %rbp, 0x60(%rsp)
jle 0x6bd66
xorl %r15d, %r15d
jmp 0x6c087
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r12
movq %rbp, (%rax)
movq %rbx, %rdi
leaq 0xb991d(%rip), %rsi     # 0x1256a0
movq %rbp, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
addq $0x2, 0x18(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %r15
movq %r15, %rsi
callq 0xef1ed
movq %rax, 0x8(%r12)
movq %rbx, %rdi
leaq 0xb98ef(%rip), %rsi     # 0x1256b2
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
addq $0x4, 0x18(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r12, %r15
callq 0xef3a0
movq %rax, 0x10(%r12)
movq %rbx, %rdi
leaq 0xb98d0(%rip), %rsi     # 0x1256c0
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpq %r14, 0x10(%r12)
jle 0x6c087
cmpq $0x0, 0x8(%r15)
movq 0x10(%rsp), %r14
jle 0x6c092
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r15, 0x68(%rsp)
cmpb $0x0, (%r14)
jne 0x6c092
movq 0x10(%r15), %rbp
addq %r12, %rbp
movq %rbp, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x2c(%rsp), %rsi
callq 0xe958c
movq 0x18(%rbx), %rax
cmpq %rbp, 0x18(%rax)
jle 0x6bf3d
movl (%r15), %edx
movq %rbx, %rdi
leaq 0xb987c(%rip), %rsi     # 0x1256da
movl %r13d, %ecx
movq %rbp, %r8
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
addq $0x6, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0xef1ed
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef1ed
movq %rbx, %rdi
movq %r15, 0x58(%rsp)
movq %r15, %rsi
movq %rax, 0x50(%rsp)
movq %rax, %rdx
callq 0xe9b05
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rbx, %rdi
leaq 0xb9836(%rip), %rsi     # 0x125702
movq %rax, 0x30(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef1ed
movq %rax, %r15
movq %rbx, %rdi
leaq 0xcd87b(%rip), %rsi     # 0x13976e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x4, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef3a0
movq %rax, %r14
movq %rbx, %rdi
leaq 0xb97f5(%rip), %rsi     # 0x125711
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpq %rbp, %r14
jle 0x6bf38
addq %r14, %r15
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r15
jle 0x6bf75
movq 0x10(%rsp), %r14
movw $0x101, (%r14)          # imm = 0x101
xorl %r15d, %r15d
movq %r15, %rdi
callq 0xf28d4
movl 0x2c(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
incq %r13
addq $0x30, %r12
movq 0x68(%rsp), %r15
cmpq 0x8(%r15), %r13
jl 0x6be20
jmp 0x6c092
movl $0x1, %ecx
movq 0x30(%rsp), %rax
cmpl $0x2, %eax
je 0x6bf92
movl $0x4, %ecx
cmpl $0x10, %eax
jne 0x6c013
movq %rcx, 0x48(%rsp)
movq %rbx, %rdi
movq 0x58(%rsp), %r15
movq %r15, %rsi
movq 0x50(%rsp), %rbp
movq %rbp, %rdx
callq 0xf241d
testl %eax, %eax
je 0x6c024
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movl $0x3, %ecx
callq 0xf2cab
movq %r15, %rdi
movq %rax, %r15
cmpl $0x2, 0x30(%rsp)
jne 0x6c029
movl $0x8, %esi
callq 0xea80b
leaq 0x7(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0x3, %rcx
movq 0x18(%rbx), %rdi
movl $0x0, (%rsp)
movl $0x1, %edx
movq %r14, %rsi
movq 0x40(%rsp), %r8
movq %r15, %r9
callq 0xf35b8
movl $0x8, %edx
jmp 0x6c073
movq %rbx, %rdi
leaq 0xab65d(%rip), %rsi     # 0x11767a
xorl %eax, %eax
callq 0xe9df7
xorl %r15d, %r15d
jmp 0x6c07d
movq 0x48(%rsp), %rax
imulq %rdi, %rax
movl $0x20, %esi
movq %rax, %rdi
callq 0xea80b
leaq 0x7(%rax), %rcx
testq %rax, %rax
cmovnsq %rax, %rcx
sarq $0x3, %rcx
movq 0x18(%rbx), %rdi
movl $0x1, (%rsp)
movl $0x4, %edx
movq %r14, %rsi
movq 0x38(%rsp), %r8
movq %r15, %r9
callq 0xf35b8
movl $0x2, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0xf2923
movq 0x10(%rsp), %r14
jmp 0x6bf46
movq 0x10(%rsp), %r14
movw $0x101, (%r14)          # imm = 0x101
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movl 0x28(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq 0x60(%rsp), %rbp
incq %rbp
cmpq 0x8(%r14), %rbp
jl 0x6bd24
jmp 0x6c0e1
movl $0x0, 0x4(%r14)
jmp 0x6c0cf
movl $0x1, 0x4(%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6d56d
jmp 0x6c0e1
movb $0x1, 0x1(%r14)
testq %r14, %r14
je 0x6c109
cmpb $0x0, 0x1(%r14)
je 0x6c0fe
leaq 0xacd7b(%rip), %rsi     # 0x118e6f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq