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

	d = de_malloc(c, sizeof(lctx));

	d->extract_files = 1;
	if(de_havemodcode(c, mparams, 'D')) {
		d->extract_files = 0;
	}

	// TODO: Since this module can be used as a submodule, we really should
	// coordinate the 'encoding' setting with the parent module
	// (using mparams->in_params.input_encoding).
	// But as long as the only possible parent is macpaint, it's not needed,
	// and maybe more trouble than it's worth.
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_MACROMAN);

	run_macbinary_internal(c, d);

	if(mparams) {
		mparams->out_params.uint1 = (u32)d->dfpos;
		mparams->out_params.uint2 = (u32)d->dflen;
		mparams->out_params.uint3 = (u32)d->rfpos;
		mparams->out_params.uint4 = (u32)d->rflen;

		if(mparams->out_params.fi) {
			// If caller created out_params.fi for us, save the mod time to it.
			mparams->out_params.fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = d->mod_time;

			// If caller created .fi->name_other, copy the filename to it.
			if(d->filename_srd && d->filename_srd->str->len>0 && mparams->out_params.fi->name_other) {
				ucstring_append_ucstring(mparams->out_params.fi->name_other, d->filename_srd->str);
			}
		}
	}

	if(d) {
		de_destroy_stringreaderdata(c, d->filename_srd);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r12
movq %rdi, %rbx
movl $0x58, %esi
callq 0xe969b
movq %rax, %r14
movb $0x1, 0x4(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x44, %edx
callq 0xea97e
testl %eax, %eax
je 0x8ec48
movb $0x0, 0x4(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x11, %edx
callq 0xeb7d1
movl %eax, (%r14)
movl $0x28, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %rbp
movq %rbx, %rdi
callq 0xfca54
movq %rax, %r13
movq %rsp, %rsi
movq $0x0, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xef14d
movb %al, 0x5(%r14)
movzbl %al, %edx
leaq 0x9f924(%rip), %rsi     # 0x12e5ba
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x5(%r14)
je 0x8ecbd
leaq 0x9f921(%rip), %rsi     # 0x12e5cf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0x8f18e
movq 0x18(%rbx), %rdi
movl $0x7a, %esi
callq 0xef0d5
movb %al, 0x6(%r14)
movzbl %al, %edx
leaq 0x9f914(%rip), %rsi     # 0x12e5ed
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movb 0x6(%r14), %al
leal 0x7f(%rax), %ecx
cmpb $0x1, %cl
ja 0x8ecf7
movl $0x1, 0x8(%r14)
cmpb $-0x7f, %al
jb 0x8ed21
movq 0x18(%rbx), %rdi
movl $0x7b, %esi
callq 0xef0d5
movb %al, 0x7(%r14)
movzbl %al, %edx
leaq 0x9f8eb(%rip), %rsi     # 0x12e602
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xef14d
leal -0x1(%rax), %ecx
movzbl %al, %edx
cmpb $0x3e, %cl
movq %rbp, 0x18(%rsp)
ja 0x8ed79
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movl (%r14), %r9d
movq %rdx, %rcx
movl $0x1, %r8d
callq 0xefe67
movq %rax, 0x30(%r14)
movq 0x18(%rax), %rdi
callq 0xf74bd
leaq 0xacc6a(%rip), %rsi     # 0x13b9d4
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
jmp 0x8ed8a
leaq 0x9f8a3(%rip), %rsi     # 0x12e623
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
addq $0x3f, (%rsp)
leaq 0x9f8b0(%rip), %rsi     # 0x12e646
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
leaq 0x98(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
leaq 0xa8(%rsp), %r15
leaq 0x92f61(%rip), %rsi     # 0x121d3a
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movl -0x10(%r15), %eax
movl %eax, 0x90(%r13)
movb $0x1, %bpl
movb %bpl, 0x7b(%r13)
movq (%rsp), %rsi
addq $0x4, %rsi
movq %rsi, (%rsp)
movq 0x18(%rbx), %rdi
leaq 0x68(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1d74
leaq 0x78(%rsp), %r15
leaq 0xa50cd(%rip), %rsi     # 0x133ef3
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movl -0x10(%r15), %eax
movl %eax, 0x94(%r13)
movb %bpl, 0x7c(%r13)
addq $0x4, (%rsp)
movb %bpl, 0x7d(%r13)
cmpl $0x0, 0x8(%r14)
movq 0x18(%rbx), %rdi
je 0x8ee84
movq %rsp, %r15
movq %r15, %rsi
callq 0xef14d
movzbl %al, %ebp
leaq 0x9f7e8(%rip), %rsi     # 0x12e653
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
incq (%r15)
shll $0x8, %ebp
movw %bp, 0x7e(%r13)
jmp 0x8eea5
movq %rsp, %rsi
callq 0xef193
movw %ax, 0x7e(%r13)
movzwl %ax, %edx
leaq 0x859d4(%rip), %rsi     # 0x11486f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rsp, %rbp
movq %rbp, %rsi
callq 0xef295
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef295
leaq 0x9f7ac(%rip), %rsi     # 0x12e676
movq %rbx, %rdi
movl %eax, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef193
leaq 0x9f7a4(%rip), %rsi     # 0x12e690
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef14d
movzbl %al, %edx
leaq 0x9f78a(%rip), %rsi     # 0x12e6a5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
incq (%rbp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef34e
movq %rax, 0x20(%r14)
leaq 0x9f777(%rip), %rsi     # 0x12e6b7
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef34e
movq %rax, 0x28(%r14)
leaq 0x9f766(%rip), %rsi     # 0x12e6c9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef34e
movq %rax, %rbp
leaq 0x38(%r14), %r15
testq %rax, %rax
je 0x8efad
movq %rbp, %rdi
movq %r15, %rsi
callq 0xeae04
movb $0x2, 0x39(%r14)
leaq 0x20(%rsp), %rsi
movl $0x40, %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xeb4f8
jmp 0x8efc7
movb $0x0, (%r15)
leaq 0x834d4(%rip), %rsi     # 0x11248c
leaq 0x20(%rsp), %rdi
movl $0x40, %edx
callq 0xe8ded
leaq 0x9f711(%rip), %rsi     # 0x12e6df
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xef34e
movq %rax, %rbp
leaq 0x48(%r14), %r15
testq %rax, %rax
je 0x8f01e
movq %rbp, %rdi
movq %r15, %rsi
callq 0xeae04
movb $0x2, 0x49(%r14)
leaq 0x20(%rsp), %rsi
movl $0x40, %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xeb4f8
jmp 0x8f038
movb $0x0, (%r15)
leaq 0x83463(%rip), %rsi     # 0x11248c
leaq 0x20(%rsp), %rdi
movl $0x40, %edx
callq 0xe8ded
leaq 0x9f6b6(%rip), %rsi     # 0x12e6f5
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%rsp), %rsi
addq $0x2, %rsi
movq %rsi, (%rsp)
cmpl $0x0, 0x8(%r14)
je 0x8f088
movq 0x18(%rbx), %rdi
callq 0xef0d5
movzbl %al, %ebp
leaq 0x9f691(%rip), %rsi     # 0x12e708
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
orw %bp, 0x7e(%r13)
movq (%rsp), %rsi
addq $0x13, %rsi
movq %rsi, (%rsp)
cmpl $0x0, 0x8(%r14)
je 0x8f0b7
movq 0x18(%rbx), %rdi
callq 0xef169
leaq 0x9f67f(%rip), %rsi     # 0x12e72a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rsp, %rsi
addq $0x4, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xef193
movq %rax, %rbp
movl 0x8(%r14), %eax
movl %eax, %ecx
orl %ebp, %ecx
je 0x8f184
testl %ebp, %ebp
setne 0xf(%rsp)
testl %eax, %eax
leaq 0xb5ae8(%rip), %rax     # 0x144bd0
leaq 0x9f67d(%rip), %rdx     # 0x12e76c
cmovneq %rax, %rdx
leaq 0x9f64f(%rip), %rsi     # 0x12e749
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x20, %esi
callq 0xeba56
movq %rax, %r15
movq 0x18(%rbx), %rsi
movl $0x7c, %ecx
movq %rax, %rdi
xorl %edx, %edx
callq 0xebf09
movq %r15, %rdi
callq 0xebe2a
movq %r12, 0x10(%rsp)
movl %eax, %r12d
movq %r15, %rdi
callq 0xebe1d
leaq 0x9f633(%rip), %rsi     # 0x12e77b
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x0, 0x8(%r14)
setne %al
cmpl %ebp, %r12d
movq 0x10(%rsp), %r12
setne %cl
andb 0xf(%rsp), %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x8f184
leaq 0x9f624(%rip), %rsi     # 0x12e79e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
addq $0x2, (%rsp)
movq 0x18(%rsp), %rbp
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8f1ba
movq 0x18(%rax), %rdi
callq 0xf6c00
testl %eax, %eax
je 0x8f1ba
movq 0x68(%r13), %rdi
movq 0x30(%r14), %rax
movq 0x18(%rax), %rsi
callq 0xf6969
movb $0x1, 0x79(%r13)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8f1d3
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r13, %rdi
callq 0xfcaec
movq 0x20(%r13), %rax
movups 0x48(%r14), %xmm0
movups %xmm0, 0x18(%rax)
movq 0x20(%r13), %rax
movups 0x38(%r14), %xmm0
movups %xmm0, 0x28(%rax)
movq 0x20(%r14), %rax
testq %rax, %rax
jle 0x8f23f
movl $0x80, %ecx
movq %rcx, 0x10(%r14)
movq %rcx, 0x10(%rbp)
movq %rax, 0x18(%r13)
cmpb $0x0, 0x4(%r14)
je 0x8f22b
leaq 0x10(%r13), %r15
leaq 0x8(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8f690
cmpb $0x0, 0x9(%rbp)
jne 0x8f22b
movb $0x1, (%r15)
movq 0x20(%r14), %rdi
movl $0x80, %esi
callq 0xea80b
subq $-0x80, %rax
jmp 0x8f244
movl $0x80, %eax
movq 0x28(%r14), %rcx
testq %rcx, %rcx
jle 0x8f287
movq %rax, 0x18(%r14)
movb $0x1, 0x18(%rbp)
movq %rax, 0x20(%rbp)
movq %rcx, 0x40(%r13)
cmpb $0x0, 0x4(%r14)
je 0x8f287
movq %rbp, %rdx
addq $0x18, %rdx
movq %r13, %r15
addq $0x38, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8f690
cmpb $0x0, 0x19(%rbp)
jne 0x8f287
movb $0x1, (%r15)
cmpb $0x0, 0x4(%r14)
je 0x8f2a5
movq %rbp, 0x8(%r13)
leaq 0x48f(%rip), %rax       # 0x8f728
movq %rax, 0x60(%r13)
movq %r13, %rdi
callq 0xfcb73
movq %r13, %rdi
callq 0xfca9a
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe9752
testq %r12, %r12
je 0x8f323
movl 0x10(%r14), %eax
movl %eax, 0x44(%r12)
movl 0x20(%r14), %eax
movl %eax, 0x48(%r12)
movl 0x18(%r14), %eax
movl %eax, 0x4c(%r12)
movl 0x28(%r14), %eax
movl %eax, 0x50(%r12)
movq 0x60(%r12), %rax
testq %rax, %rax
je 0x8f323
movq %r14, %rcx
addq $0x48, %rcx
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rax)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8f323
movq 0x18(%rax), %rsi
cmpq $0x0, 0x10(%rsi)
jle 0x8f323
movq 0x60(%r12), %rax
movq 0x90(%rax), %rdi
testq %rdi, %rdi
je 0x8f323
callq 0xf6969
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xf00aa
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq