// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pcx.c
// Function: de_run_pcx_internal
static void de_run_pcx_internal(deark *c, lctx *d, de_module_params *mparams)
{
	const char *s;

	s = de_get_ext_option(c, "pcx:pal");
	if(s) {
		d->default_pal_num = de_atoi(s);
		if(d->default_pal_num<0 || d->default_pal_num>1) {
			d->default_pal_num = 0;
		}
		d->default_pal_set = 1;
	}

	d->resmode = RESMODE_AUTO;
	s = de_get_ext_option(c, "pcx:resmode");
	if(s) {
		if(!de_strcmp(s, "auto")) {
			d->resmode = RESMODE_AUTO;
		}
		else if(!de_strcmp(s, "dpi")) {
			d->resmode = RESMODE_DPI;
		}
		else if(!de_strcmp(s, "screen")) {
			d->resmode = RESMODE_SCREENDIMENSIONS;
		}
	}

	d->fi = de_finfo_create(c);

	if(!do_read_header(c, d)) {
		goto done;
	}

	do_palette_stuff(c, d);

	if(d->encoding==0) {
		// Uncompressed PCXs are probably not standard, but support for them is not
		// uncommon. Imagemagick, for example, will create them if you ask it to.
		de_dbg(c, "uncompressed bitmap at %d", (int)PCX_HDRSIZE);
		d->unc_pixels = dbuf_open_input_subfile(c->infile,
			PCX_HDRSIZE, c->infile->len-PCX_HDRSIZE);
	}
	else {
		if(!do_uncompress(c, d)) {
			goto done;
		}
	}
	dbuf_flush(d->unc_pixels);

	do_bitmap(c, d);

done:
	dbuf_close(d->unc_pixels);
	d->unc_pixels = NULL;
	de_finfo_destroy(c, d->fi);
	d->fi = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xbd79e(%rip), %rsi     # 0x1c1b9d
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x10445a
movq -0x20(%rbp), %rdi
callq 0x15cca0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x9c(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x9c(%rax)
jl 0x10443e
movq -0x10(%rbp), %rax
cmpl $0x1, 0x9c(%rax)
jle 0x10444c
movq -0x10(%rbp), %rax
movl $0x0, 0x9c(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0xa0(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
movq -0x8(%rbp), %rdi
leaq 0xbd735(%rip), %rsi     # 0x1c1ba5
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1044ea
movq -0x20(%rbp), %rdi
leaq 0x980e8(%rip), %rsi     # 0x19c573
callq 0x191a0
cmpl $0x0, %eax
jne 0x1044a2
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x1044e8
movq -0x20(%rbp), %rdi
leaq 0xc8c05(%rip), %rsi     # 0x1cd0b2
callq 0x191a0
cmpl $0x0, %eax
jne 0x1044c4
movq -0x10(%rbp), %rax
movl $0x2, 0x4(%rax)
jmp 0x1044e6
movq -0x20(%rbp), %rdi
leaq 0xb797e(%rip), %rsi     # 0x1bbe4d
callq 0x191a0
cmpl $0x0, %eax
jne 0x1044e4
movq -0x10(%rbp), %rax
movl $0x3, 0x4(%rax)
jmp 0x1044e6
jmp 0x1044e8
jmp 0x1044ea
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x104600
cmpl $0x0, %eax
jne 0x104518
jmp 0x1045b1
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x104e10
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x10457e
movq -0x8(%rbp), %rdi
leaq 0xbd674(%rip), %rsi     # 0x1c1bb1
movl $0x80, %edx
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rdx
subq $0x80, %rdx
movl $0x80, %esi
callq 0x1691b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
jmp 0x104594
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x105180
cmpl $0x0, %eax
jne 0x104592
jmp 0x1045b1
jmp 0x104594
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0x167c30
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x105330
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0x1676a0
movq -0x10(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rsi
callq 0x15d260
movq -0x10(%rbp), %rax
movq $0x0, 0xb0(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)