LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/reko.c
// Function: read_image_pc8
static void read_image_pc8(deark *c, lctx *d, de_bitmap *img, i64 pos1)
{
	i64 pos = pos1;
	size_t k;
	char tmps[64];

	de_dbg(c, "palette at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	de_zeromem(d->pal, sizeof(d->pal));
	for(k=0; k<256; k++) {
		u32 clr_raw;

		clr_raw = (u32)de_getu16le_p(&pos);
		d->pal[k] = de_rgb555_to_888(clr_raw);
		if(c->debug_level>=2) {
			de_snprintf(tmps, sizeof(tmps), "0x%04x "DE_CHAR_RIGHTARROW" ", (UI)clr_raw);
			de_dbg_pal_entry2(c, k, d->pal[k], tmps, NULL, NULL);
		}
	}
	de_dbg_indent(c, -1);

	de_dbg(c, "image at %"I64_FMT, pos);
	de_convert_image_paletted(c->infile, pos, 8, d->w, d->pal, img, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x6bc3b(%rip), %rsi     # 0x1c1eed
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x19140
movq $0x0, -0x30(%rbp)
cmpq $0x100, -0x30(%rbp)     # imm = 0x100
jae 0x156376
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %edi
callq 0x1619e0
movl %eax, %edx
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl %edx, 0x70(%rax,%rcx,4)
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0x156363
leaq -0x70(%rbp), %rdi
movl -0x74(%rbp), %ecx
movl $0x40, %esi
leaq 0x75812(%rip), %rdx     # 0x1cbb49
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movl 0x70(%rax,%rcx,4), %edx
leaq -0x70(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x15bdb0
jmp 0x156365
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1562e3
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x63f9b(%rip), %rsi     # 0x1ba32e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %r8
addq $0x70, %r8
movq -0x18(%rbp), %r9
movl $0x8, %edx
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x16c520
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/reko.c
// Function: read_image_pc16
static void read_image_pc16(deark *c, lctx *d, de_bitmap *img, i64 pos1)
{
	i64 i,j;
	i64 pos = pos1;

	de_dbg(c, "image at %"I64_FMT, pos);
	for(j=0; j<d->h; j++) {
		for(i=0; i<d->w; i++) {
			u32 clr_raw;
			de_color clr;

			clr_raw = (u32)de_getu16le_p(&pos);
			clr = de_rgb555_to_888(clr_raw);
			de_bitmap_setpixel_rgb(img, i, j, clr);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x63f1f(%rip), %rsi     # 0x1ba32e
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jge 0x156493
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x156483
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1652c0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
callq 0x1619e0
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl -0x40(%rbp), %ecx
callq 0x16b310
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x156434
jmp 0x156485
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x15641e
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/reko.c
// Function: read_image_amiga
static void read_image_amiga(deark *c, lctx *d, de_bitmap *img, i64 pos1)
{
	if(d->ham_flag) {
		convert_image_planar_HAM(c->infile, pos1, d->depth_pixel,
			d->amiga_row_stride, d->amiga_plane_stride, d->pal, img);
	}
	else {
		de_convert_image_paletted_planar(c->infile, pos1, d->depth_pixel,
			d->amiga_row_stride, d->amiga_plane_stride, d->pal, img, 0x02);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x44(%rax)
je 0x1564fe
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %r9
addq $0x70, %r9
movq -0x18(%rbp), %rax
movq %rax, (%rsp)
callq 0x156550
jmp 0x156540
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %r8
movq -0x10(%rbp), %r9
addq $0x70, %r9
movq -0x18(%rbp), %rax
movq %rax, (%rsp)
movl $0x2, 0x8(%rsp)
callq 0x16c690
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/reko.c
// Function: set_wizsol_card_filename
static void set_wizsol_card_filename(deark *c, i64 cardidx, u8 cardval,
	u8 cardsuit, de_finfo *fi)
{
	static const char *cnames = "a23456789tjqk";
	static const char *snames = "cdhs";
	char nbuf[16];

	if(cardval>=1 && cardval<=13 && cardsuit<=3) {
		nbuf[0] = cnames[(UI)cardval-1];
		nbuf[1] = snames[(UI)cardsuit];
		nbuf[2] = '\0';
	}
	else if(cardidx==0) {
		de_strlcpy(nbuf, "back", sizeof(nbuf));
	}
	else {
		de_strlcpy(nbuf, "other", sizeof(nbuf));
	}

	de_finfo_set_name_from_sz(c, fi, nbuf, 0, DE_ENCODING_LATIN1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %cl, -0x11(%rbp)
movb %al, -0x12(%rbp)
movq %r8, -0x20(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0x1, %eax
jl 0x156918
movzbl -0x11(%rbp), %eax
cmpl $0xd, %eax
jg 0x156918
movzbl -0x12(%rbp), %eax
cmpl $0x3, %eax
jg 0x156918
movq 0xcf120(%rip), %rax     # 0x225a10
movzbl -0x11(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x30(%rbp)
movq 0xcf112(%rip), %rax     # 0x225a18
movzbl -0x12(%rbp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x2f(%rbp)
movb $0x0, -0x2e(%rbp)
jmp 0x15694d
cmpq $0x0, -0x10(%rbp)
jne 0x156936
leaq -0x30(%rbp), %rdi
leaq 0x7ac2d(%rip), %rsi     # 0x1d1557
movl $0x10, %edx
callq 0x15aa30
jmp 0x15694b
leaq -0x30(%rbp), %rdi
leaq 0x818fc(%rip), %rsi     # 0x1d823d
movl $0x10, %edx
callq 0x15aa30
jmp 0x15694d
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq -0x30(%rbp), %rdx
xorl %ecx, %ecx
movl $0x5, %r8d
callq 0x15d4c0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: de_module_sgiimage
void de_module_sgiimage(deark *c, struct deark_module_info *mi)
{
	mi->id = "sgiimage";
	mi->desc = "SGI image";
	mi->run_fn = de_run_sgiimage;
	mi->identify_fn = de_identify_sgiimage;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
leaq 0x7ad45(%rip), %rcx     # 0x1d16cc
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq 0x7ad40(%rip), %rcx     # 0x1d16d5
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
leaq 0x1c(%rip), %rcx        # 0x1569c0
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
leaq 0x44d(%rip), %rcx       # 0x156e00
movq %rcx, 0x20(%rax)
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: de_identify_sgiimage
static int de_identify_sgiimage(deark *c)
{
	UI n;

	if(c->infile->len<513) return 0;

	n = (UI)de_getu16be(0); // MAGIC
	if(n!=474) return 0;

	n = (UI)de_getbyte(2); // "STORAGE"
	if(n>1) return 0;

	n = (UI)de_getbyte(3); // "BPC"
	if(n<1 || n>2) return 0;

	n = (UI)de_getu16be(4); // "DIMENSION"
	// Only 1-3 are legal, but we allow 0-4 because this field is confusing
	// and underspecified.
	if(n>4) return 0;

	n = (UI)de_getu16be(10); // "ZSIZE"
	// Allow 0 because this field may be unused for some image types.
	if(n>4) return 0;

	return 60;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x201, 0x18(%rax)      # imm = 0x201
jge 0x156e2a
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1651d0
movl %eax, -0x14(%rbp)
cmpl $0x1da, -0x14(%rbp)     # imm = 0x1DA
je 0x156e53
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jbe 0x156e7a
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x3, %esi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jb 0x156e9e
cmpl $0x2, -0x14(%rbp)
jbe 0x156ea7
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x4, %esi
callq 0x1651d0
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jbe 0x156ecb
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0xa, %esi
callq 0x1651d0
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jbe 0x156eef
movl $0x0, -0x4(%rbp)
jmp 0x156ef6
movl $0x3c, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: get_cmprtype_name
static const char *get_cmprtype_name(u8 n)
{
	const char *name = NULL;

	switch(n) {
	case 0: name = "none"; break;
	case 1: name = "RLE"; break;
	}
	return name?name:"?";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %dil, %al
movb %al, -0x1(%rbp)
movq $0x0, -0x10(%rbp)
movzbl -0x1(%rbp), %eax
movl %eax, -0x14(%rbp)
testl %eax, %eax
je 0x156f29
jmp 0x156f1f
movl -0x14(%rbp), %eax
subl $0x1, %eax
je 0x156f36
jmp 0x156f41
leaq 0x457dd(%rip), %rax     # 0x19c70d
movq %rax, -0x10(%rbp)
jmp 0x156f41
leaq 0x597d5(%rip), %rax     # 0x1b0712
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x156f52
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x156f5f
leaq 0x60cd4(%rip), %rax     # 0x1b7c2d
movq %rax, -0x20(%rbp)
jmp 0x156f5f
movq -0x20(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: get_cmi_name
static const char *get_cmi_name(u32 n)
{
	const char *name = NULL;

	switch(n) {
	case CMI_NORMAL: name = "normal image"; break;
	case CMI_RGB332: name = "RGB332"; break;
	case CMI_PALETTED: name = "paletted"; break;
	case CMI_PALETTE_ONLY: name = "palette only"; break;
	}
	return name?name:"?";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
movl -0x4(%rbp), %eax
movq %rax, -0x18(%rbp)
subq $0x3, %rax
ja 0x156fd2
movq -0x18(%rbp), %rax
leaq 0x7a725(%rip), %rcx     # 0x1d16bc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7a826(%rip), %rax     # 0x1d17cd
movq %rax, -0x10(%rbp)
jmp 0x156fd2
leaq 0x7a826(%rip), %rax     # 0x1d17da
movq %rax, -0x10(%rbp)
jmp 0x156fd2
leaq 0x7a820(%rip), %rax     # 0x1d17e1
movq %rax, -0x10(%rbp)
jmp 0x156fd2
leaq 0x7a81c(%rip), %rax     # 0x1d17ea
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x156fe3
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x156ff0
leaq 0x60c43(%rip), %rax     # 0x1b7c2d
movq %rax, -0x20(%rbp)
jmp 0x156ff0
movq -0x20(%rbp), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: sgiimage_decode_image
static void sgiimage_decode_image(deark *c, struct sgiimage_ctx *d,
	dbuf *inf, i64 pos1, de_bitmap *img, de_bitmap *imglo)
{
	i64 pos = pos1;
	i64 pn;
	i64 i, j;

	for(pn=0; pn<d->num_channels; pn++) {
		i64 samplenum;

		if(d->has_alpha && pn==(d->num_channels-1))
			samplenum = 3;
		else
			samplenum = pn;

		for(j=0; j<d->height; j++) {
			for(i=0; i<d->width; i++) {
				UI s;

				s = sgiimage_getsample_p(d, inf, &pos);

				if(imglo) {
					de_bitmap_setsample(img, i, j, samplenum, (de_colorsample)(s>>8));
					de_bitmap_setsample(imglo, i, j, samplenum, (s&0xff));
				}
				else {
					de_bitmap_setsample(img, i, j, samplenum, (de_colorsample)s);
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jge 0x1573ac
movq -0x10(%rbp), %rax
movzbl 0x39(%rax), %eax
cmpl $0x0, %eax
je 0x1572be
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x1572be
movq $0x3, -0x58(%rbp)
jmp 0x1572c6
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0x157399
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jge 0x157386
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x157670
movl %eax, -0x5c(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x157357
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl -0x5c(%rbp), %eax
shrl $0x8, %eax
movzbl %al, %r8d
callq 0x16b060
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl -0x5c(%rbp), %eax
andl $0xff, %eax
movzbl %al, %r8d
callq 0x16b060
jmp 0x157373
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl -0x5c(%rbp), %eax
movzbl %al, %r8d
callq 0x16b060
jmp 0x157375
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x1572e8
jmp 0x157388
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1572ce
jmp 0x15739b
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x157280
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/sgiimage.c
// Function: sgiimage_getsample_p
static UI sgiimage_getsample_p(struct sgiimage_ctx *d, dbuf *f, i64 *ppos)
{
	UI s;

	if(d->bytes_per_sample==2) {
		s = (UI)dbuf_getu16be_p(f, ppos);
	}
	else {
		s = dbuf_getbyte_p(f, ppos);
	}
	return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0x1576a0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x165210
movl %eax, -0x1c(%rbp)
jmp 0x1576b3
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: de_module_storyboard
void de_module_storyboard(deark *c, struct deark_module_info *mi)
{
	mi->id = "storyboard";
	mi->desc = "Storyboard PIC/CAP";
	mi->run_fn = de_run_storyboard;
	mi->identify_fn = de_identify_storyboard;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
leaq 0x7a049(%rip), %rcx     # 0x1d18c0
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq 0x7a046(%rip), %rcx     # 0x1d18cb
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
leaq 0x1c(%rip), %rcx        # 0x1578b0
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
leaq 0x10d(%rip), %rcx       # 0x1579b0
movq %rcx, 0x20(%rax)
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: de_run_storyboard
static void de_run_storyboard(deark *c, de_module_params *mparams)
{
	struct storyboard_ctx *d = NULL;
	u8 b;

	d = de_malloc(c, sizeof(struct storyboard_ctx));
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_CP437);

	b = de_getbyte(2);
	if(b=='_') {
		de_declare_fmt(c, "Storyboard picture (old)");
		de_run_storyboard_oldfmt(c, d, mparams);
	}
	else if(b==0xc1) {
		de_declare_fmt(c, "Storyboard picture (new)");
		de_run_storyboard_newfmt(c, d, mparams);
	}
	else {
		d->need_errmsg = 1;
	}

	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported Storyboard image");
		}
		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 $0x880, %esi            # imm = 0x880
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xd, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x2, %esi
callq 0x165060
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
cmpl $0x5f, %eax
jne 0x157935
movq -0x8(%rbp), %rdi
leaq 0x79fc1(%rip), %rsi     # 0x1d18de
callq 0x15e380
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x157b20
jmp 0x15796d
movzbl -0x19(%rbp), %eax
cmpl $0xc1, %eax
jne 0x157963
movq -0x8(%rbp), %rdi
leaq 0x79fac(%rip), %rsi     # 0x1d18f7
callq 0x15e380
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x157cc0
jmp 0x15796b
movq -0x18(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0x15796d
cmpq $0x0, -0x18(%rbp)
je 0x15799d
movq -0x18(%rbp), %rax
cmpb $0x0, 0x6(%rax)
je 0x157990
movq -0x8(%rbp), %rdi
leaq 0x79f87(%rip), %rsi     # 0x1d1910
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: de_identify_storyboard
static int de_identify_storyboard(deark *c)
{
	u8 b[6];
	int has_ext;

	de_read(b, 0, sizeof(b));

	if(!de_memcmp(b, (const void*)"EP_CAP", 6)) {
		return 100;
	}

	if(c->infile->len<1856) return 0;
	if(b[2]!=0xc1) return 0;
	if(b[0]!=0x00 && b[0]!=0x54) return 0;

	has_ext = de_input_file_has_ext(c, "pic") ||
		de_input_file_has_ext(c, "cap");

	if(b[1]==0x84) {
		if(b[3]==0x01 || b[3]==0x03 || b[3]==0x07 || b[3]==0x08) {
			return has_ext ? 90 : 50;
		}
	}
	else if(b[1]==0x85 || b[1]==0x86) {
		return has_ext ? 51 : 11;
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x16(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x6, %ecx
callq 0x164d10
leaq -0x16(%rbp), %rdi
leaq 0x7a02a(%rip), %rsi     # 0x1d1a0b
movl $0x6, %edx
callq 0x19170
cmpl $0x0, %eax
jne 0x1579fc
movl $0x64, -0x4(%rbp)
jmp 0x157b0f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x740, 0x18(%rax)      # imm = 0x740
jge 0x157a1a
movl $0x0, -0x4(%rbp)
jmp 0x157b0f
movzbl -0x14(%rbp), %eax
cmpl $0xc1, %eax
je 0x157a31
movl $0x0, -0x4(%rbp)
jmp 0x157b0f
movzbl -0x16(%rbp), %eax
cmpl $0x0, %eax
je 0x157a4f
movzbl -0x16(%rbp), %eax
cmpl $0x54, %eax
je 0x157a4f
movl $0x0, -0x4(%rbp)
jmp 0x157b0f
movq -0x10(%rbp), %rdi
leaq 0x6a043(%rip), %rsi     # 0x1c1a9d
callq 0x15d180
movl %eax, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x1d(%rbp)
jne 0x157a84
movq -0x10(%rbp), %rdi
leaq 0x79f9c(%rip), %rsi     # 0x1d1a12
callq 0x15d180
cmpl $0x0, %eax
setne %al
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x1c(%rbp)
movzbl -0x15(%rbp), %eax
cmpl $0x84, %eax
jne 0x157ad8
movzbl -0x13(%rbp), %eax
cmpl $0x1, %eax
je 0x157abe
movzbl -0x13(%rbp), %eax
cmpl $0x3, %eax
je 0x157abe
movzbl -0x13(%rbp), %eax
cmpl $0x7, %eax
je 0x157abe
movzbl -0x13(%rbp), %eax
cmpl $0x8, %eax
jne 0x157ad6
movl -0x1c(%rbp), %edx
movl $0x32, %eax
movl $0x5a, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x157b0f
jmp 0x157b08
movzbl -0x15(%rbp), %eax
cmpl $0x85, %eax
je 0x157aee
movzbl -0x15(%rbp), %eax
cmpl $0x86, %eax
jne 0x157b06
movl -0x1c(%rbp), %edx
movl $0xb, %eax
movl $0x33, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x157b0f
jmp 0x157b08
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: de_run_storyboard_oldfmt
static void de_run_storyboard_oldfmt(deark *c, struct storyboard_ctx *d,
	de_module_params *mparams)
{
	i64 pos;

	pos = 6;
	if(de_getbyte_p(&pos) != 0) {
		d->need_errmsg = 1;
		goto done;
	}

	d->mode = de_getbyte_p(&pos);
	de_dbg(c, "mode: %u", (UI)d->mode);
	pos += 3; // ?

	d->rowspan = de_getu16le_p(&pos);
	de_dbg(c, "bytes per row: %u", (UI)d->rowspan);
	d->height = de_getu16le_p(&pos);
	de_dbg(c, "height: %u", (UI)d->height);

	switch(d->mode) {
	case 3:
		d->is_text = 1;
		break;
	case 4:
		d->bpp = 2;
		break;
	case 6:
		d->bpp = 1;
		break;
	default:
		de_err(c, "Unsupported screen mode: %u", (UI)d->mode);
		goto done;
	}

	if(d->is_text) {
		do_oldfmt_text(c, d, pos);
	}
	else {
		do_oldfmt_image(c, d, pos);
	}
	// TODO: Is it possible for a file to contain multiple images?

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x6, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
cmpl $0x0, %eax
je 0x157b62
movq -0x10(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0x157cad
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
movq %rsi, -0x30(%rbp)
callq 0x165170
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %edx
leaq 0x5d8ad(%rip), %rsi     # 0x1b5440
xorl %eax, %eax
movb %al, -0x25(%rbp)
callq 0x15b0d0
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1652c0
movq %rax, %rdx
movb -0x25(%rbp), %al
movq -0x10(%rbp), %rcx
movq %rdx, 0x20(%rcx)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0x20(%rcx), %edx
leaq 0x79d5a(%rip), %rsi     # 0x1d1934
callq 0x15b0d0
movq -0x30(%rbp), %rsi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1652c0
movq %rax, %rdx
movb -0x25(%rbp), %al
movq -0x10(%rbp), %rcx
movq %rdx, 0x18(%rcx)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl 0x18(%rcx), %edx
leaq 0x79d36(%rip), %rsi     # 0x1d1946
callq 0x15b0d0
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
movl %eax, -0x24(%rbp)
subl $0x3, %eax
je 0x157c3b
jmp 0x157c27
movl -0x24(%rbp), %eax
subl $0x4, %eax
je 0x157c45
jmp 0x157c31
movl -0x24(%rbp), %eax
subl $0x6, %eax
je 0x157c53
jmp 0x157c61
movq -0x10(%rbp), %rax
movb $0x1, 0x5(%rax)
jmp 0x157c7d
movq -0x10(%rbp), %rax
movq $0x2, 0x8(%rax)
jmp 0x157c7d
movq -0x10(%rbp), %rax
movq $0x1, 0x8(%rax)
jmp 0x157c7d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %edx
leaq 0x79cdd(%rip), %rsi     # 0x1d1951
movb $0x0, %al
callq 0x15bfb0
jmp 0x157cad
movq -0x10(%rbp), %rax
cmpb $0x0, 0x5(%rax)
je 0x157c9a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x157ea0
jmp 0x157cab
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x158070
jmp 0x157cad
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: newfmt_readpal256
static void newfmt_readpal256(deark *c, struct storyboard_ctx *d)
{
	i64 pos = 128;
	u8 cr1, cg1, cb1;
	u8 cr2, cg2, cb2;
	i64 k;
	char tmps[64];

	for(k=0; k<256; k++) {
		cr1 = de_getbyte(pos);
		cg1 = de_getbyte(pos+256);
		cb1 = de_getbyte(pos+512);
		pos++;

		cr2 = de_scale_63_to_255(cr1);
		cg2 = de_scale_63_to_255(cg1);
		cb2 = de_scale_63_to_255(cb1);
		d->pal[k] = DE_MAKE_RGB(cr2, cg2, cb2);
		de_snprintf(tmps, sizeof(tmps), "(%2d,%2d,%2d) "DE_CHAR_RIGHTARROW" ",
			(int)cr1, (int)cg1, (int)cb1);
		de_dbg_pal_entry2(c, k, d->pal[k], tmps, NULL, NULL);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x80, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x100, -0x28(%rbp)     # imm = 0x100
jge 0x158ddb
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x165060
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x100, %rsi            # imm = 0x100
callq 0x165060
movb %al, -0x1a(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x200, %rsi            # imm = 0x200
callq 0x165060
movb %al, -0x1b(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movzbl -0x19(%rbp), %edi
callq 0x161710
movb %al, -0x1c(%rbp)
movzbl -0x1a(%rbp), %edi
callq 0x161710
movb %al, -0x1d(%rbp)
movzbl -0x1b(%rbp), %edi
callq 0x161710
movb %al, -0x1e(%rbp)
movzbl -0x1c(%rbp), %edx
shll $0x10, %edx
orl $0xff000000, %edx       # imm = 0xFF000000
movzbl -0x1d(%rbp), %eax
shll $0x8, %eax
orl %eax, %edx
movzbl -0x1e(%rbp), %eax
orl %eax, %edx
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movl %edx, 0x7c(%rax,%rcx,4)
leaq -0x70(%rbp), %rdi
movzbl -0x19(%rbp), %ecx
movzbl -0x1a(%rbp), %r8d
movzbl -0x1b(%rbp), %r9d
movl $0x40, %esi
leaq 0x441d3(%rip), %rdx     # 0x19cf71
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movl 0x7c(%rax,%rcx,4), %edx
leaq -0x70(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
callq 0x15bdb0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x158cd0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: do_newfmt_render_planar
static void do_newfmt_render_planar(deark *c, struct storyboard_ctx *d,
	dbuf *unc_data, de_bitmap *img)
{
	i64 n;
#define SBPIC_MAXPLANES 4
	u8 pbit[SBPIC_MAXPLANES];

	de_zeromem(pbit, sizeof(pbit));

	for(n=0; n<d->planespan; n++) {
		UI k;
		UI pn;
		i64 xpos, ypos;

		for(pn=0; pn<(UI)d->bpp; pn++) {
			pbit[pn] = dbuf_getbyte(unc_data, pn*d->planespan + n);
		}

		ypos = n%d->height;
		for(k=0; k<8; k++) {
			UI palent;

			xpos = 8*(n/d->height) + (i64)(7-k);
			palent = 0;
			for(pn=0; pn<(UI)d->bpp; pn++) {
				if((pbit[pn] & (1U<<k))!=0) {
					palent |= 1U<<pn;
				}
			}

			de_bitmap_setpixel_rgb(img, xpos, ypos, d->pal[palent]);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x2c(%rbp), %rdi
xorl %esi, %esi
movl $0x4, %edx
callq 0x19140
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jge 0x15923f
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl %ecx, %eax
jae 0x159167
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, %esi
movq -0x10(%rbp), %rax
imulq 0x68(%rax), %rsi
addq -0x28(%rbp), %rsi
callq 0x165060
movb %al, %cl
movl -0x34(%rbp), %eax
movb %cl, -0x2c(%rbp,%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x159129
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cqto
idivq 0x18(%rcx)
movq %rdx, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x8, -0x30(%rbp)
jae 0x15922c
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cqto
idivq 0x18(%rcx)
shlq $0x3, %rax
movl $0x7, %ecx
subl -0x30(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl %ecx, %eax
jae 0x159202
movl -0x34(%rbp), %eax
movzbl -0x2c(%rbp,%rax), %eax
movl -0x30(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1591f5
movl -0x34(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
orl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x1591f7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1591bb
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x10(%rbp), %rax
movl -0x4c(%rbp), %ecx
movl 0x7c(%rax,%rcx,4), %ecx
callq 0x16b310
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x159180
jmp 0x15922e
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x159110
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: newfmt_copy_from_prev_row
static int newfmt_copy_from_prev_row(deark *c, struct storyboard_ctx *d,
	dbuf *outf, i64 count)
{
	dbuf_flush(outf);
	if(count > d->width) return 0;
	dbuf_copy(outf, outf->len - d->width, count, outf);
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x167c30
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jle 0x159288
movl $0x0, -0x4(%rbp)
jmp 0x1592b0
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
subq 0x10(%rax), %rsi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x166070
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: de_module_xwd
void de_module_xwd(deark *c, struct deark_module_info *mi)
{
	mi->id = "xwd";
	mi->desc = "X-Windows screen dump";
	mi->run_fn = de_run_xwd;
	mi->identify_fn = de_identify_xwd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
leaq 0x78779(%rip), %rcx     # 0x1d1a50
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
leaq 0x7876f(%rip), %rcx     # 0x1d1a54
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
leaq 0x1c(%rip), %rcx        # 0x159310
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
leaq 0xad(%rip), %rcx        # 0x1593b0
movq %rcx, 0x20(%rax)
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: de_run_xwd
static void de_run_xwd(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;

	d = de_malloc(c, sizeof(lctx));
	do_header(c, d);
	if(d->errflag) goto done;
	// TODO?: Do something with the name that may appear after the header.

	read_or_construct_colormap(c, d);

	do_xwd_image(c, d);

done:
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported XWD file");
		}
		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 $0x508, %esi            # imm = 0x508
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1594f0
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0x159352
jmp 0x15936c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x159780
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x159920
cmpq $0x0, -0x18(%rbp)
je 0x15939c
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x15938f
movq -0x8(%rbp), %rdi
leaq 0x786e2(%rip), %rsi     # 0x1d1a6a
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: de_identify_xwd
static int de_identify_xwd(deark *c)
{
	int has_ext = 0;
	i64 hdrsize;
	i64 cmapn;
	UI n;

	// TODO: Identification could be improved.

	n = (UI)de_getu32be(4); // version
	if (n!=7) return 0;

	hdrsize = (UI)de_getu32be(0);
	if(hdrsize<100 || hdrsize>500) return 0;

	n = (UI)de_getu32be(8); // pixfmt
	if(n>2) return 0;

	n = (UI)de_getu32be(12); // depth
	if(n<1 || n>32) return 0;

	cmapn = de_getu32be(76);
	if(cmapn>512) return 0;
	if(hdrsize + 12*cmapn > c->infile->len) return 0;

	has_ext = de_input_file_has_ext(c, "xwd");
	if(has_ext) return 100;
	return 75;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x4, %esi
callq 0x165470
movl %eax, -0x2c(%rbp)
cmpl $0x7, -0x2c(%rbp)
je 0x1593ea
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x165470
movl %eax, %eax
movq %rax, -0x20(%rbp)
cmpq $0x64, -0x20(%rbp)
jl 0x159412
cmpq $0x1f4, -0x20(%rbp)     # imm = 0x1F4
jle 0x15941e
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x8, %esi
callq 0x165470
movl %eax, -0x2c(%rbp)
cmpl $0x2, -0x2c(%rbp)
jbe 0x159445
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0xc, %esi
callq 0x165470
movl %eax, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
jb 0x159466
cmpl $0x20, -0x2c(%rbp)
jbe 0x15946f
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x4c, %esi
callq 0x165470
movq %rax, -0x28(%rbp)
cmpq $0x200, -0x28(%rbp)     # imm = 0x200
jle 0x159498
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x20(%rbp), %rax
imulq $0xc, -0x28(%rbp), %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x1594bb
movl $0x0, -0x4(%rbp)
jmp 0x1594e4
movq -0x10(%rbp), %rdi
leaq 0x7858a(%rip), %rsi     # 0x1d1a50
callq 0x15d180
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x1594dd
movl $0x64, -0x4(%rbp)
jmp 0x1594e4
movl $0x4b, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: read_or_construct_colormap
static void read_or_construct_colormap(deark *c, lctx *d)
{
	UI k;
	UI num_entries_to_read;
	int saved_indent_level;
	i64 pos;

	de_dbg_indent_save(c, &saved_indent_level);
	if((d->imgtype==XWD_IMGTYPE_PAL_OR_GRAY) &&
		(d->bits_per_pixel>=1 && d->bits_per_pixel<=8))
	{
		de_make_grayscale_palette(d->pal, 1ULL<<d->bits_per_pixel, 0);
	}

	if(d->cmap_size_in_bytes<1) goto done;

	de_dbg(c, "colormap at %"I64_FMT, d->cmap_pos);
	de_dbg_indent(c, 1);

	num_entries_to_read = d->hf[HF_CMAP_NUM_ENTRIES];
	if(num_entries_to_read>256) num_entries_to_read = 256;

	pos = d->cmap_pos;
	for(k=0; k<num_entries_to_read; k++) {
		UI s;
		u8 samp[3];

		pos += 4;
		for(s=0; s<3; s++) {
			samp[s] = de_getbyte_p(&pos);
			pos++;
		}
		d->pal[k] = DE_MAKE_RGB(samp[0], samp[1], samp[2]);
		de_dbg_pal_entry(c, (i64)k, d->pal[k]);
		pos += 2;
	}

done:
	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 -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
cmpl $0x1, 0xdc(%rax)
jne 0x1597eb
movq -0x10(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jl 0x1597eb
movq -0x10(%rbp), %rax
cmpq $0x8, 0xb0(%rax)
jg 0x1597eb
movq -0x10(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rcx
movl $0x1, %esi
shlq %cl, %rsi
xorl %edx, %edx
callq 0x16d580
movq -0x10(%rbp), %rax
cmpq $0x1, 0x80(%rax)
jge 0x1597fe
jmp 0x15990b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
leaq 0x6d806(%rip), %rsi     # 0x1c7017
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
movl %eax, -0x18(%rbp)
cmpl $0x100, -0x18(%rbp)     # imm = 0x100
jbe 0x159840
movl $0x100, -0x18(%rbp)     # imm = 0x100
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x159909
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x3, -0x2c(%rbp)
jae 0x1598a9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movb %al, %cl
movl -0x2c(%rbp), %eax
movb %cl, -0x2f(%rbp,%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x159872
movzbl -0x2f(%rbp), %edx
shll $0x10, %edx
orl $0xff000000, %edx       # imm = 0xFF000000
movzbl -0x2e(%rbp), %eax
shll $0x8, %eax
orl %eax, %edx
movzbl -0x2d(%rbp), %eax
orl %eax, %edx
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %edx, 0x108(%rax,%rcx,4)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, %esi
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x108(%rax,%rcx,4), %edx
callq 0x15bf00
movq -0x28(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x159853
jmp 0x15990b
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: get_pixfmt_name
static const char *get_pixfmt_name(UI x)
{
	const char *name = NULL;

	switch(x) {
	case 0: name = "1-bit"; break;
	case 1: name = "1-plane"; break;
	case 2: name = "multi-plane"; break;
	}
	return name?name:"?";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x14(%rbp)
testl %eax, %eax
je 0x159c2f
jmp 0x159c1b
movl -0x14(%rbp), %eax
subl $0x1, %eax
je 0x159c3c
jmp 0x159c25
movl -0x14(%rbp), %eax
subl $0x2, %eax
je 0x159c49
jmp 0x159c54
leaq 0x77e7b(%rip), %rax     # 0x1d1ab1
movq %rax, -0x10(%rbp)
jmp 0x159c54
leaq 0x77e74(%rip), %rax     # 0x1d1ab7
movq %rax, -0x10(%rbp)
jmp 0x159c54
leaq 0x77e6f(%rip), %rax     # 0x1d1abf
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x159c65
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x159c72
leaq 0x5dfc1(%rip), %rax     # 0x1b7c2d
movq %rax, -0x20(%rbp)
jmp 0x159c72
movq -0x20(%rbp), %rax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: get_vclass_name
static const char *get_vclass_name(UI x)
{
	const char *name = NULL;

	switch(x) {
	case 0: name = "grayscale"; break;
	case 2: name = "colormapped"; break;
	case 4: name = "truecolor"; break;
	}
	return name?name:"?";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq $0x0, -0x10(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x14(%rbp)
testl %eax, %eax
je 0x159caf
jmp 0x159c9b
movl -0x14(%rbp), %eax
subl $0x2, %eax
je 0x159cbc
jmp 0x159ca5
movl -0x14(%rbp), %eax
subl $0x4, %eax
je 0x159cc9
jmp 0x159cd4
leaq 0x48212(%rip), %rax     # 0x1a1ec8
movq %rax, -0x10(%rbp)
jmp 0x159cd4
leaq 0x77e08(%rip), %rax     # 0x1d1acb
movq %rax, -0x10(%rbp)
jmp 0x159cd4
leaq 0x6801d(%rip), %rax     # 0x1c1ced
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x159ce5
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x159cf2
leaq 0x5df41(%rip), %rax     # 0x1b7c2d
movq %rax, -0x20(%rbp)
jmp 0x159cf2
movq -0x20(%rbp), %rax
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: decode_bitfield
static void decode_bitfield(UI n, UI *pshift, i64 *pmaxval)
{
	u8 ok = 0;
	UI sh = 0;
	i64 mv = 0;
	UI count_of_1_bits = 0;
	UI k;

	for(k=0; k<=31; k++) {
		if(n & (1U<<k)) {
			if(count_of_1_bits==0) {
				sh = k;
			}
			count_of_1_bits++;
			mv = (mv<<1U) | 0x1;
		}
	}

	if(count_of_1_bits==0 || count_of_1_bits>16) goto done;
	ok = 1;

done:
	if(ok) {
		*pshift = sh;
		*pmaxval = mv;
	}
	else {
		*pshift = 0;
		*pmaxval = 255;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x1f, -0x30(%rbp)
ja 0x15a33d
movl -0x4(%rbp), %eax
movl -0x30(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x15a330
cmpl $0x0, -0x2c(%rbp)
jne 0x15a318
movl -0x30(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
shlq %rax
orq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x15a332
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x15a2f0
cmpl $0x0, -0x2c(%rbp)
je 0x15a349
cmpl $0x10, -0x2c(%rbp)
jbe 0x15a34b
jmp 0x15a34f
movb $0x1, -0x19(%rbp)
cmpb $0x0, -0x19(%rbp)
je 0x15a36b
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0x15a380
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movq $0xff, (%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: detect_compression
static void detect_compression(deark *c, lctx *d)
{
	i64 count;

	if(d->actual_image_size == d->expected_image_size) goto done;
	if(d->actual_image_size%3 != 0) goto done;

	if(d->hf[HF_PIXFMT]==2 &&
		d->hf[HF_DEPTH]==8 &&
		d->hf[HF_BYTE_ORDER]==0 &&
		d->hf[HF_BITMAP_UNIT]==32 &&
		d->hf[HF_BIT_ORDER]==0 &&
		d->hf[HF_SCANLINE_PAD]==32 &&
		d->hf[HF_BITS_PER_PIX]==8 &&
		d->hf[HF_VCLASS]==3 &&
		d->hf[HF_BITS_PER_RGB]==8)
	{
		;
	}
	else {
		goto done;
	}

	// TODO: We could do better by checking more than just the first
	// compression code.
	count = de_getu16be(d->imgpos);
	if(count<1 || count>d->width) {
		goto done;
	}

	d->cmpr_meth = 100;
done:
	if(d->cmpr_meth==100) {
		de_dbg(c, "detected PV-Wave RLE compression");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x90(%rcx), %rax
jne 0x15a3bd
jmp 0x15a47f
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movl $0x3, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x15a3dd
jmp 0x15a47f
movq -0x10(%rbp), %rax
cmpl $0x2, 0xc(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x8, 0x10(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x0, 0x20(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x20, 0x24(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x20, 0x2c(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x8, 0x30(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x3, 0x38(%rax)
jne 0x15a439
movq -0x10(%rbp), %rax
cmpl $0x8, 0x48(%rax)
jne 0x15a439
jmp 0x15a43b
jmp 0x15a47f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rsi
callq 0x1651d0
movq %rax, -0x18(%rbp)
cmpq $0x1, -0x18(%rbp)
jl 0x15a46f
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0xb8(%rcx), %rax
jle 0x15a471
jmp 0x15a47f
movq -0x10(%rbp), %rax
movl $0x64, 0xd8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x64, 0xd8(%rax)
jne 0x15a49e
movq -0x8(%rbp), %rdi
leaq 0x777c7(%rip), %rsi     # 0x1d1c5e
movb $0x0, %al
callq 0x15b0d0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: decompress_pvwave_rle
static void decompress_pvwave_rle(deark *c, lctx *d, dbuf *unc_pixels)
{
	i64 pos = d->imgpos;
	i64 endpos = c->infile->len;
	i64 row_padding;
	i64 nbytes_written = 0;
	i64 xpos = 0;

	row_padding = d->rowspan - d->width;
	if(row_padding<0) goto done;

	while(1) {
		i64 count;
		u8 b;

		if(pos+3 > endpos) goto done;
		if(nbytes_written >= d->expected_image_size) goto done;

		count = de_getu16be_p(&pos);
		b = de_getbyte_p(&pos);
		dbuf_write_run(unc_pixels, b, count);
		nbytes_written += count;
		xpos += count;

		if(xpos >= d->width) {
			if(row_padding!=0 && xpos==d->width) {
				// It's stupid that we have to do this.
				dbuf_write_run(unc_pixels, 0x00, row_padding);
				nbytes_written += row_padding;
			}
			xpos = 0;
		}
	}
done:
	de_dbg(c, "decompressed %"I64_FMT" bytes to %"I64_FMT,
		pos-d->imgpos, nbytes_written);
	dbuf_flush(unc_pixels);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x10(%rbp), %rcx
subq 0xb8(%rcx), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x15a519
jmp 0x15a5e9
jmp 0x15a51b
movq -0x20(%rbp), %rax
addq $0x3, %rax
cmpq -0x28(%rbp), %rax
jle 0x15a52e
jmp 0x15a5e9
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x90(%rcx), %rax
jl 0x15a544
jmp 0x15a5e9
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165210
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165170
movb %al, -0x49(%rbp)
movq -0x18(%rbp), %rdi
movb -0x49(%rbp), %al
movq -0x48(%rbp), %rdx
movzbl %al, %esi
callq 0x168800
movq -0x48(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0xb8(%rcx), %rax
jl 0x15a5e4
cmpq $0x0, -0x30(%rbp)
je 0x15a5dc
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0xb8(%rcx), %rax
jne 0x15a5dc
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rdx
xorl %esi, %esi
callq 0x168800
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
jmp 0x15a51b
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
subq 0x88(%rax), %rdx
movq -0x38(%rbp), %rcx
leaq 0x4473c(%rip), %rsi     # 0x19ed43
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rdi
callq 0x167c30
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/xwd.c
// Function: read_image_colormapped
static void read_image_colormapped(deark *c, lctx *d, dbuf *inf, i64 inf_pos,
	de_bitmap *img)
{
	UI flags = 0;

	if(d->bits_per_pixel<1 || d->bits_per_pixel>8) return;

	if(d->nplanes<=1) {
		if(d->hf[HF_BIT_ORDER]==0) {
			flags |= 0x01;
		}

		de_convert_image_paletted(inf, inf_pos, d->bits_per_pixel,
			d->rowspan, d->pal, img, flags);
	}
	else {
		if(d->hf[HF_BIT_ORDER]==0) {
			flags |= 0x01;
		}

		de_convert_image_paletted_planar(inf, inf_pos, d->nplanes,
			d->rowspan, d->rowspan*d->height, d->pal, img, flags);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x1, 0xb0(%rax)
jl 0x15a83f
movq -0x10(%rbp), %rax
cmpq $0x8, 0xb0(%rax)
jle 0x15a844
jmp 0x15a906
movq -0x10(%rbp), %rax
cmpq $0x1, 0xd0(%rax)
jg 0x15a89f
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x15a865
movl -0x2c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
movq -0x10(%rbp), %r8
addq $0x108, %r8             # imm = 0x108
movq -0x28(%rbp), %r9
movl -0x2c(%rbp), %eax
movl %eax, (%rsp)
callq 0x16c520
jmp 0x15a906
movq -0x10(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jne 0x15a8b2
movl -0x2c(%rbp), %eax
orl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0xd0(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0xc8(%rax), %r8
movq -0x10(%rbp), %rax
imulq 0xc0(%rax), %r8
movq -0x10(%rbp), %r9
addq $0x108, %r9             # imm = 0x108
movq -0x28(%rbp), %r10
movl -0x2c(%rbp), %eax
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x16c690
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-util.c
// Function: de_get_version_string
char *de_get_version_string(char *buf, size_t bufsize)
{
	char extver[32];

	if((DE_VERSION_NUMBER&0x000000ffU) == 0)
		de_strlcpy(extver, "", sizeof(extver));
	else
		de_snprintf(extver, sizeof(extver), "-%u", DE_VERSION_NUMBER&0x000000ff);

	de_snprintf(buf, bufsize, "%u.%u.%u%s%s",
		(DE_VERSION_NUMBER&0xff000000U)>>24,
		(DE_VERSION_NUMBER&0x00ff0000U)>>16,
		(DE_VERSION_NUMBER&0x0000ff00U)>>8,
		extver, DE_VERSION_SUFFIX);

	return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
movl $0x20, %esi
leaq 0x4e652(%rip), %rdx     # 0x1a8f82
movl $0x1, %ecx
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %r10
leaq 0x77494(%rip), %rdx     # 0x1d1de3
movl $0x1, %ecx
movl $0x7, %r8d
xorl %r9d, %r9d
leaq 0x7626c(%rip), %rax     # 0x1d0bd0
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x15a980
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop