// File: /workspace/github_c_makefile_star2_O2/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, %r15
movl $0x430, %esi            # imm = 0x430
callq 0xdecaf
movq %rax, %r13
movq %r15, %rdi
callq 0x41b02
movl %eax, (%r13)
decl %eax
cmpl $0x3, %eax
ja 0x41a9b
leaq 0xcda34(%rip), %rcx     # 0x10ee60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r15, 0x18(%rsp)
movq %r13, 0x8(%rsp)
jmpq *%rax
leaq 0xcdbd2(%rip), %rsi     # 0x10f018
jmp 0x41a86
leaq 0xcdbba(%rip), %rsi     # 0x10f00c
movq %r15, %rdi
callq 0xe07f7
leaq 0xcdbef(%rip), %rsi     # 0x10f050
movq %r15, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rbx
movq %r15, %rdi
movl %ebx, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
pushq $0x10
popq %rsi
callq 0xe409f
movq %rax, 0x20(%r13)
leaq 0xcdbd5(%rip), %rsi     # 0x10f066
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq 0x20(%r13), %r12
leaq 0xcdbca(%rip), %rsi     # 0x10f080
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movl %ebx, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
movq %r12, %rsi
callq 0xe3eb4
movzbl %al, %edx
movl %edx, %ecx
shrl %ecx
leaq 0xcdbae(%rip), %rsi     # 0x10f095
movq %r15, %rdi
movl %ebp, %r15d
movq %rcx, (%rsp)
xorl %eax, %eax
callq 0xde896
addq $0x5, %r12
xorl %r14d, %r14d
movq 0x18(%rsp), %r13
cmpq %r14, (%rsp)
je 0x4169b
leaq -0x4(%r12), %rsi
movq 0x18(%r13), %rdi
callq 0xe409f
movq %rax, %rbx
movq 0x18(%r13), %rdi
movq %r12, %rsi
callq 0xe409f
movq %rax, %rbp
movq %r13, %rdi
leaq 0xcdb81(%rip), %rsi     # 0x10f0b9
movl %r14d, %edx
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
cmpq $0x1000007d, %rbx       # imm = 0x1000007D
jne 0x41684
movq %r13, %rdi
leaq 0xcdb70(%rip), %rsi     # 0x10f0d9
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%r13), %rdi
movq %rbp, %rsi
callq 0xe3fa3
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq 0x2(%rbp), %rsi
callq 0xe3fa3
movq %r13, %rdi
leaq 0xcdb4b(%rip), %rsi     # 0x10f0ef
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
leaq 0x12(%rbp), %rdx
movq %r13, %rdi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x41cd5
movq 0x8(%rbx), %r15
leaq (%r15,%rbp), %rsi
addq $0x12, %rsi
movq 0x18(%r13), %rdi
callq 0xe3fa3
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq (%r15,%rbp), %rsi
addq $0x14, %rsi
callq 0xe3fa3
movq %r13, %rdi
leaq 0xcdb1b(%rip), %rsi     # 0x10f111
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r13), %rdi
leaq (%r15,%rbp), %rsi
addq $0x16, %rsi
callq 0xe409f
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq (%r15,%rbp), %rsi
addq $0x1a, %rsi
callq 0xe409f
movq %r13, %rdi
leaq 0xcdaf7(%rip), %rsi     # 0x10f127
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r13), %rdi
leaq (%r15,%rbp), %rsi
addq $0x1e, %rsi
callq 0xe409f
movq %rax, %rbx
movq 0x18(%r13), %rdi
leaq (%r15,%rbp), %rsi
addq $0x22, %rsi
pushq $-0x1
popq %r15
callq 0xe409f
movq %r13, %rdi
leaq 0xcdad1(%rip), %rsi     # 0x10f13f
movl %ebx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
movl %r15d, %esi
callq 0xdeba7
movq %r13, %rdi
movl %r15d, %esi
callq 0xdeba7
incq %r14
addq $0x8, %r12
jmp 0x41504
pushq $-0x1
popq %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0xdeba7
movq 0x8(%rsp), %r13
jmp 0x41ad9
leaq 0xcd977(%rip), %rsi     # 0x10f033
movq %r15, %rdi
callq 0xe07f7
leaq 0xead23(%rip), %rsi     # 0x12c3ee
movq %r15, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %r14
movq %r15, %rdi
movl %r14d, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
pushq $0x10
popq %rsi
callq 0xe409f
movq %rax, %rbx
leaq 0xed887(%rip), %rsi     # 0x12ef83
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
leaq 0xea1dc(%rip), %rsi     # 0x12b8f9
movq %r15, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movl %r14d, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
movq %rbx, %rsi
callq 0xe3eb4
movzbl %al, %r14d
leaq 0xcdc2a(%rip), %rsi     # 0x10f376
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0xde896
leaq (%r14,%r14,2), %r14
leaq (%rbx,%r14), %rsi
incq %rsi
movq 0x18(%r15), %rdi
callq 0xe3eb4
movzbl %al, %edx
leaq 0xcdc19(%rip), %rsi     # 0x10f390
movq %r15, %rdi
movq %rdx, 0x28(%rsp)
xorl %eax, %eax
callq 0xde896
leaq (%rbx,%r14), %rsi
addq $0x2, %rsi
movq 0x18(%r15), %rdi
callq 0xe409f
movq %rax, %r14
leaq 0xcdc03(%rip), %rsi     # 0x10f3a4
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
xorl %r13d, %r13d
xorl %ebx, %ebx
movq $0x0, (%rsp)
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
cmpq 0x28(%rsp), %r13
jge 0x41aae
movq %r13, %r12
testq %rbx, %rbx
movq 0x8(%rsp), %r13
je 0x417e8
movq %r15, %rdi
movq %rbx, %rsi
callq 0x423b6
movq (%rsp), %rsi
testq %rsi, %rsi
je 0x417f9
movq %r15, %rdi
callq 0x423b6
movq %r12, %rax
cqto
pushq $0x2
popq %rcx
idivq %rcx
movq %r15, %rdi
leaq 0xcdbb2(%rip), %rsi     # 0x10f3c0
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
pushq $0x1
popq %rbx
movl %ebx, %esi
callq 0xdeba7
movq %r15, %rdi
leaq 0xcdb9c(%rip), %rsi     # 0x10f3ca
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movl %ebx, %esi
callq 0xdeba7
movl $0x440, %esi            # imm = 0x440
movq %r15, %rdi
callq 0xdecaf
movq %rax, %rbx
andl $0x0, 0x20(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x41d38
movq 0x38(%rbx), %rax
testq %rax, %rax
jle 0x41ab5
movq %rbx, 0x10(%rsp)
addq %r14, %rax
leaq 0x1(%r12), %rbx
movq %r15, %rdi
movq %rax, %r14
movl %ebp, %esi
callq 0xdeba7
cmpq 0x28(%rsp), %rbx
jge 0x41a15
movq %r15, %rdi
leaq 0xcdb40(%rip), %rsi     # 0x10f3e3
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movl $0x440, %esi            # imm = 0x440
movq %r15, %rdi
callq 0xdecaf
movq %rax, %rbx
movl $0x1, 0x20(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x41d38
movq %rbx, (%rsp)
movq 0x38(%rbx), %rax
testq %rax, %rax
jle 0x41aba
addq %rax, %r14
movq %r14, 0x20(%rsp)
addq $0x2, %r12
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rbp
testq %rbp, %rbp
je 0x41a48
movq (%rsp), %rax
movq 0x30(%rax), %r13
testq %r13, %r13
je 0x41a50
movq %r12, 0x30(%rsp)
movq 0x18(%rbp), %rsi
movq 0x8(%rbp), %rdx
movq 0x10(%rbp), %rcx
xorl %eax, %eax
cmpl $0x3, 0x24(%rbp)
setge %al
leal 0x2(,%rax,2), %r8d
movq %r15, %rdi
callq 0xe746f
movq %rax, %r14
xorl %r12d, %r12d
cmpq 0x10(%r14), %r12
jge 0x41a39
xorl %ebx, %ebx
cmpq 0x8(%r14), %rbx
jge 0x41a0d
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xe735f
movl %eax, %r15d
movl $0xff000000, %eax       # imm = 0xFF000000
cmpq 0x18(%rbp), %rbx
jge 0x419ea
xorl %eax, %eax
cmpq 0x18(%r13), %rbx
jge 0x419ea
cmpq 0x10(%r13), %r12
jge 0x419ea
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xe735f
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 0xe1d3e
movq (%rsp), %rcx
cmpq $0x0, 0x10(%rcx)
jne 0x419e2
cmpq $0x8, 0x18(%rcx)
sete %cl
negb %cl
xorb %cl, %al
notb %al
movzbl %al, %eax
shll $0x18, %eax
andl $0xffffff, %r15d        # imm = 0xFFFFFF
orl %eax, %r15d
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl %r15d, %ecx
callq 0xe728c
incq %rbx
jmp 0x41966
incq %r12
jmp 0x4195a
movq %r14, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rbp
movl $0x0, %eax
movq %rax, (%rsp)
movl $0x0, %r14d
testq %rbp, %rbp
jne 0x41a56
jmp 0x41a62
movq 0x30(%rsp), %rbx
movq %r14, %rbp
movq 0x18(%rsp), %r15
jmp 0x41a56
movq %r12, %rbx
xorl %r14d, %r14d
jmp 0x41a62
movq %r12, %rbx
xorl %r14d, %r14d
movq %rbp, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe70b7
movq %r14, %rdi
callq 0xe7084
movq %rbx, %r13
movq 0x20(%rsp), %r14
pushq $-0x1
popq %rbp
movq 0x10(%rsp), %rbx
jmp 0x417bb
leaq 0xcd59b(%rip), %rsi     # 0x10f021
movq %r15, %rdi
callq 0xe07f7
movq %r15, %rdi
movq %r13, %rsi
callq 0x41b94
jmp 0x41ad9
leaq 0xcd59a(%rip), %rsi     # 0x10f03c
movq %r15, %rdi
xorl %eax, %eax
callq 0xdf5b8
jmp 0x41ad9
movq 0x8(%rsp), %r13
jmp 0x41abf
xorl %r14d, %r14d
jmp 0x41ac3
movq 0x10(%rsp), %rbx
movq (%rsp), %r14
movq %r15, %rdi
movq %rbx, %rsi
callq 0x423b6
movq %r15, %rdi
movq %r14, %rsi
callq 0x423b6
movq %r15, %rdi
movq %r13, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xded32