// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/mmm.c
// Function: de_run_mmm
static void de_run_mmm(deark *c, de_module_params *mparams)
{
	struct mmm_ctx *d = NULL;
	struct de_iffctx *ictx = NULL;
	const char *s;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(struct mmm_ctx));
	d->input_encoding = de_get_input_encoding(c, mparams, DE_ENCODING_ASCII);
	d->opt_allowbad = (u8)de_get_ext_option_bool(c, "mmm:allowbad", 0);
	s = de_get_ext_option(c, "mmm:palid");
	if(s) {
		d->pal_id_to_use = de_atoi(s);
		d->force_pal = 1;
	}

	d->tmp_namestr = ucstring_create(c);

	d->pal1[0] = DE_STOCKCOLOR_BLACK;
	d->pal1[1] = DE_STOCKCOLOR_WHITE;

	if(!read_alt_palette_file(c, d)) goto done;

	ictx = fmtutil_create_iff_decoder(c);
	setup_ictx_for_mmm(c, d, ictx);
	ictx->f = c->infile;

	d->pass = 1;
	de_dbg(c, "pass %d", d->pass);
	de_dbg_indent(c, 1);
	fmtutil_read_iff_format(ictx, 0, c->infile->len);
	de_dbg_indent(c, -1);
	if(d->errflag) goto done;

	if(d->force_pal && !d->have_pal && !d->opt_allowbad) {
		de_err(c, "Palette %d not found", d->pal_id_to_use);
		goto done;
	}

	if(d->clut_count>1 && d->dib_count>0 && !d->opt_allowbad && !d->force_pal) {
		de_err(c, "Multiple palettes found (not supported, "
			"or try \"-opt mmm:palid=...\").");
		mmm_allowbad_note(c);
		d->suppress_dib_pass2 = 1;
	}

	d->pass = 2;
	de_dbg(c, "pass %d", d->pass);
	de_dbg_indent(c, 1);
	fmtutil_read_iff_format(ictx, 0, c->infile->len);
	de_dbg_indent(c, -1);

done:
	fmtutil_destroy_iff_decoder(ictx);
	if(d) {
		de_dbg(c, "dib count: %d", d->dib_count);
		de_dbg(c, "clut count: %d", d->clut_count);
		ucstring_destroy(d->tmp_namestr);
		de_free(c, d);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movl $0x438, %esi            # imm = 0x438
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r14
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xeb220
movl %eax, 0xc(%r14)
leaq 0x99a23(%rip), %rsi     # 0x13072a
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9bd0
movb %al, 0x4(%r14)
leaq 0x99a1b(%rip), %rsi     # 0x130737
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x96d3a
movq %rax, %rdi
callq 0xe9c2a
movl %eax, 0x8(%r14)
movb $0x1, 0x6(%r14)
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x28(%r14)
movq $-0x1000000, 0x30(%r14) # imm = 0xFF000000
leaq 0x79827(%rip), %rsi     # 0x11057c
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x96e2d
movb $0x1, 0x5(%r14)
movq %rbx, %rdi
movq %rax, %rsi
callq 0xf1114
movb $0x1, %r13b
testq %rax, %rax
je 0x96e38
movq %rax, %r15
movq %rbx, %rdi
callq 0x1075c0
movq %rax, %r12
movq %r14, 0x10(%rax)
movl $0x1, 0x58(%rax)
leaq 0x2fc(%rip), %rax       # 0x9709e
movq %rax, 0x20(%r12)
leaq 0x708(%rip), %rax       # 0x974b6
movq %rax, 0x40(%r12)
leaq 0x780(%rip), %rax       # 0x9753a
movq %rax, 0x28(%r12)
movq %r15, 0x18(%r12)
movl $0x64, (%r14)
leaq 0x999e7(%rip), %rsi     # 0x1307b9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r15), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x1075e4
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpb $0x0, 0x20(%r14)
jne 0x96e33
cmpb $0x0, 0x6(%r14)
je 0x96ff7
movl 0x8(%r14), %edx
leaq 0x99920(%rip), %rsi     # 0x130741
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x96e3e
xorl %r12d, %r12d
xorl %r15d, %r15d
xorl %r13d, %r13d
jmp 0x96e3e
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %r12, %rdi
callq 0x1075d3
movq %r15, %rdi
callq 0xf052b
movb $0x0, 0x10(%r14)
movq $0x0, 0x14(%r14)
testb %r13b, %r13b
je 0x96e68
xorl %r15d, %r15d
jmp 0x96f97
movq %rbx, %rdi
callq 0x1075c0
movq %rax, %r15
movq %r14, 0x10(%rax)
movl $0x1, %eax
movl %eax, 0x58(%r15)
leaq 0x217(%rip), %rcx       # 0x9709e
movq %rcx, 0x20(%r15)
leaq 0x624(%rip), %rcx       # 0x974b6
movq %rcx, 0x40(%r15)
leaq 0x69d(%rip), %rcx       # 0x9753a
movq %rcx, 0x28(%r15)
movq 0x18(%rbx), %rcx
movq %rcx, 0x18(%r15)
movl %eax, (%r14)
leaq 0x8a184(%rip), %rsi     # 0x121037
movq %rbx, %rdi
movl $0x1, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1075e4
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
cmpb $0x0, 0x10(%r14)
jne 0x96f97
movb 0x6(%r14), %al
testb %al, %al
je 0x96f13
cmpb $0x0, 0x20(%r14)
jne 0x96f13
cmpb $0x0, 0x4(%r14)
je 0x9700d
cmpl $0x2, 0x14(%r14)
jl 0x96f4e
cmpl $0x0, 0x18(%r14)
jle 0x96f4e
orb 0x4(%r14), %al
jne 0x96f4e
leaq 0x99828(%rip), %rsi     # 0x130756
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
leaq 0x99ab4(%rip), %rsi     # 0x1309f3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9393
movb $0x1, 0x11(%r14)
movl $0x2, (%r14)
leaq 0x8a0db(%rip), %rsi     # 0x121037
movq %rbx, %rdi
movl $0x2, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x1075e4
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r15, %rdi
callq 0x1075d3
movl 0x18(%r14), %edx
leaq 0x997f2(%rip), %rsi     # 0x13079c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl 0x14(%r14), %edx
leaq 0x997eb(%rip), %rsi     # 0x1307aa
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x28(%r14), %rdi
callq 0xf6753
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x997d0(%rip), %rsi     # 0x1307ce
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x96e3e
movl 0x8(%r14), %edx
leaq 0x99729(%rip), %rsi     # 0x130741
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x96f97