// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %r13
leaq 0x50(%rax), %r14
movl $0x2, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0xf3bdb
movq %r13, %r15
addq $0x10, %r15
leaq 0xb9525(%rip), %rdi     # 0x124f30
movl $0x10, %edx
movq %r15, %rsi
callq 0xec5fe
movq 0x18(%rbx), %rdi
movl $0x6, %esi
callq 0xeead3
cmpb $0x32, %al
je 0x6be80
movzbl %al, %eax
cmpl $0x4a, %eax
je 0x6be76
cmpl $0x45, %eax
jne 0x6be95
movq %r15, 0x38(%rsp)
movq %r14, 0x40(%rsp)
leaq 0xb792b(%rip), %rsi     # 0x12337f
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
leaq 0x70(%rsp), %rsi
movq $0xc, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeebeb
movq %rax, 0x8(%r13)
leaq 0xb9e34(%rip), %rsi     # 0x1258c1
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpq $0x0, 0x8(%r13)
jle 0x6be9a
xorl %r12d, %r12d
movq %r13, 0x10(%rsp)
cmpb $0x0, (%r13)
jne 0x6be9a
movq %r12, %r15
shlq $0x5, %r15
leaq 0x20(%r15), %r14
movq %r14, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
callq 0xe8a1c
leaq 0x40(%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
movq %r12, 0x60(%rsp)
jle 0x6bafb
xorl %esi, %esi
jmp 0x6be47
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %rbp
movq %r12, (%rax)
movq %rbx, %rdi
leaq 0xb9db8(%rip), %rsi     # 0x1258d0
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
addq $0x22, %r15
movq %r15, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0xeebeb
movq %rax, 0x8(%rbp)
movq %rbx, %rdi
leaq 0xb9d88(%rip), %rsi     # 0x1258e2
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
addq $0x4, 0x20(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, 0x10(%rbp)
movq %rbx, %rdi
leaq 0xb9d6d(%rip), %rsi     # 0x1258f0
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbp, %rsi
cmpq %r14, 0x10(%rbp)
jle 0x6be47
cmpq $0x0, 0x8(%rsi)
jle 0x6be4e
xorl %ebp, %ebp
movq $0x0, 0x18(%rsp)
movq %rsi, 0x68(%rsp)
cmpb $0x0, (%r13)
jne 0x6be4e
movq 0x10(%rsi), %r14
leaq (%r14,%rbp), %r15
movq %r15, 0x28(%rsp)
movq %rbx, %rdi
movq %rbp, %r12
movq %rsi, %rbp
leaq 0x34(%rsp), %rsi
callq 0xe8a1c
movq 0x18(%rbx), %rax
cmpq %r15, 0x18(%rax)
jle 0x6bcf0
movl (%rbp), %edx
movq %rbx, %rdi
leaq 0xb9d0f(%rip), %rsi     # 0x12590a
movq 0x18(%rsp), %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r12, %rbp
leaq (%r12,%r14), %rax
addq $0x6, %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0xeebeb
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movq %rax, %r12
movq %rbx, %rdi
movq %r13, 0x50(%rsp)
movq %r13, %rsi
movq %rax, %rdx
callq 0xe8f88
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
movq %rbx, %rdi
leaq 0xb9cbf(%rip), %rsi     # 0x125932
movq %rax, 0x58(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movq %rax, %r13
movq %rbx, %rdi
leaq 0xcde74(%rip), %rsi     # 0x139b0e
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4, 0x28(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
movq %rax, %r14
movq %rbx, %rdi
leaq 0xb9c7e(%rip), %rsi     # 0x125941
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpq %r15, %r14
jle 0x6bcdf
addq %r14, %r13
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r13
jle 0x6bd36
movq 0x10(%rsp), %r13
movw $0x101, (%r13)          # imm = 0x101
xorl %r15d, %r15d
jmp 0x6bcfd
movw $0x101, (%r13)          # imm = 0x101
xorl %r15d, %r15d
movq %r12, %rbp
movq %r15, %rdi
callq 0xf228d
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x18(%rsp), %rcx
incq %rcx
addq $0x30, %rbp
movq 0x68(%rsp), %rsi
movq %rcx, 0x18(%rsp)
cmpq 0x8(%rsi), %rcx
jl 0x6bbb5
jmp 0x6be4e
movl $0x1, %eax
movq 0x58(%rsp), %r15
cmpl $0x2, %r15d
je 0x6bd51
movl $0x4, %eax
cmpl $0x10, %r15d
jne 0x6bdce
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
movq 0x50(%rsp), %r13
movq %r13, %rsi
movq %r12, %rdx
callq 0xf1db1
testl %eax, %eax
je 0x6bddf
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
movl $0x3, %ecx
callq 0xf266a
movq %r15, %rcx
movq %rax, %r15
cmpl $0x2, %ecx
jne 0x6bdec
movl $0x8, %esi
movq %r13, %rdi
callq 0xe9cb4
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 0xf2f79
movl $0x8, %edx
jmp 0x6be33
movq %rbx, %rdi
leaq 0xab942(%rip), %rsi     # 0x11771a
xorl %eax, %eax
callq 0xe9295
xorl %r15d, %r15d
movq 0x10(%rsp), %r13
jmp 0x6bcfd
movq 0x48(%rsp), %rdi
imulq %r13, %rdi
movl $0x20, %esi
callq 0xe9cb4
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 0xf2f79
movl $0x2, %edx
movq 0x10(%rsp), %r13
movq %r15, %rdi
xorl %esi, %esi
callq 0xf22dc
jmp 0x6bcfd
movw $0x101, (%r13)          # imm = 0x101
movq %rbx, %rdi
callq 0xe8be2
movl 0x30(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq 0x60(%rsp), %r12
incq %r12
cmpq 0x8(%r13), %r12
jl 0x6bab9
jmp 0x6be9a
movl $0x0, 0x4(%r13)
jmp 0x6be88
movl $0x1, 0x4(%r13)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6d33c
jmp 0x6be9a
movb $0x1, 0x1(%r13)
cmpb $0x0, 0x1(%r13)
je 0x6beb2
leaq 0xad0e7(%rip), %rsi     # 0x118f8f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe8be2
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq