// File: /workspace/github_c_makefile_star2_O1/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 0xe969b
movq %rax, %r15
movq %r13, %rdi
callq 0x4399f
movl %eax, (%r15)
decl %eax
cmpl $0x3, %eax
ja 0x43946
leaq 0xd8bc9(%rip), %rcx     # 0x11be40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r13, (%rsp)
movq %r15, 0x18(%rsp)
jmpq *%rax
leaq 0xd8d68(%rip), %rsi     # 0x11bff8
jmp 0x43931
leaq 0xd8d50(%rip), %rsi     # 0x11bfec
movq %r13, %rdi
callq 0xeb6d6
leaq 0xd8d85(%rip), %rsi     # 0x11c030
movq %r13, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
movl $0x10, %esi
callq 0xef37e
movq %rax, 0x20(%r15)
leaq 0xd8d69(%rip), %rsi     # 0x11c046
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x20(%r15), %r15
leaq 0xd8d5e(%rip), %rsi     # 0x11c060
movq %r13, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0xef0d5
movzbl %al, %ebx
movl %ebx, %r12d
shrl %r12d
leaq 0xd8d3d(%rip), %rsi     # 0x11c075
movq %r13, %rdi
movl %ebx, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe9226
cmpb $0x2, %bl
jb 0x43507
addq $0x5, %r15
xorl %ebp, %ebp
leaq -0x4(%r15), %rsi
movq 0x18(%r13), %rdi
callq 0xef37e
movq %rax, %rbx
movq 0x18(%r13), %rdi
movq %r15, %rsi
callq 0xef37e
movq %rax, %r14
movq %r13, %rdi
leaq 0xd8d1a(%rip), %rsi     # 0x11c099
movl %ebp, %edx
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
cmpq $0x1000007d, %rbx       # imm = 0x1000007D
jne 0x434ea
movq %r13, %rdi
leaq 0xd8d08(%rip), %rsi     # 0x11c0b9
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
movq %r14, %rsi
callq 0xef1ca
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq 0x2(%r14), %rsi
callq 0xef1ca
movq %r13, %rdi
leaq 0xd8ce1(%rip), %rsi     # 0x11c0cf
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
leaq 0x12(%r14), %rdx
movq %r13, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
callq 0x43b8f
movq 0x8(%rbx), %r13
leaq (%r14,%r13), %rsi
addq $0x12, %rsi
movq (%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xef1ca
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x14, %rsi
callq 0xef1ca
movq (%rsp), %rdi
leaq 0xd8ca8(%rip), %rsi     # 0x11c0f1
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x16, %rsi
callq 0xef37e
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x1a, %rsi
callq 0xef37e
movq (%rsp), %rdi
leaq 0xd8c7b(%rip), %rsi     # 0x11c107
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x1e, %rsi
callq 0xef37e
movq %rax, %rbx
movq (%rsp), %rax
movq 0x18(%rax), %rdi
leaq (%r14,%r13), %rsi
addq $0x22, %rsi
movq (%rsp), %r13
callq 0xef37e
movq %r13, %rdi
leaq 0xd8c4d(%rip), %rsi     # 0x11c11f
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %rbp
addq $0x8, %r15
cmpq %rbp, %r12
jne 0x43356
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rsp), %r15
jmp 0x43974
leaq 0xd8aee(%rip), %rsi     # 0x11c013
movq %r13, %rdi
callq 0xeb6d6
leaq 0xf5e2a(%rip), %rsi     # 0x13935e
xorl %ebp, %ebp
movq %r13, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
movl $0x10, %esi
callq 0xef37e
movq %rax, %rbx
leaq 0xf896c(%rip), %rsi     # 0x13bed3
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
leaq 0xf553c(%rip), %rsi     # 0x138ac4
movq %r13, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r13), %rdi
movq %rbx, %rsi
callq 0xef0d5
movzbl %al, %r14d
leaq 0xd8d9d(%rip), %rsi     # 0x11c356
movq %r13, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xe9226
leaq (%r14,%r14,2), %r14
leaq (%rbx,%r14), %rsi
incq %rsi
movq 0x18(%r13), %rdi
callq 0xef0d5
movzbl %al, %r12d
leaq 0xd8d8b(%rip), %rsi     # 0x11c370
movq %r13, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
leaq (%rbx,%r14), %rsi
addq $0x2, %rsi
movq %r12, %rbx
movq 0x18(%r13), %rdi
callq 0xef37e
movq %rax, %r12
leaq 0xd8d74(%rip), %rsi     # 0x11c384
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testb %bl, %bl
je 0x43959
movq %rbx, 0x8(%rsp)
xorl %esi, %esi
xorl %ebp, %ebp
xorl %ebx, %ebx
testq %rbp, %rbp
je 0x43653
movq %r13, %rdi
movq %rsi, %r14
movq %rbp, %rsi
callq 0x442fa
movq %r14, %rsi
testq %rsi, %rsi
je 0x43660
movq %r13, %rdi
callq 0x442fa
movq %rbx, %rdx
shrq $0x3f, %rdx
addq %rbx, %rdx
shrq %rdx
movq %r13, %rdi
leaq 0xd8d29(%rip), %rsi     # 0x11c3a0
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq %r13, %rdi
leaq 0xd8d15(%rip), %rsi     # 0x11c3aa
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0x440, %esi            # imm = 0x440
movq %r13, %rdi
callq 0xe969b
movq %rax, %rbp
movl $0x0, 0x20(%rax)
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %r12, %rcx
callq 0x43bf5
movq 0x38(%rbp), %rax
testq %rax, %rax
jle 0x43959
addq %rax, %r12
movq %rbx, %r14
incq %rbx
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpq 0x8(%rsp), %rbx
jge 0x43776
movq %r13, %rdi
leaq 0xd8cbb(%rip), %rsi     # 0x11c3c3
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0x440, %esi            # imm = 0x440
movq %r13, %rdi
callq 0xe969b
movq %rax, %rbx
movl $0x1, 0x20(%rax)
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rdx
movq %r12, %rcx
callq 0x43bf5
movq %rbx, %rsi
movq 0x38(%rbx), %rax
testq %rax, %rax
jle 0x4395b
addq %rax, %r12
movq %r14, %rbx
addq $0x2, %rbx
movq %r13, %rdi
movq %rsi, %r14
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %r14, %rax
jmp 0x43778
xorl %eax, %eax
testq %rbp, %rbp
movq %rax, 0x20(%rsp)
je 0x438d4
movq %r12, 0x10(%rsp)
movq 0x30(%rbp), %r12
testq %r12, %r12
je 0x438f4
testq %rax, %rax
je 0x438d9
movq 0x30(%rax), %r14
testq %r14, %r14
je 0x438d9
movq %rbx, 0x28(%rsp)
movq %rbp, 0x30(%rsp)
movq 0x18(%r12), %rsi
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rcx
xorl %eax, %eax
cmpl $0x3, 0x24(%r12)
setge %al
leal 0x2(,%rax,2), %r8d
movq %r13, %rdi
callq 0xf2ce6
movq %rax, %r13
cmpq $0x0, 0x10(%rax)
jle 0x438ad
xorl %r15d, %r15d
cmpq $0x0, 0x8(%r13)
jle 0x438a0
xorl %ebx, %ebx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xf2bd3
movl %eax, %ebp
movl $0xff000000, %eax       # imm = 0xFF000000
cmpq 0x18(%r12), %rbx
jge 0x4387b
xorl %eax, %eax
cmpq 0x18(%r14), %rbx
jge 0x4387b
cmpq 0x10(%r14), %r15
jge 0x4387b
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xf2bd3
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 0xece35
movq 0x20(%rsp), %rcx
cmpq $0x0, 0x10(%rcx)
jne 0x43873
cmpq $0x8, 0x18(%rcx)
sete %cl
negb %cl
xorb %cl, %al
notb %al
movzbl %al, %eax
shll $0x18, %eax
andl $0xffffff, %ebp         # imm = 0xFFFFFF
orl %eax, %ebp
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xf2b02
incq %rbx
cmpq 0x8(%r13), %rbx
jl 0x43800
incq %r15
cmpq 0x10(%r13), %r15
jl 0x437f3
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf2923
movq 0x18(%rsp), %r15
movq 0x30(%rsp), %rbp
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %rbx
jmp 0x43901
xorl %r13d, %r13d
jmp 0x438fc
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf2923
xorl %r13d, %r13d
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r12
jmp 0x43901
xorl %r13d, %r13d
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %r14
movq %r13, %rdi
callq 0xf28d4
movq (%rsp), %r13
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpq %r14, %rbx
movq 0x20(%rsp), %rsi
jl 0x4363d
jmp 0x4395b
leaq 0xd86d0(%rip), %rsi     # 0x11c001
movq %r13, %rdi
callq 0xeb6d6
movq %r13, %rdi
movq %r15, %rsi
callq 0x43a45
jmp 0x43974
leaq 0xd86cf(%rip), %rsi     # 0x11c01c
movq %r13, %rdi
xorl %eax, %eax
callq 0xea1a2
jmp 0x43974
xorl %esi, %esi
movq %r13, %rdi
movq %rsi, %rbx
movq %rbp, %rsi
callq 0x442fa
movq %r13, %rdi
movq %rbx, %rsi
callq 0x442fa
movq %r13, %rdi
movq %r15, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9752