LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: do_generate_font
static int do_generate_font(deark *c, lctx *d)
{
	i64 i;
	struct de_encconv_state es;

	if(!d->font) return 0;
	if(d->font->num_chars!=256) {
		de_err(c, "Only 256-character fonts are supported");
		return 0;
	}
	if(d->font_data_len!=d->font->num_chars*d->font_height) {
		de_err(c, "Incorrect font data size");
		return 0;
	}
	d->font->nominal_width = 8;
	d->font->nominal_height = (int)d->font_height;
	d->font->char_array = de_mallocarray(c, d->font->num_chars, sizeof(struct de_bitmap_font_char));
	de_encconv_init(&es, DE_ENCODING_CP437_G);

	for(i=0; i<d->font->num_chars; i++) {
		d->font->char_array[i].codepoint_nonunicode = (i32)i;
		d->font->char_array[i].codepoint_unicode = de_char_to_unicode_ex((i32)i, &es);
		d->font->char_array[i].width = d->font->nominal_width;
		d->font->char_array[i].height = d->font->nominal_height;
		d->font->char_array[i].rowspan = 1;
		d->font->char_array[i].bitmap = &d->font_data[i*d->font_height];
	}

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq 0x28(%rsi), %rax
testq %rax, %rax
je 0x30d1d
cmpq $0x100, 0x18(%rax)      # imm = 0x100
jne 0x30d21
movq %rsi, %rbx
movq 0x8(%rsi), %rcx
movq %rcx, %rdx
shlq $0x8, %rdx
cmpq %rdx, 0x10(%rsi)
jne 0x30d2a
movl $0x8, (%rax)
movl %ecx, 0x4(%rax)
pushq $0x28
popq %rdx
movl $0x100, %esi            # imm = 0x100
callq 0xdf66f
movq 0x28(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq %rsp, %r14
pushq $0xd
popq %rsi
movq %r14, %rdi
callq 0xe11fc
movq 0x28(%rbx), %rcx
xorl %r12d, %r12d
pushq $0x1
popq %rbp
xorl %r15d, %r15d
cmpq 0x18(%rcx), %r15
jge 0x30d3a
movq 0x20(%rcx), %rax
movl %r15d, (%rax,%r12)
movl %r15d, %edi
movq %r14, %rsi
callq 0xe1679
movq 0x28(%rbx), %rcx
movq 0x20(%rcx), %rdx
movl %eax, 0x4(%rdx,%r12)
movq (%rcx), %rax
movq %rax, 0x8(%rdx,%r12)
movq $0x1, 0x18(%rdx,%r12)
movq 0x8(%rbx), %rax
imulq %r15, %rax
addq 0x18(%rbx), %rax
movq %rax, 0x20(%rdx,%r12)
incq %r15
addq $0x28, %r12
jmp 0x30ccc
xorl %ebp, %ebp
jmp 0x30d3a
leaq 0xd951c(%rip), %rsi     # 0x10a244
jmp 0x30d31
leaq 0xd953a(%rip), %rsi     # 0x10a26b
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xdf2a5
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: do_extract_font
static void do_extract_font(deark *c, lctx *d)
{
	de_finfo *fi = NULL;

	if(!d->has_font || !d->font) return;
	fi = de_finfo_create(c);
	de_finfo_set_name_from_sz(c, fi, "font", 0, DE_ENCODING_ASCII);

	de_font_bitmap_font_to_image(c, d->font, fi, DE_CREATEFLAG_IS_AUX);

	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpb $0x0, 0x3(%rsi)
je 0x30dab
movq %rsi, %r14
cmpq $0x0, 0x28(%rsi)
je 0x30dab
movq %rdi, %rbx
callq 0xdfd1a
movq %rax, %r15
leaq 0xf8706(%rip), %rdx     # 0x129478
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %rax, %rsi
xorl %ecx, %ecx
movl %ebp, %r8d
callq 0xdffbd
movq 0x28(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xea0f6
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xdfd24
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: free_lctx
static void free_lctx(deark *c, lctx *d)
{
	if(d->font) {
		de_free(c, d->font->char_array);
		de_destroy_bitmap_font(c, d->font);
	}
	de_free(c, d->font_data);
	de_free(c, d);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x28(%rsi), %rax
testq %rax, %rax
je 0x30de1
movq 0x20(%rax), %rsi
movq %r14, %rdi
callq 0xded32
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0xe9d28
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0xded32
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xded32
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: tdc_decrunch_emit_char
static void tdc_decrunch_emit_char(deark *c, struct thedrawcom_ctx *tdc, u8 ch)
{
	if(!tdc->dc.prescan_mode) {
		dbuf_writebyte(tdc->unc_data, ch);
		dbuf_writebyte(tdc->unc_data, (u8)(tdc->dc.curr_blink_code |
			tdc->dc.curr_bg_code | tdc->dc.curr_fg_code));
	}
	if(tdc->dc.next_xpos > tdc->dc.max_xpos) {
		tdc->dc.max_xpos = tdc->dc.next_xpos;
	}
	if(tdc->dc.next_ypos > tdc->dc.max_ypos) {
		tdc->dc.max_ypos = tdc->dc.next_ypos;
	}
	if(ch!=0 && ch!=32 && tdc->dc.next_ypos>tdc->dc.ypos_of_last_nonblank) {
		tdc->dc.ypos_of_last_nonblank = tdc->dc.next_ypos;
	}
	tdc->dc.next_xpos++;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpb $0x0, 0x58(%rdi)
jne 0x31098
movq 0x10(%rbx), %rdi
movzbl %bpl, %esi
callq 0xe5bc5
movb 0x5a(%rbx), %al
orb 0x5b(%rbx), %al
movq 0x10(%rbx), %rdi
orb 0x59(%rbx), %al
movzbl %al, %esi
callq 0xe5bc5
movq 0x60(%rbx), %rax
cmpq 0x70(%rbx), %rax
jle 0x310a6
movq %rax, 0x70(%rbx)
movq 0x68(%rbx), %rcx
cmpq 0x78(%rbx), %rcx
jle 0x310b4
movq %rcx, 0x78(%rbx)
testb $-0x21, %bpl
je 0x310ca
cmpq 0x80(%rbx), %rcx
jle 0x310ca
movq %rcx, 0x80(%rbx)
incq %rax
movq %rax, 0x60(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: aciddraw_id
static void aciddraw_id(deark *c, u8 b0, struct aciddraw_id_data *adi)
{
	de_zeromem(adi, sizeof(struct aciddraw_id_data));
	if(b0==0xe9) {
		adi->jmppos = de_geti16le(1) + 3;
	}
	else if(b0==0xeb) {
		adi->jmppos = de_getbyte(1) + 2;
	}
	else {
		return;
	}

	if(dbuf_memcmp(c->infile, adi->jmppos,
		(const void*)"\xb8\x03\x00\xcd\x10\xb4\x01\xb9\x00\x20\xcd\x10\xe8", 13))
	{
		return;
	}
	adi->is_aciddraw = 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
cmpl $0xeb, %esi
je 0x3110d
cmpl $0xe9, %esi
jne 0x3113e
movq 0x18(%r14), %rdi
pushq $0x1
popq %rsi
callq 0xe400a
movq %rax, %rsi
addq $0x3, %rsi
jmp 0x31120
movq 0x18(%r14), %rdi
pushq $0x1
popq %rsi
callq 0xe3eb4
movzbl %al, %esi
addq $0x2, %rsi
movq %rsi, 0x8(%rbx)
movq 0x18(%r14), %rdi
leaq 0xd8e1f(%rip), %rdx     # 0x109f4e
pushq $0xd
popq %rcx
callq 0xe4d48
testl %eax, %eax
jne 0x3113e
movb $0x1, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bintext.c
// Function: grabber_id_com
static void grabber_id_com(deark *c, u8 b0, struct grabber_id_data *gi)
{
	de_zeromem(gi, sizeof(struct grabber_id_data));

	if(b0==0xfb) {
		if(!dbuf_memcmp(c->infile, 1,
			(const void*)"\xbe\x81\x00\x8a\x4c\xff\x30\xed\x09\xc9\x74", 11)) {
			gi->is_grabber = 1;
			gi->fmt_class = 200;
		}
		return;
	}

	if(b0!=0xe9) return;
	gi->jmppos = de_geti16le(1) + 3;

	if(!dbuf_memcmp(c->infile, gi->jmppos,
		(const void*)"\xbe\x81\x00\xad\x80\xfc\x0d\x74\x17\x3c\x0d\x74", 12))
	{
		gi->is_grabber = 1;
		gi->fmt_class = 300;
		return;
	}
	if(!dbuf_memcmp(c->infile, gi->jmppos,
		(const void*)"\xbe\x81\x00\xfc\xad\x80\xfc\x0d\x74\x1c\x3c\x0d\x74", 13))
	{
		gi->is_grabber = 1;
		gi->fmt_class = 334;
		return;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rdx)
cmpl $0xe9, %esi
je 0x31187
cmpl $0xfb, %esi
jne 0x311df
movq 0x18(%r14), %rdi
leaq 0xd8deb(%rip), %rdx     # 0x109f5c
pushq $0x1
popq %rsi
pushq $0xb
popq %rcx
callq 0xe4d48
testl %eax, %eax
jne 0x311df
movl $0xc8, %eax
jmp 0x311d9
movq 0x18(%r14), %rdi
pushq $0x1
popq %rsi
callq 0xe400a
leaq 0x3(%rax), %rsi
movq %rsi, 0x8(%rbx)
movq 0x18(%r14), %rdi
leaq 0xd8dc2(%rip), %rdx     # 0x109f68
pushq $0xc
popq %rcx
callq 0xe4d48
testl %eax, %eax
je 0x311d4
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0xd8db4(%rip), %rdx     # 0x109f75
pushq $0xd
popq %rcx
callq 0xe4d48
testl %eax, %eax
jne 0x311df
movl $0x14e, %eax            # imm = 0x14E
jmp 0x311d9
movl $0x12c, %eax            # imm = 0x12C
movb $0x1, (%rbx)
movl %eax, 0x4(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmi.c
// Function: de_module_bmi
void de_module_bmi(deark *c, struct deark_module_info *mi)
{
	mi->id = "bmi";
	mi->desc = "Zoner BMI bitmap";
	mi->run_fn = de_run_bmi;
	mi->identify_fn = de_identify_bmi;
}

// Assembly:
leaq 0xd9399(%rip), %rax     # 0x10a588
movq %rax, (%rsi)
leaq 0xd9393(%rip), %rax     # 0x10a58c
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0x31214
movq %rax, 0x18(%rsi)
leaq 0x707(%rip), %rax       # 0x31916
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmi.c
// Function: read_palette
static void read_palette(deark *c, lctx *d, struct imageinfo *ii, i64 pos1)
{
	if(ii->num_pal_entries<1) return;
	de_dbg(c, "palette at %"I64_FMT", %d entries", pos1, (int)ii->num_pal_entries);
	de_dbg_indent(c, 1);
	de_read_palette_rgb(c->infile, pos1, ii->num_pal_entries, 4,
		ii->pal, 256, DE_GETRGBFLAG_BGR);
	de_dbg_indent(c, -1);
}

// Assembly:
movq 0x20(%rsi), %rcx
testq %rcx, %rcx
jle 0x319a7
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xd8c69(%rip), %rsi     # 0x10a5c3
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq 0x20(%r14), %rdx
addq $0x28, %r14
movl $0x1, (%rsp)
pushq $0x4
popq %rcx
movl $0x100, %r9d            # imm = 0x100
movq %r15, %rsi
movq %r14, %r8
callq 0xe7963
pushq $-0x1
popq %rsi
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0xdeba7
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_bmp
void de_module_bmp(deark *c, struct deark_module_info *mi)
{
	mi->id = "bmp";
	mi->desc = "BMP (Windows or OS/2 bitmap)";
	mi->run_fn = de_run_bmp;
	mi->identify_fn = de_identify_bmp;
}

// Assembly:
leaq 0xe26c3(%rip), %rax     # 0x114072
movq %rax, (%rsi)
leaq 0xd8ea7(%rip), %rax     # 0x10a860
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0x319d4
movq %rax, 0x18(%rsi)
leaq 0x180b(%rip), %rax      # 0x331da
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_identify_bmp
static int de_identify_bmp(deark *c)
{
	i64 fsize;
	i64 bits_offset;
	i64 infohdrsize;
	u32 compression_field = 0;
	int bmp_ext;
	u8 buf[6];

	de_read(buf, 0, sizeof(buf));
	if(de_memcmp(buf, "BM", 2)) {
		return 0;
	}

	bmp_ext = de_input_file_has_ext(c, "bmp");
	fsize = de_getu32le_direct(&buf[2]);
	bits_offset = de_getu32le(10);
	infohdrsize = de_getu32le(14);
	if(infohdrsize>=20) {
		compression_field = (u32)de_getu32le(14+16);
		// Don't detect KQP format as BMP
		if(infohdrsize==68 && compression_field==0x4745504aU) return 0;
	}

	if(infohdrsize<12) return 0;
	if(infohdrsize>256) return 0;
	if(bits_offset>=c->infile->len) return 0;
	if(bits_offset<14+infohdrsize) return 0;
	if(fsize==c->infile->len && bmp_ext) return 100;
	if(buf[2]==0xcb) {
		// Possible VBM file.
		// Windows BMP files are highly unlikely to start with 'B' 'M' \xcb,
		// because that would imply the file is an odd number of bytes in size,
		// which is legal but silly.
		if(bmp_ext) return 90;
		return 5;
	}

	if(bmp_ext) return 100;
	if(infohdrsize==12 || infohdrsize==40 || infohdrsize==108 ||
		infohdrsize==124)
	{
		return 100;
	}
	return 90;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rdi
xorl %ebx, %ebx
leaq 0x2(%rsp), %r15
pushq $0x6
popq %rcx
movq %r15, %rsi
xorl %edx, %edx
callq 0xe3cb7
cmpw $0x4d42, (%r15)         # imm = 0x4D42
je 0x33219
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xe0e52(%rip), %rsi     # 0x114072
movq %r14, %rdi
callq 0xdfcd5
movl %eax, %ebp
leaq 0x4(%rsp), %rdi
callq 0xe409c
movq %rax, %r12
movq 0x18(%r14), %rdi
pushq $0xa
popq %rsi
callq 0xe409f
movq %rax, %r13
movq 0x18(%r14), %rdi
pushq $0xe
popq %rsi
callq 0xe409f
movq %rax, %r15
cmpq $0x14, %rax
jl 0x3328e
movq 0x18(%r14), %rdi
pushq $0x1e
popq %rsi
callq 0xe409f
movq %r15, %rcx
xorq $0x44, %rcx
movl %eax, %eax
xorq $0x4745504a, %rax       # imm = 0x4745504A
orq %rcx, %rax
sete %al
cmpq $0x100, %r15            # imm = 0x100
ja 0x33208
testb %al, %al
je 0x33298
jmp 0x33208
cmpq $0xc, %r15
jl 0x33208
movq 0x18(%r14), %rax
movq 0x18(%rax), %rax
cmpq %rax, %r13
setge %cl
leaq 0xe(%r15), %rdx
cmpq %rdx, %r13
setl %dl
orb %cl, %dl
jne 0x33208
cmpq %rax, %r12
sete %al
testl %ebp, %ebp
setne %cl
pushq $0x64
popq %rbx
testb %cl, %al
jne 0x33208
cmpb $-0x35, 0x4(%rsp)
jne 0x332e5
testl %ebp, %ebp
pushq $0x5a
popq %rax
pushq $0x5
popq %rbx
cmovnel %eax, %ebx
jmp 0x33208
testl %ebp, %ebp
jne 0x33208
movabsq $0x7fffffffffffffef, %rax # imm = 0x7FFFFFFFFFFFFFEF
andq %r15, %rax
cmpq $0x6c, %rax
je 0x33208
cmpq $0xc, %r15
pushq $0x64
popq %rax
pushq $0x5a
popq %rbx
cmovel %eax, %ebx
cmpq $0x28, %r15
cmovel %eax, %ebx
jmp 0x33208
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_picjpeg
void de_module_picjpeg(deark *c, struct deark_module_info *mi)
{
	mi->id = "picjpeg";
	mi->desc = "Pegasus JPEG, and KQP";
	mi->run_fn = de_run_picjpeg;
	mi->identify_fn = de_identify_picjpeg;
	mi->id_alias[0] = "kqp";
}

// Assembly:
leaq 0xd7559(%rip), %rax     # 0x10a87d
movq %rax, (%rsi)
leaq 0xd7557(%rip), %rax     # 0x10a885
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0x33354
movq %rax, 0x18(%rsi)
leaq 0x6ab(%rip), %rax       # 0x339ef
movq %rax, 0x20(%rsi)
leaq 0xd754c(%rip), %rax     # 0x10a89b
movq %rax, 0x38(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_identify_picjpeg
static int de_identify_picjpeg(deark *c)
{
	if(dbuf_memcmp(c->infile, 0, (const void*)"BM", 2)) return 0;
	if(de_getu32le(14) != 68) return 0;
	if((UI)de_getu32le(30) != 0x4745504aU) return 0;
	return 100;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rdi
leaq 0xdb61d(%rip), %rdx     # 0x10f01e
xorl %ebx, %ebx
pushq $0x2
popq %rcx
xorl %esi, %esi
callq 0xe4d48
testl %eax, %eax
jne 0x33a3c
movq 0x18(%r14), %rdi
pushq $0xe
popq %rsi
callq 0xe409f
cmpq $0x44, %rax
jne 0x33a3c
movq 0x18(%r14), %rdi
pushq $0x1e
popq %rsi
callq 0xe409f
xorl %ecx, %ecx
cmpl $0x4745504a, %eax       # imm = 0x4745504A
pushq $0x64
popq %rbx
cmovnel %ecx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_dib
void de_module_dib(deark *c, struct deark_module_info *mi)
{
	mi->id = "dib";
	mi->desc = "DIB (raw Windows bitmap)";
	mi->run_fn = de_run_dib;
	mi->identify_fn = de_identify_dib;
}

// Assembly:
leaq 0xe2802(%rip), %rax     # 0x11624f
movq %rax, (%rsi)
leaq 0xd6e48(%rip), %rax     # 0x10a89f
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0x33a72
movq %rax, 0x18(%rsi)
leaq 0x133(%rip), %rax       # 0x33ba0
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_run_dib
static void de_run_dib(deark *c, de_module_params *mparams)
{
	struct de_bmpinfo bi;
	UI createflags = 0;
	dbuf *outf = NULL;
	int implicit_size = 0;
	i64 dib_len;
	const char *ext = "bmp";
	de_finfo *fi_to_use = NULL;

	if(mparams) {
		// If flags&0x01, try to calculate the proper file size, instead of trusting
		// the length of the input file.
		if(mparams->in_params.flags & 0x01) implicit_size = 1;

		if(mparams->in_params.flags & 0x80) ext = "preview.bmp";

		fi_to_use = mparams->in_params.fi;
	}

	if(de_havemodcode(c, mparams, 'X')) {
		createflags |= DE_CREATEFLAG_IS_AUX;
	}

	if(!fmtutil_get_bmpinfo(c, c->infile, &bi, 0, c->infile->len, 0)) {
		de_err(c, "Invalid DIB, or not a DIB file");
		goto done;
	}

	if(implicit_size) {
		dib_len = bi.total_size;
		if(dib_len > c->infile->len) {
			dib_len = c->infile->len;
		}
	}
	else {
		dib_len = c->infile->len;
	}

	outf = dbuf_create_output_file(c, ext, fi_to_use, createflags);

	de_dbg(c, "writing a BMP FILEHEADER");
	fmtutil_generate_bmpfileheader(c, outf, &bi, 14+dib_len);

	de_dbg(c, "copying DIB file");
	dbuf_copy(c->infile, 0, dib_len, outf);

done:
	dbuf_close(outf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
je 0x33aae
movl 0x8(%rsi), %eax
testb $0x1, %al
sete %r12b
testb %al, %al
leaq 0xe05d5(%rip), %rax     # 0x114072
leaq 0xd72bf(%rip), %r14     # 0x10ad63
cmovnsq %rax, %r14
movq 0x28(%rsi), %r15
jmp 0x33abb
leaq 0xe05bd(%rip), %r14     # 0x114072
movb $0x1, %r12b
xorl %r15d, %r15d
pushq $0x58
popq %rdx
movq %rbx, %rdi
callq 0xdfcf4
xorl %ebp, %ebp
testl %eax, %eax
setne %r13b
movq 0x18(%rbx), %rsi
movq 0x18(%rsi), %r8
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0xebba5
testl %eax, %eax
je 0x33afe
movb %r13b, %bpl
testb %r12b, %r12b
je 0x33b14
movq 0x18(%rbx), %rax
movq 0x18(%rax), %r12
jmp 0x33b2b
leaq 0xd726a(%rip), %rsi     # 0x10ad6f
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x33b86
movq 0x98(%rsp), %rax
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %r12
cmpq %r12, %rax
cmovlq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xe4e62
movq %rax, %r14
leaq 0xd7249(%rip), %rsi     # 0x10ad8e
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
leaq 0xe(%r12), %rcx
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xec053
leaq 0xd723c(%rip), %rsi     # 0x10ada7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r14, %rcx
callq 0xe45f4
movq %r14, %rdi
callq 0xe5591
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_identify_dib
static int de_identify_dib(deark *c)
{
	i64 n;

	n = de_getu32le(0); // biSize
	if(n!=40) return 0;
	n = de_getu16le(12); // biPlanes
	if(n!=1) return 0;
	n = de_getu16le(14); // biBitCount
	if(n==1 || n==4 || n==8 || n==16 || n==24 || n==32) return 15;
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rdi
xorl %ebx, %ebx
xorl %esi, %esi
callq 0xe409f
cmpq $0x28, %rax
jne 0x33bf1
movq 0x18(%r14), %rdi
pushq $0xc
popq %rsi
callq 0xe3fa3
cmpq $0x1, %rax
jne 0x33bf1
movq 0x18(%r14), %rdi
pushq $0xe
popq %rsi
callq 0xe3fa3
cmpq $0x20, %rax
ja 0x33bf1
movabsq $0x101010112, %rcx      # imm = 0x101010112
btq %rax, %rcx
jae 0x33bf1
pushq $0xf
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_ddb
void de_module_ddb(deark *c, struct deark_module_info *mi)
{
	mi->id = "ddb";
	mi->desc = "Windows DDB bitmap";
	mi->run_fn = de_run_ddb;
	mi->identify_fn = NULL;
	mi->flags |= DE_MODFLAG_HIDDEN;
}

// Assembly:
leaq 0xe260b(%rip), %rax     # 0x11620d
movq %rax, (%rsi)
leaq 0xd6cac(%rip), %rax     # 0x10a8b8
movq %rax, 0x8(%rsi)
leaq 0xe(%rip), %rax         # 0x33c25
movq %rax, 0x18(%rsi)
andq $0x0, 0x20(%rsi)
orb $0x1, 0x30(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_winzle
void de_module_winzle(deark *c, struct deark_module_info *mi)
{
	mi->id = "winzle";
	mi->desc = "Winzle! puzzle image";
	mi->run_fn = de_run_winzle;
	mi->identify_fn = de_identify_winzle;
}

// Assembly:
leaq 0xd67d8(%rip), %rax     # 0x10a8cb
movq %rax, (%rsi)
leaq 0xd67d5(%rip), %rax     # 0x10a8d2
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0x34118
movq %rax, 0x18(%rsi)
leaq 0xb2(%rip), %rax        # 0x341c5
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_run_winzle
static void de_run_winzle(deark *c, de_module_params *mparams)
{
	u8 buf[256];
	i64 xorsize;
	i64 i;
	dbuf *f = NULL;

	xorsize = c->infile->len >= 256 ? 256 : c->infile->len;
	de_read(buf, 0, xorsize);
	for(i=0; i<xorsize; i++) {
		buf[i] ^= 0x0d;
	}

	f = dbuf_create_output_file(c, "bmp", NULL, 0);
	dbuf_write(f, buf, xorsize);
	if(c->infile->len > 256) {
		dbuf_copy(c->infile, 256, c->infile->len - 256, f);
	}
	dbuf_close(f);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movq 0x18(%rdi), %rax
movl $0x100, %r14d           # imm = 0x100
cmpq %r14, %rax
cmovlq %rax, %r14
xorl %r15d, %r15d
movq %rsp, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0xe3cb7
testq %r14, %r14
movl $0x0, %eax
cmovgq %r14, %rax
cmpq %r15, %rax
je 0x34167
xorb $0xd, (%rsp,%r15)
incq %r15
jmp 0x34158
leaq 0xdff04(%rip), %rsi     # 0x114072
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r15
movq %rsp, %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0xe46ba
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rdx
cmpq $0x101, %rdx            # imm = 0x101
jl 0x341b0
addq $-0x100, %rdx
movl $0x100, %esi            # imm = 0x100
movq %r15, %rcx
callq 0xe45f4
movq %r15, %rdi
callq 0xe5591
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_module_jigsaw_wk
void de_module_jigsaw_wk(deark *c, struct deark_module_info *mi)
{
	mi->id = "jigsaw_wk";
	mi->desc = "Jigsaw .jig";
	mi->run_fn = de_run_jigsaw_wk;
	mi->identify_fn = de_identify_jigsaw_wk;
}

// Assembly:
leaq 0xd66d4(%rip), %rax     # 0x10a8e7
movq %rax, (%rsi)
leaq 0xd66d4(%rip), %rax     # 0x10a8f1
movq %rax, 0x8(%rsi)
leaq 0x10(%rip), %rax        # 0x34238
movq %rax, 0x18(%rsi)
leaq 0x83(%rip), %rax        # 0x342b6
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_run_jigsaw_wk
static void de_run_jigsaw_wk(deark *c, de_module_params *mparams)
{
	i64 fsize;
	dbuf *outf = NULL;

	fsize = de_getu32le(2);
	if(fsize>c->infile->len) goto done;

	outf = dbuf_create_output_file(c, "bmp", NULL, 0);
	dbuf_write(outf, (const u8*)"BM", 2);
	dbuf_copy(c->infile, 2, fsize-2, outf);

done:
	dbuf_close(outf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
pushq $0x2
popq %rsi
callq 0xe409f
movq %rax, %r14
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r14
jle 0x34261
xorl %r15d, %r15d
jmp 0x342a3
leaq 0xdfe0a(%rip), %rsi     # 0x114072
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xe4e62
movq %rax, %r15
leaq 0xdada0(%rip), %rsi     # 0x10f01e
pushq $0x2
popq %r12
movq %rax, %rdi
movq %r12, %rdx
callq 0xe46ba
movq 0x18(%rbx), %rdi
addq $-0x2, %r14
movq %r12, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0xe45f4
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xe5591
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: de_identify_jigsaw_wk
static int de_identify_jigsaw_wk(deark *c)
{
	i64 fsize;
	int ret;
	u8 buf[32];

	if(dbuf_memcmp(c->infile, 0, "JG", 2)) {
		return 0;
	}

	fsize = de_getu32le(2);
	if(fsize>c->infile->len) return 0;

	de_read(buf, 0, sizeof(buf));
	buf[0] = 'B';
	buf[1] = 'M';
	ret = looks_like_bmp_bytes(buf, sizeof(buf), 0);
	if(ret) {
		return 95;
	}

	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq 0x18(%rdi), %rdi
leaq 0xd6b89(%rip), %rdx     # 0x10ae54
xorl %ebx, %ebx
pushq $0x2
popq %rcx
xorl %esi, %esi
callq 0xe4d48
testl %eax, %eax
jne 0x34326
movq 0x18(%r14), %rdi
pushq $0x2
popq %rsi
callq 0xe409f
movq 0x18(%r14), %rdi
cmpq 0x18(%rdi), %rax
jg 0x34326
movq %rsp, %rbx
pushq $0x20
popq %rcx
movq %rbx, %rsi
xorl %edx, %edx
callq 0xe3cb7
movw $0x4d42, (%rbx)         # imm = 0x4D42
leaq 0xd6517(%rip), %rsi     # 0x10a824
pushq $0x1e
popq %rdx
pushq $0x3f
popq %rcx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0xe0fff
testl %eax, %eax
pushq $0x5f
popq %rbx
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: do_read_bitfields
static void do_read_bitfields(deark *c, lctx *d, i64 pos, i64 len)
{
	i64 k;

	if(len>16) len=16;
	for(k=0; 4*k<len; k++) {
		d->bitfield[k].mask = (u32)de_getu32le(pos+4*k);
		de_dbg(c, "mask[%d]: 0x%08x", (int)k, (UI)d->bitfield[k].mask);
	}
	update_bitfields_info(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
cmpq $0x10, %rcx
pushq $0x10
popq %r13
cmovlq %rcx, %r13
movq %rdi, %r15
xorl %ebp, %ebp
xorl %r12d, %r12d
cmpq %r13, %r12
jge 0x3438c
movq 0x18(%r15), %rdi
leaq (%r14,%r12), %rsi
callq 0xe409f
movl %eax, 0x100(%rbx,%r12,4)
movq %r15, %rdi
leaq 0xd67d4(%rip), %rsi     # 0x10ab4d
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
addq $0x4, %r12
incl %ebp
jmp 0x34355
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3439f
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: update_bitfields_info
static void update_bitfields_info(deark *c, lctx *d)
{
	i64 k;
	u32 tmpmask;

	for(k=0; k<4; k++) {
		tmpmask = d->bitfield[k].mask;
		if(tmpmask==0) continue;
		while((tmpmask & 0x1) == 0) {
			d->bitfield[k].shift++;
			tmpmask >>= 1;
		}
		d->bitfield[k].scale = 255.0 / (double)tmpmask;
	}
}

// Assembly:
addq $0x100, %rdi            # imm = 0x100
xorl %eax, %eax
movsd 0xd6398(%rip), %xmm0    # 0x10a748
cmpq $0x4, %rax
je 0x343ec
movq %rax, %rcx
shlq $0x4, %rcx
movl (%rdi,%rcx), %edx
testl %edx, %edx
je 0x343e7
addq %rdi, %rcx
testb $0x1, %dl
jne 0x343d3
incl 0x4(%rcx)
shrl %edx
jmp 0x343c7
movl %edx, %edx
cvtsi2sd %rdx, %xmm1
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rcx)
incq %rax
jmp 0x343b0
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: do_image_paletted
static void do_image_paletted(deark *c, lctx *d, dbuf *bits, i64 bits_offset, u8 want_trns)
{
	int bypp;

	if(d->pal_is_grayscale) bypp = 1;
	else bypp = 3;
	if(want_trns) bypp++;

	d->img = bmp_bitmap_create(c, d, bypp);
	de_convert_image_paletted(bits, bits_offset,
		d->bitcount, d->rowspan, d->pal, d->img, 0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
xorl %eax, %eax
cmpl $0x0, 0x88(%rsi)
sete %al
xorl %ecx, %ecx
testl %r8d, %r8d
setne %cl
leal (%rcx,%rax,2), %edx
incl %edx
callq 0x34566
movq %rax, 0x10(%rbx)
movq 0x38(%rbx), %rdx
movq 0xf8(%rbx), %rcx
addq $0x140, %rbx            # imm = 0x140
andl $0x0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %r8
movq %rax, %r9
callq 0xe7cbc
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: do_image_24bit
static void do_image_24bit(deark *c, lctx *d, dbuf *bits, i64 bits_offset, u8 want_trns)
{
	i64 i, j;
	u32 clr;
	int bypp;

	if(want_trns) bypp = 4;
	else bypp = 3;

	d->img = bmp_bitmap_create(c, d, bypp);
	for(j=0; j<d->height; j++) {
		i64 rowpos = bits_offset + j*d->rowspan;
		i64 pos_in_this_row = 0;
		u8 cbuf[3];

		for(i=0; i<d->pdwidth; i++) {
			dbuf_read(bits, cbuf, rowpos + pos_in_this_row, 3);
			if(pos_in_this_row+3 > d->rowspan) {
				// If -padpix was used, a partial pixel at the end of the row is
				// possible. Happens when width == 1 or 2 (mod 4).
				// To handle that, zero out the byte(s) that we shouldn't have read.
				cbuf[2] = 0;
				if(pos_in_this_row+2 > d->rowspan) {
					cbuf[1] = 0;
				}
			}
			clr = DE_MAKE_RGB(cbuf[2], cbuf[1], cbuf[0]);
			de_bitmap_setpixel_rgb(d->img, i, j, clr);
			pos_in_this_row += 3;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %r14
movq %rsi, %r15
cmpl $0x1, %r8d
pushq $0x4
popq %rdx
sbbl $0x0, %edx
callq 0x34566
movq %rax, 0x10(%r15)
xorl %r12d, %r12d
cmpq 0x60(%r15), %r12
jge 0x34515
movq 0xf8(%r15), %r13
imulq %r12, %r13
addq 0x10(%rsp), %r13
pushq $0x2
popq %rbp
xorl %ebx, %ebx
cmpq 0x58(%r15), %rbx
jge 0x3450d
leaq -0x2(,%rbp), %rdx
addq %r13, %rdx
movq %r14, %rdi
leaq 0xd(%rsp), %rsi
pushq $0x3
popq %rcx
callq 0xe3cb7
leaq 0x1(%rbp), %rcx
movq 0xf8(%r15), %rax
cmpq %rax, %rcx
jle 0x344e0
movb $0x0, 0xf(%rsp)
cmpq %rax, %rbp
jle 0x344e0
movb $0x0, 0xe(%rsp)
movzwl 0xe(%rsp), %eax
shll $0x8, %eax
movzbl 0xd(%rsp), %ecx
orl %eax, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movq 0x10(%r15), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0xe7287
incq %rbx
addq $0x3, %rbp
jmp 0x344a0
incq %r12
jmp 0x34481
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: extract_embedded_image
static void extract_embedded_image(deark *c, lctx *d, const char *ext)
{
	i64 nbytes;

	if(d->want_returned_img) return;

	nbytes = get_bits_size(c, d);
	if(nbytes<1) return;

	dbuf_create_file_from_slice(c->infile, d->bits_offset, nbytes, ext, NULL, 0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
cmpb $0x0, 0x4(%rsi)
je 0x34535
popq %rbx
popq %r14
popq %r15
retq
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x346c1
testq %rax, %rax
jle 0x3452f
movq 0x18(%r15), %rdi
movq 0x28(%r14), %rsi
movq %rax, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
popq %rbx
popq %r14
popq %r15
jmp 0xe4e0b
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: rle_to_bytes_append_unit4
static void rle_to_bytes_append_unit4(deark *c, struct rle_dcmpr_ctx *rc, u8 n, u8 mflag)
{
	if(rc->num_pending_bits) { // presumably = 4
		rc->pending_bits |= n;
		rc->num_pending_bits += 4;
		rle_to_bytes_flush(c, rc);
	}
	else { // presumably num_pending_bits = 0
		rc->pending_bits = n<<4;
		rc->num_pending_bits += 4;
	}

	if(mflag && rc->mask) {
		de_bitmap_setpixel_gray(rc->mask, rc->xpos, rc->ypos, 0xff);
	}
	rc->xpos++;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rdi, %rbx
movl 0x60(%rdi), %eax
testl %eax, %eax
je 0x345c7
orb %sil, 0x64(%rbx)
addl $0x4, %eax
movl %eax, 0x60(%rbx)
movq %rbx, %rdi
callq 0x346a0
jmp 0x345d6
shlb $0x4, %sil
movb %sil, 0x64(%rbx)
movl $0x4, 0x60(%rbx)
testb %bpl, %bpl
je 0x345f6
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x345f6
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movl $0xff, %ecx
callq 0xe71da
incq 0x50(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: rle_to_bytes_append_unit24
static void rle_to_bytes_append_unit24(deark *c, struct rle_dcmpr_ctx *rc,
	u8 cr, u8 cg, u8 cb, u8 mflag)
{
	dbuf_writebyte(rc->unc_pixels, cb);
	dbuf_writebyte(rc->unc_pixels, cg);
	dbuf_writebyte(rc->unc_pixels, cr);
	if(mflag && rc->mask) {
		de_bitmap_setpixel_gray(rc->mask, rc->xpos, rc->ypos, 0xff);
	}
	rc->xpos++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
movl %ecx, %esi
callq 0xe5bc5
movq 0x40(%rbx), %rdi
movl %r14d, %esi
callq 0xe5bc5
movq 0x40(%rbx), %rdi
movl %r15d, %esi
callq 0xe5bc5
testl %ebp, %ebp
je 0x34656
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x34656
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movl $0xff, %ecx
callq 0xe71da
incq 0x50(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: rle_to_bytes_append_unit8
static void rle_to_bytes_append_unit8(deark *c, struct rle_dcmpr_ctx *rc, u8 n, u8 mflag)
{
	dbuf_writebyte(rc->unc_pixels, n);
	if(mflag && rc->mask) {
		de_bitmap_setpixel_gray(rc->mask, rc->xpos, rc->ypos, 0xff);
	}
	rc->xpos++;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
callq 0xe5bc5
testl %ebp, %ebp
je 0x34695
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x34695
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
movl $0xff, %ecx
callq 0xe71da
incq 0x50(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: rle_to_bytes_flush
static void rle_to_bytes_flush(deark *c, struct rle_dcmpr_ctx *rc)
{
	if(rc->num_pending_bits) {
		dbuf_writebyte(rc->unc_pixels, rc->pending_bits);
	}
	rc->pending_bits = 0;
	rc->num_pending_bits = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x60(%rdi)
je 0x346b7
movq 0x40(%rbx), %rdi
movzbl 0x64(%rbx), %esi
callq 0xe5bc5
movb $0x0, 0x64(%rbx)
andl $0x0, 0x60(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bmp.c
// Function: picjpeg_scale_qtable
static void picjpeg_scale_qtable(u8 tbl[64], UI setting)
{
	size_t i;

	for(i=0; i<64; i++) {
		UI x;

		x = tbl[i];
		// The denominator 32 might not be exactly right, but assuming this is
		// the right idea, it's not too far off.
		x = (x * setting)/32;
		if(x>255) x = 255;
		else if(x<1) x = 1;
		tbl[i] = x;
	}
}

// Assembly:
xorl %eax, %eax
pushq $0x1
popq %rcx
movl $0xff, %edx
cmpq $0x40, %rax
je 0x3472f
movzbl (%rdi,%rax), %r8d
imull %esi, %r8d
movl %r8d, %r9d
shrl $0x5, %r9d
cmpl $0x20, %r8d
cmovbl %ecx, %r9d
cmpl $0x2000, %r8d           # imm = 0x2000
cmovael %edx, %r9d
movb %r9b, (%rdi,%rax)
incq %rax
jmp 0x346fd
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: de_module_arj
void de_module_arj(deark *c, struct deark_module_info *mi)
{
	mi->id = "arj";
	mi->desc = "ARJ";
	mi->run_fn = de_run_arj;
	mi->identify_fn = de_identify_arj;
	mi->help_fn = de_help_arj;
	mi->flags |= DE_MODFLAG_MULTIPART;
}

// Assembly:
leaq 0xd6720(%rip), %rax     # 0x10ae57
movq %rax, (%rsi)
leaq 0xd671a(%rip), %rax     # 0x10ae5b
movq %rax, 0x8(%rsi)
leaq 0x1f(%rip), %rax        # 0x3476b
movq %rax, 0x18(%rsi)
leaq 0x473(%rip), %rax       # 0x34bca
movq %rax, 0x20(%rsi)
leaq 0x4c8(%rip), %rax       # 0x34c2a
movq %rax, 0x28(%rsi)
orb $0x40, 0x30(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: de_identify_arj
static int de_identify_arj(deark *c)
{
	i64 basic_hdr_size;

	if(dbuf_memcmp(c->infile, 0, g_arj_hdr_id, 2)) return 0;
	basic_hdr_size = de_getu16le(2);
	if(basic_hdr_size>ARJ_MAX_BASIC_HEADER_SIZE || basic_hdr_size<ARJ_MIN_BASIC_HEADER_SIZE) return 0;
	if(de_input_file_has_ext(c, "arj")) return 100;
	return 75;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x18(%rdi), %rdi
leaq 0xd62f8(%rip), %rdx     # 0x10aed4
xorl %ebx, %ebx
pushq $0x2
popq %rcx
xorl %esi, %esi
callq 0xe4d48
testl %eax, %eax
jne 0x34c20
movq 0x18(%r14), %rdi
pushq $0x2
popq %rsi
callq 0xe3fa3
addq $-0xa29, %rax           # imm = 0xF5D7
cmpq $-0xa0b, %rax           # imm = 0xF5F5
jb 0x34c20
leaq 0xd624a(%rip), %rsi     # 0x10ae57
movq %r14, %rdi
callq 0xdfcd5
testl %eax, %eax
pushq $0x4b
popq %rax
pushq $0x64
popq %rbx
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: do_arj_volume
static void do_arj_volume(deark *c, lctx *d, struct arjvol_struct *v)
{
	i64 pos;
	i64 bytes_consumed = 0;

	d->cv = v;
	d->inf = v->inf;
	pos = v->archive_start;
	if(do_header_or_member(c, d, pos, 1, &bytes_consumed) != 1) goto done;
	pos += bytes_consumed;
	if(d->cv->is_secured) {
		do_security_envelope(c, d);
	}

	do_member_sequence(c, d, pos);

done:
	;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rsp), %r8
andq $0x0, (%r8)
movq %rdx, 0x8(%rsi)
movq (%rdx), %rax
movq %rax, (%rsi)
movq 0x10(%rdx), %r14
pushq $0x1
popq %rcx
movq %r14, %rdx
callq 0x350e7
cmpl $0x1, %eax
jne 0x3503e
movq 0x8(%r15), %rax
addq 0x10(%rsp), %r14
cmpb $0x0, 0x19(%rax)
je 0x34fab
movq 0x28(%rax), %rcx
testq %rcx, %rcx
je 0x34fab
movq 0x20(%rax), %rdx
leaq 0xd66c6(%rip), %rsi     # 0x10b62d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq (%r15), %rsi
movq 0x8(%r15), %rax
movq 0x20(%rax), %rdx
movq 0x28(%rax), %rcx
andl $0x0, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
xorl %r9d, %r9d
callq 0xded3a
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x8(%rsp), %r12
andq $0x0, 0x8(%rsp)
leaq 0x2(%r14), %rax
movq (%r15), %rcx
cmpq 0x18(%rcx), %rax
jg 0x3503e
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x350e7
testl %eax, %eax
je 0x3503e
movq 0x8(%rsp), %rcx
cmpq $0x2, %rcx
jl 0x3503e
addq %rcx, %r14
cmpl $0x2, %eax
jne 0x34fb0
movq 0x8(%r15), %rax
cmpb $0x0, 0x1b(%rax)
jne 0x3503e
movq 0x28(%rax), %rsi
testq %rsi, %rsi
jle 0x3500f
addq 0x20(%rax), %rsi
movq %r14, %rdi
callq 0xdfb50
movq %rax, %r14
movq (%r15), %rax
movq 0x18(%rax), %rdx
subq %r14, %rdx
cmpq $0x2, %rdx
jl 0x3503e
leaq 0xd6629(%rip), %rsi     # 0x10b64f
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xde896
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: arj_logical_member_finish_and_free
static void arj_logical_member_finish_and_free(deark *c, lctx *d, u8 errflag)
{
	if(!d->clm) return;

	if(errflag) {
		if(d->mp_opt_used) {
			de_err(c, "%s: Incomplete file; not all fragments were found",
				ucstring_getpsz_d(d->clm->filename));
		}
		else {
			if(!d->clm->warned_incomplete) {
				de_warn(c, "%s: Incomplete file; use \"-mp\" for multi-volume support",
					ucstring_getpsz_d(d->clm->filename));
				d->clm->warned_incomplete = 1;
			}
		}
	}
	dbuf_close(d->clm->outf);
	ucstring_destroy(d->clm->filename);
	de_free(c, d->clm);
	d->clm = NULL;
}

// Assembly:
movq 0x28(%rsi), %rax
testq %rax, %rax
je 0x350e6
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
testb %dl, %dl
je 0x350b9
cmpb $0x0, 0x14(%rbx)
je 0x3508e
movq 0x8(%rax), %rdi
callq 0xeb877
leaq 0xd65fe(%rip), %rsi     # 0x10b679
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
movq 0x28(%rbx), %rax
jmp 0x350b9
cmpb $0x0, 0x10(%rax)
jne 0x350b9
movq 0x8(%rax), %rdi
callq 0xeb877
leaq 0xd64fb(%rip), %rsi     # 0x10b59f
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf05a
movq 0x28(%rbx), %rax
movb $0x1, 0x10(%rax)
movq (%rax), %rdi
callq 0xe5591
movq 0x28(%rbx), %rax
movq 0x8(%rax), %rdi
callq 0xeaf3c
movq 0x28(%rbx), %rsi
movq %r14, %rdi
callq 0xded32
andq $0x0, 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: read_arj_datetime
static void read_arj_datetime(deark *c, lctx *d, struct member_data *md,
	i64 pos, struct de_timestamp *ts1, const char *name)
{
	i64 dosdt, dostm;
	char timestamp_buf[64];

	dostm = dbuf_getu16le(d->inf, pos);
	dosdt = dbuf_getu16le(d->inf, pos+2);
	if(dostm==0 && dosdt==0) {
		de_snprintf(timestamp_buf, sizeof(timestamp_buf), "[not set]");
	}
	else if(md->unix_timestamp_format) {
		i64 ut;

		// Unix time is usually signed, but it seems that Open Source ARJ makes
		// it unsigned, so the valid dates are from 1970-2106.
		ut = (dosdt<<16) | dostm;
		de_unix_time_to_timestamp(ut, ts1, 0x1);
		de_timestamp_to_string(ts1, timestamp_buf, sizeof(timestamp_buf), 0);
	}
	else {
		de_dos_datetime_to_timestamp(ts1, dosdt, dostm);
		ts1->tzcode = DE_TZCODE_LOCAL;
		de_timestamp_to_string(ts1, timestamp_buf, sizeof(timestamp_buf), 0);
	}
	de_dbg(c, "%s time: %s", name, timestamp_buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %r15
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rdi
movq %rcx, %rsi
callq 0xe3fa3
movq %rax, %r12
movq (%rbx), %rdi
addq $0x2, %rbp
movq %rbp, %rsi
callq 0xe3fa3
movq %r12, %rcx
orq %rax, %rcx
jne 0x369b5
leaq 0xee55c(%rip), %rdx     # 0x124f00
leaq 0x10(%rsp), %rdi
pushq $0x40
popq %rsi
xorl %eax, %eax
callq 0xde40c
jmp 0x369f8
cmpb $0x0, 0x10(%r13)
je 0x369d3
shlq $0x10, %rax
orq %r12, %rax
pushq $0x1
popq %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0xe002e
jmp 0x369e6
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0xe0110
movb $0x2, 0x1(%r15)
leaq 0x10(%rsp), %rsi
pushq $0x40
popq %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xe0644
leaq 0xd4a37(%rip), %rsi     # 0x10b436
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0xde896
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/arj.c
// Function: method4_lz77buf_writebytecb
static void method4_lz77buf_writebytecb(struct de_lz77buffer *rb, const u8 n)
{
	struct method4_ctx *cctx = (struct method4_ctx*)rb->userdata;

	if(cctx->stop_flag) return;
	if(cctx->dcmpro->len_known) {
		if(cctx->nbytes_written >= cctx->dcmpro->expected_len) {
			cctx->stop_flag = 1;
			return;
		}
	}

	dbuf_writebyte(cctx->dcmpro->f, n);
	cctx->nbytes_written++;
}

// Assembly:
pushq %rbx
movq (%rdi), %rbx
cmpl $0x0, 0x8(%rbx)
jne 0x36a57
movq 0x10(%rbx), %rax
cmpb $0x0, 0x8(%rax)
je 0x36a3f
movq (%rbx), %rcx
cmpq 0x10(%rax), %rcx
jge 0x36a50
movq (%rax), %rdi
movzbl %sil, %esi
callq 0xe5bc5
incq (%rbx)
jmp 0x36a57
movl $0x1, 0x8(%rbx)
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bpg.c
// Function: de_module_bpg
void de_module_bpg(deark *c, struct deark_module_info *mi)
{
	mi->id = "bpg";
	mi->desc = "BPG (Better Portable Graphics)";
	mi->desc2 = "resources only";
	mi->run_fn = de_run_bpg;
	mi->identify_fn = de_identify_bpg;
}

// Assembly:
leaq 0xd4e5c(%rip), %rax     # 0x10b8bf
movq %rax, (%rsi)
leaq 0xd4d5f(%rip), %rax     # 0x10b7cc
movq %rax, 0x8(%rsi)
leaq 0xd1889(%rip), %rax     # 0x108301
movq %rax, 0x10(%rsi)
leaq 0x10(%rip), %rax        # 0x36a93
movq %rax, 0x18(%rsi)
leaq 0x33e(%rip), %rax       # 0x36dcc
movq %rax, 0x20(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bpg.c
// Function: get_ue7
static i64 get_ue7(deark *c, i64 *pos)
{
	u8 b;
	i64 val = 0;
	int bytecount = 0;

	// TODO: Better error handling
	while(1) {
		b = de_getbyte(*pos);
		(*pos)++;
		bytecount++;

		// A quick hack to prevent 64-bit integer overflow.
		// 5 bytes are enough for 35 bits, and none of the fields in
		// BPG v0.9.4.1 require more than 32.
		if(bytecount<=5)
			val = (val<<7)|(b&0x7f);

		if(b<0x80) {
			break;
		}
	}
	return val;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rsi
xorl %eax, %eax
xorl %r15d, %r15d
movq %rax, %r12
movq 0x18(%r14), %rdi
callq 0xe3eb4
movl %eax, %ecx
movq (%rbx), %rsi
incq %rsi
movq %rsi, (%rbx)
movq %r12, %rdx
shlq $0x7, %rdx
andb $0x7f, %al
movzbl %al, %eax
orq %rdx, %rax
cmpl $0x5, %r15d
leal 0x1(%r15), %edx
cmovaeq %r12, %rax
movl %edx, %r15d
testb %cl, %cl
js 0x36e04
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bsave.c
// Function: de_module_bsave
void de_module_bsave(deark *c, struct deark_module_info *mi)
{
	mi->id = "bsave";
	mi->desc = "BSAVE/BLOAD image";
	mi->run_fn = de_run_bsave;
	mi->identify_fn = de_identify_bsave;
	mi->help_fn = de_help_bsave;
}

// Assembly:
leaq 0xd4aca(%rip), %rax     # 0x10b91d
movq %rax, (%rsi)
leaq 0xd4ac6(%rip), %rax     # 0x10b923
movq %rax, 0x8(%rsi)
leaq 0x1b(%rip), %rax        # 0x36e83
movq %rax, 0x18(%rsi)
leaq 0x8bc(%rip), %rax       # 0x3772f
movq %rax, 0x20(%rsi)
leaq 0x8e3(%rip), %rax       # 0x37761
movq %rax, 0x28(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bsave.c
// Function: de_help_bsave
static void de_help_bsave(deark *c)
{
	size_t k;

	de_msg(c, "-opt bsave:fmt=...");
	for(k=0; k<DE_ARRAYCOUNT(bsave_fmt_arr); k++) {
		const struct bsave_fmt_arr_item *item;

		item = &bsave_fmt_arr[k];
		if(item->flags & FMTFLAG_UNLISTED) continue;
		de_msg(c, " %-5s : %s", item->name, item->descr);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xd4647(%rip), %rsi     # 0x10bdba
xorl %eax, %eax
callq 0xdf42e
pushq $0x18
popq %r15
leaq 0x14ae4b(%rip), %r12    # 0x1825d0
leaq 0xd4641(%rip), %r14     # 0x10bdcd
cmpq $0x1b8, %r15            # imm = 0x1B8
je 0x377b9
testb $-0x80, -0x14(%r15,%r12)
jne 0x377b3
movq -0x8(%r15,%r12), %rdx
movq (%r15,%r12), %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xdf42e
addq $0x20, %r15
jmp 0x3778c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bsave.c
// Function: identify_bsave_internal
static void identify_bsave_internal(deark *c, struct bsave_id_info *idi)
{
	u32 load_segment;
	i64 data_size;
	// Known signatures: "PCPaint V1.0", "PCPaint V1.5".
	static const u8 *pcpaintsig = (const u8*)"PCPaint V1.";

	de_zeromem(idi, sizeof(struct bsave_id_info));
	if(c->infile->len<12) return;
	if(de_getbyte(0)!=0xfd) return;
	idi->might_be_bsave = 1;

	load_segment = (u32)de_getu16le(1);
	data_size = de_getu16le(5);
	if(data_size > c->infile->len) {
		// Mas data_size *should* be filesize-7, but there are a few bad files
		// that set it to filesize.
		idi->probably_not_bsave = 1;
		return;
	}
	if(data_size==0) {
		idi->probably_not_bsave = 1;
		return;
	}

	if(load_segment==0xb800 && (c->infile->len>=8007+14)) {
		i64 pos;

		pos = 8007;
		if(!dbuf_memcmp(c->infile, pos, pcpaintsig, 11)) {
			idi->pcpaint_sig_found = 1;
			idi->pcpaint_sig_pos = pos;
			return;
		}
	}

	if(data_size > c->infile->len) {
		idi->probably_not_bsave = 1;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
movq 0x18(%rdi), %rdi
cmpq $0xc, 0x18(%rdi)
jl 0x37866
movq %rsi, %rbx
xorl %esi, %esi
callq 0xe3eb4
cmpb $-0x3, %al
jne 0x37866
movb $0x1, (%rbx)
movq 0x18(%r14), %rdi
pushq $0x1
popq %rsi
callq 0xe3fa3
movq %rax, %r12
movq 0x18(%r14), %rdi
pushq $0x5
popq %rsi
callq 0xe3fa3
movq %rax, %r15
movq 0x18(%r14), %rdi
movq 0x18(%rdi), %rax
cmpq %rax, %r15
jg 0x37862
testq %r15, %r15
je 0x37862
cmpl $0xb800, %r12d          # imm = 0xB800
setne %cl
cmpq $0x1f55, %rax           # imm = 0x1F55
setl %dl
orb %cl, %dl
jne 0x3785d
leaq 0xd429c(%rip), %rdx     # 0x10bae0
pushq $0xb
popq %rcx
movl $0x1f47, %esi           # imm = 0x1F47
callq 0xe4d48
testl %eax, %eax
je 0x37872
movq 0x18(%r14), %rax
movq 0x18(%rax), %rax
cmpq %rax, %r15
jle 0x37866
movb $0x1, 0x1(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movb $0x1, 0x2(%rbx)
movq $0x1f47, 0x8(%rbx)      # imm = 0x1F47
jmp 0x37866
// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/bsave.c
// Function: use_fmt_by_id
static void use_fmt_by_id(deark *c, lctx *d, UI fmt_id)
{
	if(fmt_id==FMT_UNKNOWN) return;
	d->fmt_info = get_fmt_info_by_id(fmt_id);
	if(d->fmt_info) {
		d->decoder_fn = d->fmt_info->decoder_fn;
		d->has_dimension_fields = (d->fmt_info->flags & FMTFLAG_HAS_DIMENSION_FIELDS)?1:0;
		d->interlaced = (d->fmt_info->flags & FMTFLAG_INTERLACED)?1:0;
	}
}

// Assembly:
testl %esi, %esi
je 0x378b3
pushq %rbx
movq %rdi, %rbx
movl %esi, %edi
callq 0x384cd
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x378b2
movq 0x8(%rax), %rcx
movq %rcx, 0x30(%rbx)
movb 0x4(%rax), %al
movl %eax, %ecx
andb $0x1, %cl
movb %cl, 0x2d(%rbx)
shrb %al
andb $0x1, %al
movb %al, 0x2c(%rbx)
popq %rbx
retq