// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0x438, %esi            # imm = 0x438
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rdi
leaq 0xde2e5(%rip), %rsi     # 0x1bc1da
xorl %edx, %edx
callq 0x15cbc0
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x8(%rbp), %rdi
leaq 0xde2d7(%rip), %rsi     # 0x1bc1e7
callq 0x15cb30
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xddf3a
movq -0x28(%rbp), %rdi
callq 0x15cca0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x6(%rax)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movl $0xff000000, 0x30(%rax) # imm = 0xFF000000
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x34(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xde210
cmpl $0x0, %eax
jne 0xddf7b
jmp 0xde0f0
movq -0x8(%rbp), %rdi
callq 0x18c8b0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xde380
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %edx
leaq 0xceb7c(%rip), %rsi     # 0x1acb40
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x18c920
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x18(%rbp), %rax
cmpb $0x0, 0x10(%rax)
je 0xde00f
jmp 0xde0f0
movq -0x18(%rbp), %rax
movzbl 0x6(%rax), %eax
cmpl $0x0, %eax
je 0xde04e
movq -0x18(%rbp), %rax
cmpb $0x0, 0x20(%rax)
jne 0xde04e
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
jne 0xde04e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0xde1af(%rip), %rsi     # 0x1bc1f1
movb $0x0, %al
callq 0x15bfb0
jmp 0xde0f0
movq -0x18(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jle 0xde099
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jle 0xde099
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
jne 0xde099
movq -0x18(%rbp), %rax
cmpb $0x0, 0x6(%rax)
jne 0xde099
movq -0x8(%rbp), %rdi
leaq 0xde185(%rip), %rsi     # 0x1bc206
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
callq 0xde3e0
movq -0x18(%rbp), %rax
movb $0x1, 0x11(%rax)
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %edx
leaq 0xcea8c(%rip), %rsi     # 0x1acb40
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x18c920
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rdi
callq 0x18c8f0
cmpq $0x0, -0x18(%rbp)
je 0xde14c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0xde13a(%rip), %rsi     # 0x1bc24c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x14(%rax), %edx
leaq 0xde12f(%rip), %rsi     # 0x1bc25a
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nop