LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: do_pathinfo
static void do_pathinfo(deark *c, lctx *d, zztype *zz)
{
	i64 num_records;
	i64 i;

	num_records = zz_avail(zz) / 26;
	de_dbg(c, "calculated number of records: %d", (int)num_records);
	for(i=0; i<num_records; i++) {
		zztype czz;
		i64 t;
		i64 x;
		const char *name;

		de_dbg(c, "path data record[%d] at %d", (int)i, (int)zz->pos);
		zz_init_with_len(&czz, zz, 26);
		de_dbg_indent(c, 1);

		t = psd_getu16zz(&czz);
		switch(t) {
		case 0: name="Closed subpath length"; break;
		case 1: name="Closed subpath Bezier knot, linked"; break;
		case 2: name="Closed subpath Bezier knot, unlinked"; break;
		case 3: name="Open subpath length"; break;
		case 4: name="Open subpath Bezier knot, linked"; break;
		case 5: name="Open subpath Bezier knot, unlinked"; break;
		case 6: name="Path fill rule"; break;
		case 7: name="Clipboard"; break;
		case 8: name="Initial fill rule"; break;
		default: name="?"; break;
		}
		de_dbg(c, "path record type: %d (%s)", (int)t, name);

		switch(t) {
		case 0: case 3:
			x = psd_getu16zz(&czz);
			de_dbg(c, "number of Bezier knot records: %d", (int)x);
			break;
		case 8:
			x = psd_getu16zz(&czz);
			de_dbg(c, "value: %d", (int)x);
			break;
		}

		zz->pos += 26;
		de_dbg_indent(c, -1);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
movq (%rdx), %rcx
movq 0x10(%rdx), %rax
movq %rax, %r13
subq %rcx, %r13
jle 0xa94d5
movq 0x8(%rbx), %rdx
cmpq %rdx, %rcx
jge 0xa94d8
subq %rdx, %rax
movq %rax, %r13
jmp 0xa94d8
xorl %r13d, %r13d
movabsq $0x4ec4ec4ec4ec4ec5, %rcx # imm = 0x4EC4EC4EC4EC4EC5
movq %r13, %rax
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x3, %rdx
addq %rax, %rdx
leaq 0x8a464(%rip), %rsi     # 0x133961
movq %r15, %rdi
movq %rdx, 0x10(%rsp)
xorl %eax, %eax
callq 0xe9226
cmpq $0x1a, %r13
jl 0xa95f1
xorl %r13d, %r13d
movl (%rbx), %ecx
movq %r15, %rdi
leaq 0x8a45d(%rip), %rsi     # 0x133982
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
movq (%rbx), %rbp
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r15), %rdi
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edx
movq %rbp, %rsi
callq 0xef570
movq %rax, %r12
leaq 0x8290c(%rip), %rcx     # 0x12be69
cmpq $0x8, %rax
ja 0xa9571
leaq 0x8b4da(%rip), %rax     # 0x134a44
movslq (%rax,%r12,4), %rcx
addq %rax, %rcx
movq %r15, %rdi
leaq 0x8a4f9(%rip), %rsi     # 0x133a74
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
leaq 0x8a502(%rip), %r14     # 0x133a8e
testq %r12, %r12
je 0xa95ab
leaq 0x8a4f6(%rip), %r14     # 0x133a8e
cmpq $0x3, %r12
je 0xa95ab
cmpq $0x8, %r12
jne 0xa95d2
leaq 0x814a9(%rip), %r14     # 0x12aa54
addq $0x2, %rbp
movq 0x18(%r15), %rdi
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edx
movq %rbp, %rsi
callq 0xef570
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
addq $0x1a, (%rbx)
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %r13
cmpq %r13, 0x10(%rsp)
jne 0xa9519
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: do_boolean_block
static void do_boolean_block(deark *c, lctx *d, zztype *zz,
	const struct de_fourcc *blk4cc, const char *name)
{
	u8 value;
	i64 len;

	len = zz_avail(zz);
	if(len<1 || len>4) return;
	value = psd_getbytezz(zz);
	de_dbg(c, "%s: %d", name, (int)value);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq (%rsi), %rsi
movq 0x10(%r15), %rcx
movq %rcx, %rax
subq %rsi, %rax
jle 0xab499
movq 0x8(%r15), %rdx
cmpq %rdx, %rsi
jge 0xab49b
subq %rdx, %rcx
movq %rcx, %rax
jmp 0xab49b
xorl %eax, %eax
addq $-0x5, %rax
cmpq $-0x4, %rax
jae 0xab4ab
popq %rbx
popq %r14
popq %r15
retq
movq 0x18(%r14), %rdi
callq 0xef0d5
incq (%r15)
movzbl %al, %ecx
leaq 0x93822(%rip), %rsi     # 0x13ece3
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0xe9226
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: do_descriptor_block
static void do_descriptor_block(deark *c, lctx *d, zztype *zz,
	const struct de_fourcc *blk4cc, const char *name)
{
	char dscrname[100];

	if(name[0])
		de_snprintf(dscrname, sizeof(dscrname), " (for %s)", name);
	else
		de_strlcpy(dscrname, "", sizeof(dscrname));

	read_descriptor(c, d, zz, 1, dscrname);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpb $0x0, (%rcx)
je 0xab502
leaq 0x88bdb(%rip), %rdx     # 0x1340cc
movq %rsp, %rdi
movl $0x64, %esi
xorl %eax, %eax
callq 0xe8d67
jmp 0xab516
leaq 0x996c7(%rip), %rsi     # 0x144bd0
movq %rsp, %rdi
movl $0x64, %edx
callq 0xe8ded
movq %rsp, %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0xa8173
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: do_pattern_sequence
static void do_pattern_sequence(deark *c, lctx *d, zztype *zz)
{
	i64 pattern_idx;
	zztype czz;

	pattern_idx = 0;
	while(1) {
		if(zz_avail(zz)<16) break;
		zz_init(&czz, zz);
		if(!do_pattern(c, d, &czz, pattern_idx)) {
			break;
		}
		zz->pos += zz_used(&czz);
		pattern_idx++;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
xorl %r8d, %r8d
movq %rdx, 0x18(%rsp)
movq 0x10(%rsp), %rbx
movq (%rdx), %r13
movq 0x10(%rdx), %r14
movq %r14, %rax
subq %r13, %rax
jg 0xabc65
xorl %eax, %eax
jmp 0xabc74
movq 0x8(%rdx), %rcx
cmpq %rcx, %r13
jge 0xabc74
movq %r14, %rax
subq %rcx, %rax
cmpq $0x10, %rax
jl 0xabd6e
movq %r14, %rax
subq %r13, %rax
setle %cl
cmpq $0x10, %rax
setl %r12b
orb %cl, %r12b
movq %r13, %rbp
jne 0xabd54
movq %rbx, %rdi
leaq 0x882ee(%rip), %rsi     # 0x133f93
movl %r8d, %edx
movl %r13d, %ecx
xorl %eax, %eax
movl %r8d, 0x4(%rsp)
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rax
movl 0x4(%rax), %edx
movq %r13, %rsi
callq 0xef614
movq %rax, %rbp
leaq 0x4(%r13), %r15
movq %rbx, %rdi
leaq 0x7f4cc(%rip), %rsi     # 0x12b1b5
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
testq %rbp, %rbp
movl $0x0, %eax
cmovgq %rbp, %rax
addq %r13, %rax
addq $0x4, %rax
cmpq %r14, %rax
cmovgeq %r14, %rax
movq %r15, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0xabd7d
movq %rbp, %rdi
callq 0xea7de
leaq (%rax,%r13), %rbp
addq $0x4, %rbp
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movl 0x4(%rsp), %r8d
movq 0x18(%rsp), %rdx
testb %r12b, %r12b
jne 0xabd6e
cmpq %r14, %rbp
cmovlq %rbp, %r14
subq %r13, %r14
addq %r14, (%rdx)
incl %r8d
jmp 0xabc52
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/psd.c
// Function: read_prefixed_string_to_ucstring
static void read_prefixed_string_to_ucstring(deark *c, lctx *d, de_ucstring *s, zztype *zz)
{
	i64 dlen;

	if(zz_avail(zz)<4) {
		zz->pos = zz->endpos;
		return;
	}

	dlen = psd_getu32zz(zz);

	if(zz->pos + dlen > zz->endpos) { // error
		zz->pos = zz->endpos;
		return;
	}

	dbuf_read_to_ucstring(c->infile, zz->pos, dlen, s, 0, d->input_encoding);
	zz->pos += dlen;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq (%rcx), %rsi
movq 0x10(%rcx), %rax
movq %rax, %rcx
subq %rsi, %rcx
jle 0xac5c4
movq 0x8(%rbx), %rdx
cmpq %rdx, %rsi
jge 0xac5c6
movq %rax, %rcx
subq %rdx, %rcx
jmp 0xac5c6
xorl %ecx, %ecx
cmpq $0x4, %rcx
jl 0xac614
movq 0x18(%r12), %rdi
movl 0x4(%r15), %edx
callq 0xef614
movq %rax, %r13
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
leaq 0x4(%rcx), %rsi
movq %rsi, (%rbx)
addq %r13, %rcx
addq $0x4, %rcx
cmpq %rax, %rcx
jg 0xac614
movq 0x18(%r12), %rdi
movl 0x8(%r15), %r9d
movq %r13, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0xf01b0
addq (%rbx), %r13
movq %r13, %rax
movq %rax, (%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/palmbitmap.c
// Function: de_module_palmbitmap
void de_module_palmbitmap(deark *c, struct deark_module_info *mi)
{
	mi->id = "palmbitmap";
	mi->desc = "Palm BitmapType";
	mi->run_fn = de_run_palmbitmap;
	mi->identify_fn = de_identify_palmbitmap;
	mi->help_fn = de_help_palmbitmap;
}

// Assembly:
leaq 0x884b5(%rip), %rax     # 0x134ae0
movq %rax, (%rsi)
leaq 0x884b6(%rip), %rax     # 0x134aeb
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0xac65b
movq %rax, 0x18(%rsi)
leaq 0x145d(%rip), %rax      # 0xadaa8
movq %rax, 0x20(%rsi)
leaq 0x1527(%rip), %rax      # 0xadb7d
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/palmbitmap.c
// Function: de_identify_palmbitmap
static int de_identify_palmbitmap(deark *c)
{
	if(de_input_file_has_ext(c, "palm")) {
		int x;
		x = de_identify_palmbitmap_internal(c, c->infile, 0, c->infile->len);
		if(x) return 90;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x87b1c(%rip), %rsi     # 0x1355d6
callq 0xea936
testl %eax, %eax
je 0xadaf2
movq 0x18(%rbx), %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0xef0d5
xorl %r14d, %r14d
cmpb $-0x1, %al
sete %r14b
shll $0x4, %r14d
movq 0x18(%rbx), %rdi
leaq 0x9(%r14), %rsi
callq 0xef0d5
cmpb $0x3, %al
jbe 0xadafd
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0xef169
movq %rax, %r12
movq %r14, %rsi
orq $0x2, %rsi
movq %r15, %rdi
callq 0xef169
testq %r12, %r12
je 0xadaf2
testq %rax, %rax
je 0xadaf2
movq %r14, %rsi
orq $0x4, %rsi
movq %r15, %rdi
callq 0xef169
movq %rax, %r15
movq 0x18(%rbx), %rdi
orq $0x8, %r14
movq %r14, %rsi
callq 0xef0d5
orb %al, %bpl
je 0xadb5e
cmpb $0x10, %al
ja 0xadaf2
movzbl %al, %eax
movl $0x10116, %ecx          # imm = 0x10116
btl %eax, %ecx
jae 0xadaf2
testq %r15, %r15
setne %cl
testb $0x1, %r15b
sete %dl
movl $0x5a, %eax
testb %dl, %cl
je 0xadaf2
jmp 0xadaf4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/palmpdb.c
// Function: de_module_palmdb
void de_module_palmdb(deark *c, struct deark_module_info *mi)
{
	mi->id = "palmdb";
	mi->id_alias[0] = "palmrc";
	mi->desc = "Palm OS PDB or PRC";
	mi->run_fn = de_run_pdb_or_prc;
	mi->identify_fn = de_identify_pdb_prc;
	mi->help_fn = de_help_pdb_prc;
}

// Assembly:
leaq 0x8747c(%rip), %rax     # 0x135027
movq %rax, (%rsi)
leaq 0x87479(%rip), %rax     # 0x13502e
movq %rax, 0x38(%rsi)
leaq 0x87475(%rip), %rax     # 0x135035
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0xadbe6
movq %rax, 0x18(%rsi)
leaq 0x15ba(%rip), %rax      # 0xaf190
movq %rax, 0x20(%rsi)
leaq 0x17c8(%rip), %rax      # 0xaf3a9
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/palmpdb.c
// Function: do_string_rsrc
static void do_string_rsrc(deark *c, lctx *d,
	i64 pos, i64 len,
	const struct rsrc_type_info_struct *rti, unsigned int flags)
{
	de_ucstring *s = NULL;

	if(!rti || !rti->descr) return;
	s = ucstring_create(c);
	dbuf_read_to_ucstring_n(c->infile, pos, len, DE_DBG_MAX_STRLEN, s,
		DE_CONVFLAG_STOP_AT_NUL, DE_ENCODING_PALM);
	de_dbg(c, "%s: \"%s\"", rti->descr, ucstring_getpsz(s));

	if((flags&0x1) & !d->icon_name) {
		// Also save the string to d->icon_name, to be used later
		d->icon_name = ucstring_create(c);
		dbuf_read_to_ucstring_n(c->infile, pos, len, 80, d->icon_name,
			DE_CONVFLAG_STOP_AT_NUL, DE_ENCODING_PALM);
	}

	ucstring_destroy(s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %r8, %r8
je 0xaf679
movq %r8, %rbx
cmpq $0x0, 0x8(%r8)
je 0xaf679
movl %r9d, %ebp
movq %rdi, %r12
movq %rsi, %r15
movq %rcx, %r14
movq %rdx, %r13
callq 0xf6870
movq 0x18(%r12), %rdi
movl $0x13, (%rsp)
movl $0x1f4, %ecx            # imm = 0x1F4
movq %r13, 0x8(%rsp)
movq %r13, %rsi
movq %r14, 0x10(%rsp)
movq %r14, %rdx
movq %r15, %r14
movq %rax, %r15
movq %rax, %r8
movl $0x1, %r9d
callq 0xf0203
movq 0x8(%rbx), %rbx
movq %r15, %rdi
callq 0xf74bd
leaq 0x7c837(%rip), %rsi     # 0x12be42
movq %r12, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
testb $0x1, %bpl
je 0xaf663
cmpq $0x0, 0xc0(%r14)
jne 0xaf663
movq %r12, %rdi
callq 0xf6870
movq %rax, 0xc0(%r14)
movq 0x18(%r12), %rdi
movl $0x13, (%rsp)
movl $0x50, %ecx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rax, %r8
movl $0x1, %r9d
callq 0xf0203
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf6bb0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/palmpdb.c
// Function: extract_item
static void extract_item(deark *c, lctx *d, i64 data_offs, i64 data_len,
	const char *ext_sz, de_ucstring *ext_ucstring,
	unsigned int createflags, int always_extract)
{
	de_finfo *fi = NULL;

	if(c->extract_level<2 && !always_extract) goto done;
	if(data_offs<0 || data_len<0) goto done;
	if(data_offs+data_len > c->infile->len) goto done;
	fi = de_finfo_create(c);
	if(ext_sz) {
		de_finfo_set_name_from_sz(c, fi, ext_sz, 0, DE_ENCODING_ASCII);
	}
	else if(ext_ucstring) {
		de_finfo_set_name_from_ucstring(c, fi, ext_ucstring, 0);
	}
	dbuf_create_file_from_slice(c->infile, data_offs, data_len, NULL, fi, createflags);
done:
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbp
movq %rdx, %r14
movq %rdi, %rbx
cmpl $0x2, 0x90(%rdi)
setge %al
cmpl $0x0, 0x40(%rsp)
setne %cl
xorl %r15d, %r15d
orq %rsi, %rdx
js 0xaf72e
orb %al, %cl
je 0xaf72e
movq %rsi, %r12
leaq (%r14,%rsi), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0xaf6d0
xorl %r15d, %r15d
jmp 0xaf72e
movq %r8, %r13
movl %r9d, 0x4(%rsp)
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r15
testq %rbp, %rbp
je 0xaf700
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xeac7c
jmp 0xaf715
testq %r13, %r13
je 0xaf715
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xea9e4
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r15, %r8
movl 0x4(%rsp), %r9d
callq 0xf0321
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xea9b3
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: de_module_pcpaint
void de_module_pcpaint(deark *c, struct deark_module_info *mi)
{
	mi->id = "pcpaint";
	mi->desc = "PCPaint PIC or CLP image";
	mi->run_fn = de_run_pcpaint;
	mi->identify_fn = de_identify_pcpaint;
	mi->help_fn = de_help_pcpaint;
}

// Assembly:
leaq 0x8608d(%rip), %rax     # 0x135810
movq %rax, (%rsi)
leaq 0x8608b(%rip), %rax     # 0x135818
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0xaf7b3
movq %rax, 0x18(%rsi)
leaq 0x7b3(%rip), %rax       # 0xaff56
movq %rax, 0x20(%rsi)
leaq 0x852(%rip), %rax       # 0xb0000
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: de_identify_pcpaint
static int de_identify_pcpaint(deark *c)
{
	u8 buf[12];
	int pic_ext, clp_ext;
	i64 x;

	pic_ext = de_input_file_has_ext(c, "pic");

	de_read(buf, 0, 12);
	if(buf[0]==0x34 && buf[1]==0x12) {
		if(buf[11]==0xff) {
			return pic_ext ? 100 : 50;
		}
		if(buf[11]==0x00 && buf[10]==0x01) {
			return pic_ext ? 60 : 10;
		}
	}

	clp_ext = de_input_file_has_ext(c, "clp");
	if(clp_ext) {
		x = de_getu16le_direct(&buf[0]);
		if(x==c->infile->len) {
			return 50;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x85e75(%rip), %rsi     # 0x135ddd
callq 0xea936
movl %eax, %ebp
movq 0x18(%rbx), %rdi
leaq 0x4(%rsp), %r14
movl $0xc, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0xeeee8
cmpb $0x34, (%r14)
jne 0xaffb5
cmpb $0x12, 0x5(%rsp)
jne 0xaffb5
movb 0xf(%rsp), %al
cmpb $-0x1, %al
je 0xaffe8
testb %al, %al
jne 0xaffb5
cmpb $0x1, 0xe(%rsp)
jne 0xaffb5
testl %ebp, %ebp
movl $0xa, %ecx
movl $0x3c, %eax
jmp 0xafff4
leaq 0x73150(%rip), %rsi     # 0x12310c
movq %rbx, %rdi
callq 0xea936
testl %eax, %eax
je 0xaffe4
leaq 0x4(%rsp), %rdi
callq 0xef1c6
movq %rax, %rcx
movq 0x18(%rbx), %rdx
movl $0x32, %eax
cmpq 0x18(%rdx), %rcx
je 0xafff7
xorl %eax, %eax
jmp 0xafff7
testl %ebp, %ebp
movl $0x32, %ecx
movl $0x64, %eax
cmovel %ecx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: de_module_bsave_cmpr
void de_module_bsave_cmpr(deark *c, struct deark_module_info *mi)
{
	mi->id = "bsave_cmpr";
	mi->desc = "PCPaint compressed BSAVE";
	mi->run_fn = de_run_bsave_cmpr;
	mi->identify_fn = de_identify_bsave_cmpr;
}

// Assembly:
leaq 0x857f5(%rip), %rax     # 0x135831
movq %rax, (%rsi)
leaq 0x857f6(%rip), %rax     # 0x13583c
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0xb0061
movq %rax, 0x18(%rsi)
leaq 0x13e(%rip), %rax       # 0xb019a
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: de_run_bsave_cmpr
static void de_run_bsave_cmpr(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	int ret;
	i64 pos;
	i64 udata_size;
	dbuf *outf = NULL;

	de_declare_fmt(c, "PCPaint compressed BSAVE");
	d = de_malloc(c, sizeof(lctx));
	d->file_fmt = FMT_CMPR_BSAVE;

	udata_size = de_getu16le(7);
	d->unc_pixels = dbuf_create_membuf(c, BSAVE_HDRSIZE+udata_size, 0x1);

	// Construct the 7-byte BSAVE header
	dbuf_copy(c->infile, 0, 5, d->unc_pixels);
	dbuf_copy(c->infile, 7, 2, d->unc_pixels);

	pos = 9;
	d->num_rle_blocks = de_getu16le_p(&pos);
	de_dbg(c, "num rle blocks: %d", (int)d->num_rle_blocks);

	de_dbg(c, "decompressing");
	de_dbg_indent(c, 1);
	ret = decompress_blocks(c, d, 11);
	de_dbg_indent(c, -1);
	if(!ret) goto done;

	outf = dbuf_create_output_file(c, "unc.pic", NULL, 0);
	dbuf_copy(d->unc_pixels, 0, d->unc_pixels->len, outf);

done:
	dbuf_close(outf);
	destroy_lctx(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x857ca(%rip), %rsi     # 0x13583c
callq 0xeb6d6
movl $0x4a0, %esi            # imm = 0x4A0
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r14
movl $0x3, (%rax)
movq 0x18(%rbx), %rdi
movl $0x7, %esi
callq 0xef1ca
leaq 0x7(%rax), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf0faf
movq %rax, 0x88(%r14)
movq 0x18(%rbx), %rdi
xorl %r15d, %r15d
movl $0x5, %edx
xorl %esi, %esi
movq %rax, %rcx
callq 0xefabc
movq 0x18(%rbx), %rdi
movq 0x88(%r14), %rcx
movl $0x7, %esi
movl $0x2, %edx
callq 0xefabc
movq %rsp, %rsi
movq $0x9, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xef1ed
movq %rax, 0x80(%r14)
leaq 0x85c16(%rip), %rsi     # 0x135d1a
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
leaq 0x67325(%rip), %rsi     # 0x11743c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl $0xb, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb104b
movl %eax, %ebp
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testl %ebp, %ebp
je 0xb017c
leaq 0x85c81(%rip), %rsi     # 0x135dd9
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r15
movq 0x88(%r14), %rdi
movq 0x18(%rdi), %rdx
xorl %esi, %esi
movq %rax, %rcx
callq 0xefabc
movq %r15, %rdi
callq 0xf0b13
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb01c0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: destroy_lctx
static void destroy_lctx(deark *c, lctx *d)
{
	if(!d) return;
	if(d->unc_pixels) dbuf_close(d->unc_pixels);
	de_finfo_destroy(c, d->fi);
	de_free(c, d->pal_info_mainfile.data);
	de_free(c, d->pal_info_palfile.data);
	de_free(c, d);
}

// Assembly:
testq %rsi, %rsi
je 0xb0216
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x88(%rsi), %rdi
testq %rdi, %rdi
je 0xb01e0
callq 0xf0b13
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0xea9b3
movq 0x58(%rbx), %rsi
movq %r14, %rdi
callq 0xe9752
movq 0x70(%rbx), %rsi
movq %r14, %rdi
callq 0xe9752
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe9752
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: do_read_alt_palette_file
static int do_read_alt_palette_file(deark *c, lctx *d)
{
	const char *palfn;
	dbuf *palfile = NULL;
	int retval = 0;
	i64 magic;

	palfn = de_get_ext_option(c, "palfile");
	if(!palfn) palfn = de_get_ext_option(c, "file2");
	if(!palfn) {
		retval = 1;
		goto done;
	}

	de_dbg(c, "[reading palette from alternate file]");

	palfile = dbuf_open_input_file(c, palfn);
	if(!palfile) {
		goto done;
	}

	magic = dbuf_getu16le(palfile, 0);
	if(magic!=0x1234) {
		de_err(c, "Palette file is not in PIC format.");
		goto done;
	}

	do_read_palette_data(c, d, palfile, &d->pal_info_palfile);

	if(d->pal_info_palfile.edesc==0) {
		de_warn(c, "Palette file does not contain palette information.");
		retval = 1;
		goto done;
	}

	d->pal_info_to_use = &d->pal_info_palfile;
	retval = 1;

done:
	dbuf_close(palfile);
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x68878(%rip), %rsi     # 0x118aa4
callq 0xea6cb
movq %rax, %r15
testq %rax, %rax
jne 0xb024b
leaq 0x60350(%rip), %rsi     # 0x110590
movq %rbx, %rdi
callq 0xea6cb
movq %rax, %r15
movl $0x1, %ebp
testq %r15, %r15
je 0xb02aa
leaq 0x8573a(%rip), %rsi     # 0x135996
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf1717
testq %rax, %rax
je 0xb02af
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
callq 0xef1ca
cmpq $0x1234, %rax           # imm = 0x1234
jne 0xb02b4
leaq 0x60(%r14), %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0xb0500
cmpl $0x0, 0x60(%r14)
je 0xb02da
movq %r12, 0x78(%r14)
jmp 0xb02c7
xorl %r15d, %r15d
jmp 0xb02c7
xorl %r15d, %r15d
jmp 0xb02c5
leaq 0x85701(%rip), %rsi     # 0x1359bc
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
xorl %ebp, %ebp
movq %r15, %rdi
callq 0xf0b13
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x856fe(%rip), %rsi     # 0x1359df
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0xb02c7
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decompress_block
static int decompress_block(deark *c, lctx *d,
	i64 pos1, i64 packed_data_size, u8 run_marker)
{
	i64 pos = pos1;
	i64 end_of_this_block;
	u8 x;
	i64 run_length;

	end_of_this_block = pos1 + packed_data_size;
	if(end_of_this_block > c->infile->len) {
		end_of_this_block = c->infile->len;
	}

	while(pos<end_of_this_block) {
		x = de_getbyte_p(&pos);
		if(x!=run_marker) {
			// An non-compressed part of the image
			dbuf_writebyte(d->unc_pixels, x);
			continue;
		}

		// A compressed run.
		x = de_getbyte_p(&pos);
		if(x!=0) {
			// If nonzero, this byte is the run length.
			run_length = (i64)x;
		}
		else {
			// If zero, it is followed by a 16-bit run length
			run_length = de_getu16le_p(&pos);
		}

		// Read the byte value to repeat (run_length) times.
		x = de_getbyte_p(&pos);
		dbuf_write_run(d->unc_pixels, x, run_length);
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r14
movq %rdx, (%rsp)
addq %rdx, %r14
movq 0x18(%rdi), %rax
movq 0x18(%rax), %rax
cmpq %rax, %r14
cmovgeq %rax, %r14
cmpq %r14, %rdx
jge 0xb04f1
movl %r8d, %ebx
movq %rsi, %r15
movq %rdi, %r12
movq %rsp, %r13
movq 0x18(%r12), %rdi
movq %r13, %rsi
callq 0xef14d
cmpb %bl, %al
jne 0xb04ab
movq 0x18(%r12), %rdi
movq %r13, %rsi
callq 0xef14d
testb %al, %al
je 0xb04bc
movzbl %al, %ebp
jmp 0xb04cc
movq 0x88(%r15), %rdi
movzbl %al, %esi
callq 0xf11be
jmp 0xb04eb
movq 0x18(%r12), %rdi
movq %r13, %rsi
callq 0xef1ed
movq %rax, %rbp
movq 0x18(%r12), %rdi
movq %r13, %rsi
callq 0xef14d
movq 0x88(%r15), %rdi
movzbl %al, %esi
movq %rbp, %rdx
callq 0xf14bd
cmpq %r14, (%rsp)
jl 0xb0484
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: do_read_palette_data
static int do_read_palette_data(deark *c, lctx *d, dbuf *f, struct pal_info *palinfo)
{
	palinfo->edesc = (UI)dbuf_getu16le(f, 13);
	palinfo->esize = dbuf_getu16le(f, 15);
	palinfo->data = de_malloc(c, palinfo->esize);
	dbuf_read(f, palinfo->data, 17, palinfo->esize);
	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0xd, %esi
movq %r14, %rdi
callq 0xef1ca
movl %eax, (%rbx)
movl $0xf, %esi
movq %r14, %rdi
callq 0xef1ca
movq %rax, 0x8(%rbx)
movq %r15, %rdi
movq %rax, %rsi
callq 0xe969b
movq %rax, 0x10(%rbx)
movq 0x8(%rbx), %rcx
movl $0x11, %edx
movq %r14, %rdi
movq %rax, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xeeee8
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_bilevel
static void decode_bilevel(deark *c, lctx *d)
{
	i64 src_rowspan;
	int is_grayscale;
	UI edesc = d->pal_info_to_use->edesc;
	de_bitmap *img = NULL;

	if(!d->unc_pixels) goto done;

	acquire_palette(c, d, 2);

	// PCPaint's CGA and EGA 2-color modes used gray shade 170 instead of
	// white (255). Maybe they should be interpreted as white, but for
	// historical accuracy I'll go with gray170.
	if(edesc==0 && (d->video_mode==0x43 || d->video_mode==0x45)) {
		d->pal[1] = DE_MAKE_GRAY(170);
	}

	d->pdwidth = de_pad_to_n(d->npwidth, 8);
	src_rowspan = d->pdwidth/8;
	is_grayscale = de_is_grayscale_palette(d->pal, 2);
	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, is_grayscale?1:3);

	de_convert_image_paletted(d->unc_pixels, 0,
		1, src_rowspan, d->pal, img, 0);

	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE|
		DE_CREATEFLAG_OPT_IMAGE);

done:
	de_bitmap_destroy(img);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
cmpq $0x0, 0x88(%rsi)
je 0xb086a
movq %rsi, %rbx
movq %rdi, %r14
movq 0x78(%rsi), %rax
movl (%rax), %ebp
movl $0x2, %edx
callq 0xb0b85
testl %ebp, %ebp
jne 0xb07d8
movzbl 0x3a(%rbx), %eax
cmpl $0x45, %eax
je 0xb07ce
cmpl $0x43, %eax
jne 0xb07d8
movl $0xffaaaaaa, 0xa0(%rbx) # imm = 0xFFAAAAAA
movq 0x20(%rbx), %rdi
movl $0x8, %esi
callq 0xea80b
movq %rax, 0x30(%rbx)
leaq 0x7(%rax), %r15
testq %rax, %rax
cmovnsq %rax, %r15
sarq $0x3, %r15
leaq 0x9c(%rbx), %r12
movl $0x2, %esi
movq %r12, %rdi
callq 0xf2544
movq 0x30(%rbx), %rdx
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
xorl %edi, %edi
testl %eax, %eax
sete %dil
leal 0x1(,%rdi,2), %r8d
movq %r14, %rdi
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
movl $0x0, (%rsp)
movl $0x1, %edx
xorl %esi, %esi
movq %r15, %rcx
movq %r12, %r8
movq %rax, %r9
callq 0xf35b8
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x6, %edx
callq 0xf2917
jmp 0xb086d
xorl %r14d, %r14d
movq %r14, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xf28d4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_cga4
static void decode_cga4(deark *c, lctx *d)
{
	i64 src_rowspan;
	de_bitmap *img = NULL;

	if(!d->unc_pixels) goto done;

	acquire_palette(c, d, 4);

	d->pdwidth = de_pad_to_4(d->npwidth);
	src_rowspan = d->pdwidth/4;
	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, 3);

	de_convert_image_paletted(d->unc_pixels, 0,
		2, src_rowspan, d->pal, img, 0);

	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE);

done:
	de_bitmap_destroy(img);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpq $0x0, 0x88(%rsi)
je 0xb091a
movq %rsi, %rbx
movq %rdi, %r14
movl $0x4, %edx
callq 0xb0b85
movq 0x20(%rbx), %rdi
callq 0xea7de
leaq 0x3(%rax), %r15
testq %rax, %rax
cmovnsq %rax, %r15
movq %rax, 0x30(%rbx)
sarq $0x2, %r15
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq %r14, %rdi
movq %rax, %rdx
movl $0x3, %r8d
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
leaq 0x9c(%rbx), %r8
movl $0x0, (%rsp)
movl $0x2, %edx
xorl %esi, %esi
movq %r15, %rcx
movq %rax, %r9
callq 0xf35b8
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0xf2917
jmp 0xb091d
xorl %r14d, %r14d
movq %r14, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0xf28d4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_egavga16
static void decode_egavga16(deark *c, lctx *d)
{
	i64 src_rowspan;
	de_bitmap *img = NULL;

	acquire_palette(c, d, 16);

	d->pdwidth = de_pad_to_2(d->npwidth);
	src_rowspan = d->pdwidth/2;

	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, 3);
	de_convert_image_paletted(d->unc_pixels, 0, 4, src_rowspan, d->pal, img, 0);
	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE);
	de_bitmap_destroy(img);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl $0x10, %edx
callq 0xb0b85
movq 0x20(%rbx), %rdi
callq 0xea7d5
movq %rax, 0x30(%rbx)
movq %rax, %r15
shrq $0x3f, %r15
addq %rax, %r15
sarq %r15
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq %r14, %rdi
movq %rax, %rdx
movl $0x3, %r8d
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
leaq 0x9c(%rbx), %r8
movl $0x0, (%rsp)
movl $0x4, %edx
xorl %esi, %esi
movq %r15, %rcx
movq %rax, %r9
callq 0xf35b8
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0xf2917
movq %r14, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0xf28d4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_vga256
static void decode_vga256(deark *c, lctx *d)
{
	de_bitmap *img = NULL;

	acquire_palette(c, d, 256);

	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, 3);

	de_convert_image_paletted(d->unc_pixels, 0,
		8, img->width, d->pal, img, 0);

	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE);

	de_bitmap_destroy(img);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x100, %edx            # imm = 0x100
callq 0xb0b85
movq 0x30(%rbx), %rdx
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq %r14, %rdi
movl $0x3, %r8d
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
movq 0x8(%rax), %rcx
leaq 0x9c(%rbx), %r8
movl $0x0, (%rsp)
movl $0x8, %edx
xorl %esi, %esi
movq %rax, %r9
callq 0xf35b8
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0xf2917
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xf28d4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_4color_planar
static void decode_4color_planar(deark *c, lctx *d)
{
	de_bitmap *img = NULL;
	i64 src_rowspan;
	i64 src_planespan;

	acquire_palette(c, d, 4);

	d->pdwidth = de_pad_to_n(d->npwidth, 8);
	src_rowspan = d->pdwidth/8;
	src_planespan = src_rowspan*d->height;

	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, 3);
	de_convert_image_paletted_planar(d->unc_pixels, 0, 2, src_rowspan, src_planespan,
		d->pal, img, 0x02);
	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x4, %edx
callq 0xb0b85
movq 0x20(%rbx), %rdi
movl $0x8, %esi
callq 0xea80b
movq %rax, 0x30(%rbx)
leaq 0x7(%rax), %r15
testq %rax, %rax
cmovnsq %rax, %r15
sarq $0x3, %r15
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq %rcx, %r12
imulq %r15, %r12
movq %r14, %rdi
movq %rax, %rdx
movl $0x3, %r8d
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
leaq 0x9c(%rbx), %r9
movl $0x2, %edx
xorl %esi, %esi
movq %r15, %rcx
movq %r12, %r8
pushq $0x2
pushq %rax
callq 0xf36f9
addq $0x10, %rsp
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x4, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xf2917
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decode_egavga16_planar
static void decode_egavga16_planar(deark *c, lctx *d)
{
	i64 src_rowspan;
	i64 src_planespan;
	de_bitmap *img = NULL;

	acquire_palette(c, d, 16);

	d->pdwidth = de_pad_to_n(d->npwidth, 8);
	src_rowspan = d->pdwidth/8;
	src_planespan = src_rowspan*d->height;

	img = de_bitmap_create2(c, d->npwidth, d->pdwidth, d->height, 3);
	de_convert_image_paletted_planar(d->unc_pixels, 0, 4, src_rowspan,
		src_planespan, d->pal, img, 0x2);
	de_bitmap_write_to_file_finfo(img, d->fi, DE_CREATEFLAG_FLIP_IMAGE);
	de_bitmap_destroy(img);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl $0x10, %edx
callq 0xb0b85
movq 0x20(%rbx), %rdi
movl $0x8, %esi
callq 0xea80b
movq %rax, 0x30(%rbx)
leaq 0x7(%rax), %r15
testq %rax, %rax
cmovnsq %rax, %r15
sarq $0x3, %r15
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq %rcx, %r12
imulq %r15, %r12
movq %r14, %rdi
movq %rax, %rdx
movl $0x3, %r8d
callq 0xf2ce6
movq %rax, %r14
movq 0x88(%rbx), %rdi
leaq 0x9c(%rbx), %r9
movl $0x4, %edx
xorl %esi, %esi
movq %r15, %rcx
movq %r12, %r8
pushq $0x2
pushq %rax
callq 0xf36f9
addq $0x10, %rsp
movq 0x10(%rbx), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0xf2917
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xf28d4
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcpaint.c
// Function: decompress_blocks
static int decompress_blocks(deark *c, lctx *d, i64 pos1)
{
	i64 i;
	i64 packed_block_size;
	i64 unpacked_block_size;
	i64 end_of_this_block;
	i64 pos = pos1;
	u8 run_marker;
	int retval = 0;

	for(i=0; i<d->num_rle_blocks; i++) {
		de_dbg3(c, "block #%d at %"I64_FMT, (int)i, pos);
		de_dbg_indent(c, 1);
		// start_of_this_block = pos;
		packed_block_size = de_getu16le(pos);
		// block size includes the 5-byte header, so it can't be < 5.
		if(packed_block_size<5) packed_block_size=5;
		end_of_this_block = pos + packed_block_size; // Remember where this block ends
		if(end_of_this_block > c->infile->len) goto done;
		unpacked_block_size = de_getu16le(pos+2);
		run_marker = de_getbyte(pos+4);
		pos+=5;

		de_dbg3(c, "packed size: %"I64_FMT, packed_block_size);
		de_dbg3(c, "unpacked size: %"I64_FMT, unpacked_block_size);
		de_dbg3(c, "run marker: 0x%02x", (UI)run_marker);

		if(!decompress_block(c, d, pos, packed_block_size-5, run_marker)) {
			goto done;
		}
		de_dbg_indent(c, -1);

		pos = end_of_this_block;
	}
	retval = 1;
done:
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
cmpq $0x0, 0x80(%rsi)
jle 0xb116a
movq %rdx, %r13
movq %rdi, %r15
xorl %r12d, %r12d
movq %r15, %rdi
leaq 0x84cae(%rip), %rsi     # 0x135d2d
movl %r12d, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0xe9461
movq %r15, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r15), %rdi
movq %r13, %rsi
callq 0xef1ca
movq %rax, %rbp
cmpq $0x6, %rax
movl $0x5, %eax
cmovlq %rax, %rbp
movq %rbp, %rax
addq %r13, %rax
movq 0x18(%r15), %rdi
cmpq 0x18(%rdi), %rax
jg 0xb1171
leaq 0x2(%r13), %rsi
movq %rax, 0x10(%rsp)
callq 0xef1ca
movq %rax, %r14
movq 0x18(%r15), %rdi
leaq 0x4(%r13), %rsi
callq 0xef0d5
movl %eax, %ebx
addq $0x5, %r13
movq %r15, %rdi
leaq 0x84c49(%rip), %rsi     # 0x135d40
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9461
movq %r15, %rdi
leaq 0x84c33(%rip), %rsi     # 0x135d3e
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9461
movzbl %bl, %ebx
movq %r15, %rdi
leaq 0x8484d(%rip), %rsi     # 0x13596f
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9461
addq $-0x5, %rbp
movq %r15, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movl %ebx, %r8d
callq 0xb044f
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
incq %r12
movq 0x10(%rsp), %r13
cmpq 0x80(%r14), %r12
jl 0xb1075
movl $0x1, %eax
jmp 0xb1173
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_module_pcx
void de_module_pcx(deark *c, struct deark_module_info *mi)
{
	mi->id = "pcx";
	mi->desc = "PCX image";
	mi->run_fn = de_run_pcx;
	mi->identify_fn = de_identify_pcx;
	mi->help_fn = de_help_pcx;
}

// Assembly:
leaq 0x84c56(%rip), %rax     # 0x135de1
movq %rax, (%rsi)
leaq 0x84c50(%rip), %rax     # 0x135de5
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0xb11bb
movq %rax, 0x18(%rsi)
leaq 0x41(%rip), %rax        # 0xb11ec
movq %rax, 0x20(%rsi)
leaq 0xed(%rip), %rax        # 0xb12a3
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_identify_pcx
static int de_identify_pcx(deark *c)
{
	u8 buf[8];

	de_read(buf, 0, 8);
	if(buf[0]==0x0a && (buf[1]==0 || buf[1]==2 || buf[1]==3
		|| buf[1]==4 || buf[1]==5) &&
		(buf[2]==0 || buf[2]==1) )
	{
		if(de_input_file_has_ext(c, "pcx"))
			return 100;
		return 16;
	}

	// VGAPaint 386 PCX SFX
	if(buf[0]==0xeb && buf[1]==0x0e && buf[2]==1 && buf[3]==8 &&
		(de_getbyte(16)==0xe8))
	{
		if(de_input_file_has_ext(c, "pcx"))
			return 80;
		return 8;
	}

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movq 0x18(%rdi), %rdi
xorl %ebx, %ebx
leaq 0x8(%rsp), %r15
movl $0x8, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0xeeee8
movb (%r15), %al
cmpb $0xa, %al
jne 0xb124e
movzbl 0x9(%rsp), %ecx
leal -0x2(%rcx), %edx
cmpl $0x4, %edx
jb 0xb122a
testl %ecx, %ecx
jne 0xb124e
cmpb $0x1, 0xa(%rsp)
ja 0xb124e
leaq 0x84ba9(%rip), %rsi     # 0x135de1
movq %r14, %rdi
callq 0xea936
testl %eax, %eax
movl $0x10, %eax
movl $0x64, %ebx
jmp 0xb1294
cmpb $-0x15, %al
jne 0xb1297
cmpb $0xe, 0x9(%rsp)
jne 0xb1297
cmpb $0x1, 0xa(%rsp)
jne 0xb1297
cmpb $0x8, 0xb(%rsp)
jne 0xb1297
movq 0x18(%r14), %rdi
movl $0x10, %esi
callq 0xef0d5
cmpb $-0x18, %al
jne 0xb1297
leaq 0x84b61(%rip), %rsi     # 0x135de1
movq %r14, %rdi
callq 0xea936
testl %eax, %eax
movl $0x8, %eax
movl $0x50, %ebx
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_module_mswordscr
void de_module_mswordscr(deark *c, struct deark_module_info *mi)
{
	mi->id = "mswordscr";
	mi->desc = "MS Word for DOS Screen Capture";
	mi->run_fn = de_run_mswordscr;
	mi->identify_fn = de_identify_mswordscr;
}

// Assembly:
leaq 0x84b10(%rip), %rax     # 0x135def
movq %rax, (%rsi)
leaq 0x84b10(%rip), %rax     # 0x135df9
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0xb1304
movq %rax, 0x18(%rsi)
leaq 0x3d(%rip), %rax        # 0xb133c
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_run_mswordscr
static void de_run_mswordscr(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;

	d = de_malloc(c, sizeof(lctx));
	d->is_mswordscr = 1;
	de_run_pcx_internal(c, d, mparams);
	de_free(c, d);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x4b8, %esi            # imm = 0x4B8
callq 0xe969b
movq %rax, %r14
movb $0x1, 0x90(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0xb1675
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe9752
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_identify_mswordscr
static int de_identify_mswordscr(deark *c)
{
	u8 buf[8];

	de_read(buf, 0, 8);
	if(buf[0]==0xcd && (buf[1]==0 || buf[1]==2 || buf[1]==3
		|| buf[1]==4 || buf[1]==5) &&
		buf[2]==1 )
	{
		if(de_input_file_has_ext(c, "scr") || de_input_file_has_ext(c, "mwg"))
			return 100;

		return 10;
	}
	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
xorl %r14d, %r14d
leaq 0x8(%rsp), %r15
movl $0x8, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0xeeee8
cmpb $-0x33, (%r15)
jne 0xb13bd
movb 0x9(%rsp), %al
testb $-0x3, %al
setne %cl
addb $-0x3, %al
cmpb $0x3, %al
setae %al
testb %al, %cl
jne 0xb13bd
cmpb $0x1, 0xa(%rsp)
jne 0xb13bd
leaq 0x84a6a(%rip), %rsi     # 0x135df5
movq %rbx, %rdi
callq 0xea936
movl $0x64, %r14d
testl %eax, %eax
jne 0xb13bd
leaq 0x84f49(%rip), %rsi     # 0x1362ed
movq %rbx, %rdi
callq 0xea936
testl %eax, %eax
movl $0xa, %eax
movl $0x64, %r14d
cmovel %eax, %r14d
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_module_dcx
void de_module_dcx(deark *c, struct deark_module_info *mi)
{
	mi->id = "dcx";
	mi->desc = "DCX (multi-image PCX)";
	mi->run_fn = de_run_dcx;
	mi->identify_fn = de_identify_dcx;
}

// Assembly:
leaq 0x84a47(%rip), %rax     # 0x135e18
movq %rax, (%rsi)
leaq 0x84a41(%rip), %rax     # 0x135e1c
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0xb13f6
movq %rax, 0x18(%rsi)
leaq 0xf1(%rip), %rax        # 0xb14e2
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_run_dcx
static void de_run_dcx(deark *c, de_module_params *mparams)
{
	u32 *page_offset;
	i64 num_pages;
	i64 page;
	i64 page_size;

	page_offset = de_mallocarray(c, 1023, sizeof(u32));
	num_pages = 0;
	while(num_pages < 1023) {
		page_offset[num_pages] = (u32)de_getu32le(4 + 4*num_pages);
		if(page_offset[num_pages]==0)
			break;
		num_pages++;
	}

	de_dbg(c, "number of pages: %d", (int)num_pages);

	for(page=0; page<num_pages; page++) {
		if(page == num_pages-1) {
			// Last page. Assume it goes to the end of file.
			page_size = c->infile->len - page_offset[page];
		}
		else {
			page_size = page_offset[page+1] - page_offset[page];
		}
		if(page_size<0) page_size=0;
		de_dbg(c, "page %d at %u, size=%"I64_FMT, (int)page, (UI)page_offset[page],
			page_size);

		dbuf_create_file_from_slice(c->infile, page_offset[page], page_size, "pcx", NULL, 0);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x4, %r12d
movl $0x3ff, %esi            # imm = 0x3FF
movl $0x4, %edx
callq 0xea259
movq %rax, %r14
xorl %r15d, %r15d
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef37e
movl %eax, -0x4(%r14,%r12)
testl %eax, %eax
je 0xb144a
incq %r15
addq $0x4, %r12
cmpq $0x1000, %r12           # imm = 0x1000
jne 0xb141f
movl $0x3ff, %r15d           # imm = 0x3FF
leaq 0x84ea0(%rip), %rsi     # 0x1362f1
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
testq %r15, %r15
je 0xb14d3
leaq -0x1(%r15), %r13
xorl %ebp, %ebp
cmpq %rbp, %r13
jne 0xb147f
movq 0x18(%rbx), %rax
movq 0x18(%rax), %r12
movl (%r14,%rbp,4), %eax
subq %rax, %r12
jmp 0xb1488
movl 0x4(%r14,%rbp,4), %r12d
subl (%r14,%rbp,4), %r12d
testq %r12, %r12
movl $0x0, %eax
cmovleq %rax, %r12
movl (%r14,%rbp,4), %ecx
movq %rbx, %rdi
leaq 0x84e63(%rip), %rsi     # 0x136305
movl %ebp, %edx
movq %r12, %r8
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl (%r14,%rbp,4), %esi
movq %r12, %rdx
leaq 0x84921(%rip), %rcx     # 0x135de1
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xf0321
incq %rbp
cmpq %rbp, %r15
jne 0xb1469
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_module_pcx2com
void de_module_pcx2com(deark *c, struct deark_module_info *mi)
{
	mi->id = "pcx2com";
	mi->desc = "PCX2COM self-displaying image";
	mi->run_fn = de_run_pcx2com;
	mi->identify_fn = de_identify_pcx2com;
}

// Assembly:
leaq 0x84923(%rip), %rax     # 0x135e32
movq %rax, (%rsi)
leaq 0x84921(%rip), %rax     # 0x135e3a
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0xb1534
movq %rax, 0x18(%rsi)
leaq 0xd2(%rip), %rax        # 0xb1601
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_run_pcx2com
static void de_run_pcx2com(deark *c, de_module_params *mparams)
{
	i64 pos;
	dbuf *outf = NULL;

	outf = dbuf_create_output_file(c, "pcx", NULL, 0);

	// header
	dbuf_enable_wbuffer(outf);
	dbuf_write(outf, (const u8*)"\x0a\x05\x01\x08\x00\x00\x00\x00\x3f\x01\xc7", 11);
	dbuf_truncate(outf, 64);
	dbuf_write(outf, (const u8*)"\x00\x01\x40\x01\x01\x00\x40\x01\xc8", 9);
	dbuf_truncate(outf, 128);

	// image data, and 0x0c palette marker
	dbuf_copy(c->infile, 920, c->infile->len-920, outf);

	// VGA palette
	pos = 152;
	while(pos < 152+768) {
		u8 x;

		x = de_getbyte_p(&pos);
		dbuf_writebyte(outf, de_scale_63_to_255(x));
	}

	dbuf_close(outf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x8489a(%rip), %rsi     # 0x135de1
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r14
movq %rax, %rdi
callq 0xf0e3f
leaq 0x84e0e(%rip), %rsi     # 0x136370
movl $0xb, %edx
movq %r14, %rdi
callq 0xefb82
movl $0x40, %esi
movq %r14, %rdi
callq 0xf152a
leaq 0x84df9(%rip), %rsi     # 0x13637c
movl $0x9, %edx
movq %r14, %rdi
callq 0xefb82
movl $0x80, %esi
movq %r14, %rdi
callq 0xf152a
movq 0x18(%rbx), %rdi
movq $-0x398, %rdx           # imm = 0xFC68
addq 0x18(%rdi), %rdx
movl $0x398, %esi            # imm = 0x398
movq %r14, %rcx
callq 0xefabc
leaq 0x8(%rsp), %r15
movq $0x98, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef14d
movzbl %al, %edi
callq 0xecde3
movzbl %al, %esi
movq %r14, %rdi
callq 0xf11be
cmpq $0x398, 0x8(%rsp)       # imm = 0x398
jl 0xb15c5
movq %r14, %rdi
callq 0xf0b13
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcx.c
// Function: de_identify_pcx2com
static int de_identify_pcx2com(deark *c)
{
	if(c->infile->len<922 || c->infile->len>65280) return 0;

	if((UI)de_getu32be(0)!=0xb81300cdU) return 0;
	if(de_getbyte(c->infile->len-1) != 0x0c) return 0;

	// The is the substring "Self PCX", xor 0x80.
	if(dbuf_memcmp(c->infile, 104,
		(const u8*)"\xd3\xe5\xec\xe6\xa0\xd0\xc3\xd8", 8))
	{
		return 0;
	}

	return 100;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movq $-0xff01, %rax          # imm = 0xFFFF00FF
addq 0x18(%rdi), %rax
xorl %ebx, %ebx
cmpq $-0xfb67, %rax          # imm = 0xFFFF0499
jb 0xb166b
xorl %ebx, %ebx
xorl %esi, %esi
callq 0xef32a
cmpl $0xb81300cd, %eax       # imm = 0xB81300CD
jne 0xb166b
movq 0x18(%r14), %rdi
movq 0x18(%rdi), %rsi
decq %rsi
callq 0xef0d5
cmpb $0xc, %al
jne 0xb166b
movq 0x18(%r14), %rdi
leaq 0x84cd2(%rip), %rdx     # 0x136322
movl $0x68, %esi
movl $0x8, %ecx
callq 0xf025e
xorl %ecx, %ecx
testl %eax, %eax
movl $0x64, %ebx
cmovnel %ecx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pff2.c
// Function: de_module_pff2
void de_module_pff2(deark *c, struct deark_module_info *mi)
{
	mi->id = "pff2";
	mi->desc = "PFF2 font";
	mi->run_fn = de_run_pff2;
	mi->identify_fn = de_identify_pff2;
}

// Assembly:
leaq 0x83d59(%rip), %rax     # 0x1363a4
movq %rax, (%rsi)
leaq 0x83d54(%rip), %rax     # 0x1363a9
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0xb2670
movq %rax, 0x18(%rsi)
leaq 0xef(%rip), %rax        # 0xb275a
movq %rax, 0x20(%rsi)
retq