// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x58, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb $0x1, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x44, %edx
callq 0x15d1d0
cmpl $0x0, %eax
je 0xd0ff1
movq -0x18(%rbp), %rax
movb $0x0, 0x4(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x11, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xd15c0
cmpq $0x0, -0x10(%rbp)
je 0xd10e2
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4c(%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0xd10e0
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x48(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x50(%rcx), %rcx
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xd10de
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x10(%rax)
jle 0xd10de
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
cmpq $0x0, 0x90(%rax)
je 0xd10de
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x90(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq 0x18(%rax), %rsi
callq 0x171460
jmp 0xd10e0
jmp 0xd10e2
cmpq $0x0, -0x18(%rbp)
je 0xd1107
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x166830
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)