// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/epocimage.c
// Function: de_run_epocimage
static void de_run_epocimage(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;

	d = de_malloc(c, sizeof(lctx));
	d->fmt = de_identify_epocimage_internal(c);

	switch(d->fmt) {
	case DE_PFMT_SKETCH:
		de_declare_fmt(c, "EPOC Sketch");
		de_run_epocsketch(c, d);
		break;
	case DE_PFMT_MBM:
		de_declare_fmt(c, "EPOC MBM");
		de_run_epocmbm(c, d);
		break;
	case DE_PFMT_EXPORTED_MBM:
		de_declare_fmt(c, "EPOC Exported MBM");
		de_run_epocmbm(c, d);
		break;
	case DE_PFMT_AIF:
		de_declare_fmt(c, "EPOC AIF");
		de_run_epocaif(c, d);
		break;
	default:
		de_internal_err_nonfatal(c, "Unidentified format");
	}

	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r13
movl $0x430, %esi            # imm = 0x430
callq 0xe8b2b
movq %rax, %rbx
movq 0x18(%r13), %rdi
callq 0x439be
movl %eax, (%rbx)
decl %eax
cmpl $0x3, %eax
ja 0x4395c
leaq 0xd8cc1(%rip), %rcx     # 0x11bf50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r13, (%rsp)
movq %rbx, 0x8(%rsp)
jmpq *%rax
leaq 0xd8e60(%rip), %rsi     # 0x11c108
jmp 0x43947
leaq 0xd8e48(%rip), %rsi     # 0x11c0fc
movq %r13, %rdi
callq 0xeb125
leaq 0xd8e7d(%rip), %rsi     # 0x11c140
movq %r13, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r13), %rdi
movl $0x10, %esi
callq 0xeed61
movq %rax, 0x20(%rbx)
leaq 0xd8e61(%rip), %rsi     # 0x11c156
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x20(%rbx), %r15
leaq 0xd8e56(%rip), %rsi     # 0x11c170
movq %r13, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0xeead3
movzbl %al, %ebx
movl %ebx, %r12d
shrl %r12d
leaq 0xd8e35(%rip), %rsi     # 0x11c185
movq %r13, %rdi
movl %ebx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe8617
cmpb $0x2, %bl
jb 0x4351f
addq $0x5, %r15
xorl %ebp, %ebp
leaq -0x4(%r15), %rsi
movq 0x18(%r13), %rdi
callq 0xeed61
movq %rax, %rbx
movq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0xeed61
movq %rax, %r14
movq %r13, %rdi
leaq 0xd8e12(%rip), %rsi     # 0x11c1a9
movl %ebp, %edx
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
cmpq $0x1000007d, %rbx       # imm = 0x1000007D
jne 0x43502
movq %r13, %rdi
leaq 0xd8e00(%rip), %rsi     # 0x11c1c9
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r13), %rdi
movq %r14, %rsi
callq 0xeebc8
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq 0x2(%r14), %rsi
callq 0xeebc8
movq %r13, %rdi
leaq 0xd8dd9(%rip), %rsi     # 0x11c1df
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
leaq 0x12(%r14), %rdx
movq %r13, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x43baa
movq 0x8(%rbx), %r13
leaq (%r14,%r13), %rsi
addq $0x12, %rsi
movq (%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xeebc8
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x14, %rsi
callq 0xeebc8
movq (%rsp), %rdi
leaq 0xd8da0(%rip), %rsi     # 0x11c201
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x16, %rsi
callq 0xeed61
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x1a, %rsi
callq 0xeed61
movq (%rsp), %rdi
leaq 0xd8d73(%rip), %rsi     # 0x11c217
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x1e, %rsi
callq 0xeed61
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x22, %rsi
movq (%rsp), %r13
callq 0xeed61
movq %r13, %rdi
leaq 0xd8d45(%rip), %rsi     # 0x11c22f
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
incq %rbp
addq $0x8, %r15
cmpq %rbp, %r12
jne 0x4336e
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
jmp 0x4398a
leaq 0xd8beb(%rip), %rsi     # 0x11c123
movq %r13, %rdi
callq 0xeb125
leaq 0xf61a7(%rip), %rsi     # 0x1396ee
xorl %r15d, %r15d
movq %r13, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r13), %rdi
movl $0x10, %esi
callq 0xeed61
movq %rax, %rbx
leaq 0xf8cf8(%rip), %rsi     # 0x13c273
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
leaq 0xf565d(%rip), %rsi     # 0x138bf9
movq %r13, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r13), %rdi
movq %rbx, %rsi
callq 0xeead3
movzbl %al, %r14d
leaq 0xd8e99(%rip), %rsi     # 0x11c466
movq %r13, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe8617
leaq (%r14,%r14,2), %r14
leaq (%rbx,%r14), %rsi
incq %rsi
movq 0x18(%r13), %rdi
callq 0xeead3
movzbl %al, %r12d
leaq 0xd8e87(%rip), %rsi     # 0x11c480
movq %r13, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
leaq (%rbx,%r14), %rsi
addq $0x2, %rsi
movq 0x18(%r13), %rdi
callq 0xeed61
movq %rax, %r14
leaq 0xd8e73(%rip), %rsi     # 0x11c494
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
xorl %ebp, %ebp
testb %r12b, %r12b
je 0x43974
xorl %r15d, %r15d
xorl %ebx, %ebx
movq %r12, 0x30(%rsp)
testq %r15, %r15
je 0x43660
movq %r13, %rdi
movq %r15, %rsi
callq 0x4431f
testq %rbp, %rbp
je 0x43670
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4431f
movq %rbx, %rdx
shrq $0x3f, %rdx
addq %rbx, %rdx
shrq %rdx
movq %r13, %rdi
leaq 0xd8e29(%rip), %rsi     # 0x11c4b0
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r13, %rdi
leaq 0xd8e15(%rip), %rsi     # 0x11c4ba
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x440, %esi            # imm = 0x440
movq %r13, %rdi
callq 0xe8b2b
movq %rax, %r15
movl $0x0, 0x20(%rax)
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x43c10
movq %r15, %r12
movq 0x38(%r15), %r15
testq %r15, %r15
jle 0x4396f
addq %r14, %r15
leaq 0x1(%rbx), %rbp
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpq 0x30(%rsp), %rbp
jge 0x438cc
movq %rbx, %r14
movq %r13, %rdi
leaq 0xd8db1(%rip), %rsi     # 0x11c4d3
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rdi
movl $0x1, %esi
callq 0xe8a15
movl $0x440, %esi            # imm = 0x440
movq %r13, %rdi
callq 0xe8b2b
movq %rax, %rbp
movl $0x1, 0x20(%rax)
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq %rax, %rdx
movq %r15, %rcx
callq 0x43c10
movq 0x38(%rbp), %rax
testq %rax, %rax
jle 0x43971
movq %rbp, 0x10(%rsp)
addq %rax, %r15
movq %r15, 0x28(%rsp)
addq $0x2, %r14
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r14, %rbp
movq %r12, %r15
movq 0x30(%r12), %r14
testq %r14, %r14
je 0x438f0
movq %rbp, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x30(%rax), %r15
testq %r15, %r15
je 0x438f5
movq 0x18(%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
xorl %eax, %eax
cmpl $0x3, 0x24(%r14)
setge %al
leal 0x2(,%rax,2), %r8d
movq %r13, %rdi
callq 0xf26a5
movq %rax, %r12
movq 0x10(%rax), %rcx
testq %rcx, %rcx
jle 0x438c2
movq 0x8(%r12), %rax
xorl %ebp, %ebp
testq %rax, %rax
jle 0x438b6
xorl %ebx, %ebx
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0xf2592
movl %eax, %r13d
movl $0xff000000, %eax       # imm = 0xFF000000
cmpq 0x18(%r14), %rbx
jge 0x43881
xorl %eax, %eax
cmpq 0x18(%r15), %rbx
jge 0x43881
cmpq 0x10(%r15), %rbp
jge 0x43881
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0xf2592
movl %eax, %ecx
shrl $0x10, %ecx
movl $0xff, %edx
andl %edx, %ecx
movl %eax, %esi
shrl $0x8, %esi
andl %edx, %esi
andl %edx, %eax
addl %eax, %esi
addl %ecx, %esi
movl $0x2fd, %edi            # imm = 0x2FD
callq 0xec7dc
movq 0x10(%rsp), %rcx
cmpq $0x0, 0x10(%rcx)
jne 0x43879
cmpq $0x8, 0x18(%rcx)
sete %cl
negb %cl
xorb %cl, %al
notb %al
movzbl %al, %eax
shll $0x18, %eax
andl $0xffffff, %r13d        # imm = 0xFFFFFF
orl %eax, %r13d
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movl %r13d, %ecx
callq 0xf24bf
incq %rbx
movq 0x8(%r12), %rax
cmpq %rax, %rbx
jl 0x43806
movq 0x10(%r12), %rcx
movq (%rsp), %r13
incq %rbp
cmpq %rcx, %rbp
jl 0x437fb
movq 0x18(%rsp), %rbp
movq %r12, %r14
jmp 0x438fd
movq %r15, 0x28(%rsp)
movq %r12, %r15
movq 0x30(%r12), %r14
movl $0x0, %eax
movq %rax, 0x10(%rsp)
movl $0x0, %r12d
testq %r14, %r14
jne 0x43902
jmp 0x4390e
xorl %r12d, %r12d
jmp 0x4390e
movq 0x18(%rsp), %rbp
xorl %r12d, %r12d
movq 0x20(%rsp), %r15
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf22dc
movq %r12, %rdi
callq 0xf228d
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x28(%rsp), %r14
movq %rbp, %rbx
movq 0x30(%rsp), %r12
cmpq %r12, %rbp
movq 0x10(%rsp), %rbp
jl 0x43650
jmp 0x43974
leaq 0xd87ca(%rip), %rsi     # 0x11c111
movq %r13, %rdi
callq 0xeb125
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43a60
jmp 0x4398f
leaq 0xd87c9(%rip), %rsi     # 0x11c12c
movq %r13, %rdi
xorl %eax, %eax
callq 0xe9640
jmp 0x4398f
xorl %ebp, %ebp
movq %r12, %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x4431f
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4431f
movq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8be2