// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %r14
movb $0x1, 0x4(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x44, %edx
callq 0xea4d9
testl %eax, %eax
je 0x8e350
movb $0x0, 0x4(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x11, %edx
callq 0xeb220
movl %eax, (%r14)
movl $0x28, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movq %rbx, %rdi
callq 0xfc498
movq %rax, %r13
movq %rsp, %rsi
movq $0x0, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeeb4b
movb %al, 0x5(%r14)
movzbl %al, %edx
leaq 0xa052c(%rip), %rsi     # 0x12e8ca
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x5(%r14)
movq %r15, 0x18(%rsp)
je 0x8e3ca
leaq 0xa0524(%rip), %rsi     # 0x12e8df
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
jmp 0x8e89c
movq 0x18(%rbx), %rdi
movl $0x7a, %esi
callq 0xeead3
movb %al, 0x6(%r14)
movzbl %al, %edx
leaq 0xa0517(%rip), %rsi     # 0x12e8fd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movb 0x6(%r14), %al
leal 0x7f(%rax), %ecx
cmpb $0x1, %cl
ja 0x8e406
movl $0x1, 0x8(%r14)
jmp 0x8e40a
cmpb $-0x7f, %al
jb 0x8e430
movq 0x18(%rbx), %rdi
movl $0x7b, %esi
callq 0xeead3
movb %al, 0x7(%r14)
movzbl %al, %edx
leaq 0xa04ec(%rip), %rsi     # 0x12e912
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeeb4b
leal -0x1(%rax), %ecx
movzbl %al, %edx
cmpb $0x3e, %cl
ja 0x8e483
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
movl (%r14), %r9d
movq %rdx, %rcx
movl $0x1, %r8d
callq 0xef87c
movq %rax, 0x30(%r14)
movq 0x18(%rax), %rdi
callq 0xf705c
leaq 0xad8da(%rip), %rsi     # 0x13bd4e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
jmp 0x8e494
leaq 0xa04a9(%rip), %rsi     # 0x12e933
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
addq $0x3f, (%rsp)
leaq 0xa04b6(%rip), %rsi     # 0x12e956
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq (%rsp), %rsi
leaq 0x98(%rsp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0xf1762
leaq 0xa8(%rsp), %r15
leaq 0x93967(%rip), %rsi     # 0x121e4a
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
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 0xf1762
leaq 0x78(%rsp), %r15
leaq 0xa5dbb(%rip), %rsi     # 0x1342eb
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0xe8617
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 0x8e58e
movq %rsp, %r15
movq %r15, %rsi
callq 0xeeb4b
movzbl %al, %ebp
leaq 0xa03ee(%rip), %rsi     # 0x12e963
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
incq (%r15)
shll $0x8, %ebp
movw %bp, 0x7e(%r13)
jmp 0x8e5af
movq %rsp, %rsi
callq 0xeeb91
movw %ax, 0x7e(%r13)
movzwl %ax, %edx
leaq 0x863a5(%rip), %rsi     # 0x11494a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rsp, %rbp
movq %rbp, %rsi
callq 0xeec86
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeec86
leaq 0xa03b2(%rip), %rsi     # 0x12e986
movq %rbx, %rdi
movl %eax, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb91
leaq 0xa03aa(%rip), %rsi     # 0x12e9a0
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeeb4b
movzbl %al, %edx
leaq 0xa0390(%rip), %rsi     # 0x12e9b5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
incq (%rbp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movq %rax, 0x20(%r14)
leaq 0xa037d(%rip), %rsi     # 0x12e9c7
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movq %rax, 0x28(%r14)
leaq 0xa036c(%rip), %rsi     # 0x12e9d9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xeed31
movq %rax, %rbp
leaq 0x38(%r14), %r15
testq %rax, %rax
je 0x8e6b7
movq %rbp, %rdi
movq %r15, %rsi
callq 0xea8ff
movb $0x2, 0x39(%r14)
leaq 0x20(%rsp), %rsi
movl $0x40, %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xeaf46
jmp 0x8e6d1
movb $0x0, (%r15)
leaq 0x83dda(%rip), %rsi     # 0x11249c
leaq 0x20(%rsp), %rdi
movl $0x40, %edx
callq 0xe8219
leaq 0xa0317(%rip), %rsi     # 0x12e9ef
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xeed31
movq %rax, %rbp
leaq 0x48(%r14), %r15
testq %rax, %rax
je 0x8e728
movq %rbp, %rdi
movq %r15, %rsi
callq 0xea8ff
movb $0x2, 0x49(%r14)
leaq 0x20(%rsp), %rsi
movl $0x40, %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xeaf46
jmp 0x8e742
movb $0x0, (%r15)
leaq 0x83d69(%rip), %rsi     # 0x11249c
leaq 0x20(%rsp), %rdi
movl $0x40, %edx
callq 0xe8219
leaq 0xa02bc(%rip), %rsi     # 0x12ea05
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe8617
movq (%rsp), %rsi
leaq 0x2(%rsi), %rax
movq %rax, (%rsp)
cmpl $0x0, 0x8(%r14)
je 0x8e7ca
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0xeead3
movzbl %al, %ebp
leaq 0xa0294(%rip), %rsi     # 0x12ea18
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
orw %bp, 0x7e(%r13)
movq (%rsp), %rsi
addq $0x13, %rsi
cmpl $0x0, 0x8(%r14)
movq %rsi, (%rsp)
je 0x8e7ce
movq 0x18(%rbx), %rdi
callq 0xeeb67
leaq 0xa0282(%rip), %rsi     # 0x12ea3a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq (%rsp), %rsi
jmp 0x8e7ce
addq $0x15, %rsi
addq $0x4, %rsi
movq %rsp, %rax
movq %rsi, (%rax)
movq 0x18(%rbx), %rdi
movq %rax, %rsi
callq 0xeeb91
movq %rax, %rbp
movl 0x8(%r14), %eax
movl %eax, %ecx
orl %ebp, %ecx
je 0x8e89c
testl %ebp, %ebp
setne 0xf(%rsp)
testl %eax, %eax
leaq 0xb68ab(%rip), %rax     # 0x1450b0
leaq 0xa0270(%rip), %rdx     # 0x12ea7c
cmovneq %rax, %rdx
leaq 0xa0242(%rip), %rsi     # 0x12ea59
movq %rbx, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x20, %esi
callq 0xeb499
movq %rax, %r15
movq 0x18(%rbx), %rsi
movl $0x7c, %ecx
movq %rax, %rdi
xorl %edx, %edx
callq 0xeb944
movq %r15, %rdi
callq 0xeb865
movq %r12, 0x10(%rsp)
movl %eax, %r12d
movq %r15, %rdi
callq 0xeb858
leaq 0xa0226(%rip), %rsi     # 0x12ea8b
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe8617
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 0x8e89c
leaq 0xa0217(%rip), %rsi     # 0x12eaae
jmp 0x8e3bb
movq 0x30(%r14), %rax
testq %rax, %rax
movq 0x18(%rsp), %rbp
je 0x8e8e6
movq 0x18(%rax), %rdi
callq 0xf67a3
testl %eax, %eax
je 0x8e8cd
movq 0x68(%r13), %rdi
movq 0x30(%r14), %rax
movq 0x18(%rax), %rsi
callq 0xf6509
movb $0x1, 0x79(%r13)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8e8e6
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r13, %rdi
callq 0xfc530
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 0x8e954
movl $0x80, %ecx
movq %rcx, 0x10(%r14)
movq %rcx, 0x10(%rbp)
movq %rax, 0x18(%r13)
cmpb $0x0, 0x4(%r14)
je 0x8e940
leaq 0x10(%r13), %r15
leaq 0x8(%rbp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8ed6e
cmpb $0x0, 0x9(%rbp)
jne 0x8e940
movb $0x1, (%r15)
movq 0x20(%r14), %rdi
movl $0x80, %esi
callq 0xe9cb4
subq $-0x80, %rax
jmp 0x8e959
movl $0x80, %eax
movq 0x28(%r14), %rcx
testq %rcx, %rcx
jle 0x8e99c
movq %rax, 0x18(%r14)
movb $0x1, 0x18(%rbp)
movq %rax, 0x20(%rbp)
movq %rcx, 0x40(%r13)
cmpb $0x0, 0x4(%r14)
je 0x8e9ba
movq %rbp, %rdx
addq $0x18, %rdx
movq %r13, %r15
addq $0x38, %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8ed6e
cmpb $0x0, 0x19(%rbp)
jne 0x8e99c
movb $0x1, (%r15)
cmpb $0x0, 0x4(%r14)
je 0x8e9ba
movq %rbp, 0x8(%r13)
leaq 0x458(%rip), %rax       # 0x8ee06
movq %rax, 0x60(%r13)
movq %r13, %rdi
callq 0xfc5b7
movq %r13, %rdi
callq 0xfc4de
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xe8be2
testq %r12, %r12
je 0x8ea37
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 0x8ea37
movq %r14, %rcx
addq $0x48, %rcx
movdqu (%rcx), %xmm0
movdqu %xmm0, 0x18(%rax)
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x8ea37
movq 0x18(%rax), %rsi
cmpq $0x0, 0x10(%rsi)
jle 0x8ea37
movq 0x60(%r12), %rax
movq 0x90(%rax), %rdi
testq %rdi, %rdi
je 0x8ea37
callq 0xf6509
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xefaca
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq