// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x58
popq %rsi
callq 0xdecaf
movq %rax, %r14
movb $0x1, 0x4(%rax)
pushq $0x44
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xdfcf4
testl %eax, %eax
je 0x89080
movb $0x0, 0x4(%r14)
pushq $0x11
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r14)
pushq $0x28
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
movq %rbx, %rdi
callq 0xf07cc
movq %rax, %r13
movq %rsp, %rsi
andq $0x0, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe3f2a
movb %al, 0x5(%r14)
movzbl %al, %edx
leaq 0x9857b(%rip), %rsi     # 0x121642
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x5(%r14)
movq %r15, 0x18(%rsp)
je 0x890f3
leaq 0x98573(%rip), %rsi     # 0x121657
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
jmp 0x895b1
movq 0x18(%rbx), %rdi
pushq $0x7a
popq %rsi
callq 0xe3eb4
movb %al, 0x6(%r14)
movzbl %al, %edx
leaq 0x98568(%rip), %rsi     # 0x121675
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movb 0x6(%r14), %al
leal 0x7f(%rax), %ecx
cmpb $0x1, %cl
ja 0x8912d
movl $0x1, 0x8(%r14)
jmp 0x89131
cmpb $-0x7f, %al
jb 0x89155
movq 0x18(%rbx), %rdi
pushq $0x7b
popq %rsi
callq 0xe3eb4
movb %al, 0x7(%r14)
movzbl %al, %edx
leaq 0x9853f(%rip), %rsi     # 0x12168a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xe3f2a
leal -0x1(%rax), %ecx
movzbl %al, %edx
cmpb $0x3e, %cl
movq %r12, 0x10(%rsp)
ja 0x891ab
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movl (%r14), %r9d
pushq $0x1
popq %r8
movq %rdx, %rcx
callq 0xe495c
movq %rax, 0x30(%r14)
movq 0x18(%rax), %rdi
callq 0xeb7e4
leaq 0xa58c2(%rip), %rsi     # 0x12ea5e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
jmp 0x891bc
leaq 0x984f9(%rip), %rsi     # 0x1216ab
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
addq $0x3f, (%rsp)
leaq 0x98506(%rip), %rsi     # 0x1216ce
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
leaq 0x98(%rsp), %rdx
pushq $0x4
popq %rbp
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0xe657c
leaq 0xa8(%rsp), %r15
leaq 0x8bb51(%rip), %rsi     # 0x114d5a
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
movl -0x10(%r15), %eax
movl %eax, 0x90(%r13)
movb $0x1, %r12b
movb %r12b, 0x7b(%r13)
movq (%rsp), %rsi
addq $0x4, %rsi
movq %rsi, (%rsp)
movq 0x18(%rbx), %rdi
leaq 0x68(%rsp), %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0xe657c
leaq 0x78(%rsp), %r15
leaq 0x9ddc0(%rip), %rsi     # 0x127013
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
movl -0x10(%r15), %eax
movl %eax, 0x94(%r13)
movb %r12b, 0x7c(%r13)
addq $0x4, (%rsp)
movb %r12b, 0x7d(%r13)
cmpl $0x0, 0x8(%r14)
movq 0x18(%rbx), %rdi
je 0x892b1
movq %rsp, %r15
movq %r15, %rsi
callq 0xe3f2a
movzbl %al, %ebp
leaq 0x98443(%rip), %rsi     # 0x1216db
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
incq (%r15)
shll $0x8, %ebp
movw %bp, 0x7e(%r13)
jmp 0x892d2
movq %rsp, %rsi
callq 0xe3f6e
movw %ax, 0x7e(%r13)
movzwl %ax, %edx
leaq 0x7e5f7(%rip), %rsi     # 0x1078bf
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rsp, %rbp
movq %rbp, %rsi
callq 0xe4026
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe4026
leaq 0x98407(%rip), %rsi     # 0x1216fe
movq %rbx, %rdi
movl %eax, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3f6e
leaq 0x983ff(%rip), %rsi     # 0x121718
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3f2a
movzbl %al, %edx
leaq 0x983e7(%rip), %rsi     # 0x12172d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
incq (%rbp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe4071
movq %rax, 0x20(%r14)
leaq 0x983d4(%rip), %rsi     # 0x12173f
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe4071
movq %rax, 0x28(%r14)
leaq 0x983c3(%rip), %rsi     # 0x121751
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe4071
movq %rax, %rbp
leaq 0x38(%r14), %r15
testq %rax, %rax
movq 0x10(%rsp), %r12
je 0x893db
movq %rbp, %rdi
movq %r15, %rsi
callq 0xe0102
movb $0x2, 0x39(%r14)
leaq 0x20(%rsp), %rsi
pushq $0x40
popq %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xe0644
jmp 0x893f3
movb $0x0, (%r15)
leaq 0x7c096(%rip), %rsi     # 0x10547c
leaq 0x20(%rsp), %rdi
pushq $0x40
popq %rdx
callq 0xde492
leaq 0x9836d(%rip), %rsi     # 0x121767
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xe4071
movq %rax, %rbp
leaq 0x48(%r14), %r15
testq %rax, %rax
je 0x89448
movq %rbp, %rdi
movq %r15, %rsi
callq 0xe0102
movb $0x2, 0x49(%r14)
leaq 0x20(%rsp), %rsi
pushq $0x40
popq %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xe0644
jmp 0x89460
movb $0x0, (%r15)
leaq 0x7c029(%rip), %rsi     # 0x10547c
leaq 0x20(%rsp), %rdi
pushq $0x40
popq %rdx
callq 0xde492
leaq 0x98316(%rip), %rsi     # 0x12177d
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
movq (%rsp), %rsi
leaq 0x2(%rsi), %rax
movq %rax, (%rsp)
cmpl $0x0, 0x8(%r14)
je 0x894e8
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0xe3eb4
movzbl %al, %ebp
leaq 0x982ee(%rip), %rsi     # 0x121790
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
orw %bp, 0x7e(%r13)
movq (%rsp), %rsi
addq $0x13, %rsi
cmpl $0x0, 0x8(%r14)
movq %rsi, (%rsp)
je 0x894ec
movq 0x18(%rbx), %rdi
callq 0xe3f46
leaq 0x982dc(%rip), %rsi     # 0x1217b2
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq (%rsp), %rsi
jmp 0x894ec
addq $0x15, %rsi
addq $0x4, %rsi
movq %rsp, %rax
movq %rsi, (%rax)
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0xe3f6e
movq %rax, %rbp
movl 0x8(%r14), %eax
movl %eax, %ecx
orl %ebp, %ecx
je 0x895b1
testl %ebp, %ebp
setne 0xf(%rsp)
testl %eax, %eax
leaq 0xae73d(%rip), %rax     # 0x137c60
leaq 0x982ca(%rip), %rdx     # 0x1217f4
cmovneq %rax, %rdx
leaq 0x9829c(%rip), %rsi     # 0x1217d1
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0xde896
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0xe0ae9
movq %rax, %r15
movq 0x18(%rbx), %rsi
pushq $0x7c
popq %rcx
movq %rax, %rdi
xorl %edx, %edx
callq 0xe0f33
movq %r15, %rdi
callq 0xe0e95
movl %eax, %r12d
movq %r15, %rdi
callq 0xe0e8d
leaq 0x98289(%rip), %rsi     # 0x121803
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
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 0x895b1
leaq 0x9827a(%rip), %rsi     # 0x121826
jmp 0x890e4
movq 0x30(%r14), %rax
testq %rax, %rax
movq 0x18(%rsp), %rbp
je 0x895fb
movq 0x18(%rax), %rdi
callq 0xeaf8a
testl %eax, %eax
je 0x895e2
movq 0x68(%r13), %rdi
movq 0x30(%r14), %rax
movq 0x18(%rax), %rsi
callq 0xead71
movb $0x1, 0x79(%r13)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x895fb
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r13, %rdi
callq 0xf0864
movq 0x20(%r13), %rax
movups 0x48(%r14), %xmm0
movups %xmm0, 0x18(%rax)
movq 0x20(%r13), %rax
movdqu 0x38(%r14), %xmm0
movdqu %xmm0, 0x28(%rax)
movq 0x20(%r14), %rax
testq %rax, %rax
jle 0x89669
movl $0x80, %ecx
movq %rcx, 0x10(%r14)
movq %rcx, 0x10(%rbp)
movq %rax, 0x18(%r13)
cmpb $0x0, 0x4(%r14)
je 0x89655
leaq 0x10(%r13), %r15
leaq 0x8(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x89a79
cmpb $0x0, 0x9(%rbp)
jne 0x89655
movb $0x1, (%r15)
movq 0x20(%r14), %rdi
movl $0x80, %esi
callq 0xdfbb6
subq $-0x80, %rax
jmp 0x8966e
movl $0x80, %eax
movq 0x28(%r14), %rcx
testq %rcx, %rcx
jle 0x896b1
movq %rax, 0x18(%r14)
movb $0x1, 0x18(%rbp)
movq %rax, 0x20(%rbp)
movq %rcx, 0x40(%r13)
cmpb $0x0, 0x4(%r14)
je 0x896cf
movq %rbp, %rdx
addq $0x18, %rdx
movq %r13, %r15
addq $0x38, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x89a79
cmpb $0x0, 0x19(%rbp)
jne 0x896b1
movb $0x1, (%r15)
cmpb $0x0, 0x4(%r14)
je 0x896cf
movq %rbp, 0x8(%r13)
leaq 0x44e(%rip), %rax       # 0x89b11
movq %rax, 0x60(%r13)
movq %r13, %rdi
callq 0xf08e8
movq %r13, %rdi
callq 0xf0812
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xded32
testq %r12, %r12
je 0x8974c
movdqu 0x10(%r14), %xmm0
movdqu 0x20(%r14), %xmm1
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movdqu %xmm0, 0x44(%r12)
movq 0x60(%r12), %rax
testq %rax, %rax
je 0x8974c
movq %r14, %rcx
addq $0x48, %rcx
movdqu (%rcx), %xmm0
movdqu %xmm0, 0x18(%rax)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8974c
movq 0x18(%rax), %rsi
cmpq $0x0, 0x10(%rsi)
jle 0x8974c
movq 0x60(%r12), %rax
movq 0x90(%rax), %rdi
testq %rdi, %rdi
je 0x8974c
callq 0xead71
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xe4b94
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq