LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzh.c
// Function: mash_read_offset
static UI mash_read_offset(struct lzh_ctx *cctx)
{
	UI ocode;
	UI offset;
	static const u8 numextrabits[8] = {5, 7, 9, 10, 11, 12, 13, 14};

	ocode = mash_getbits(cctx, 3);
	offset = mash_getbits(cctx, numextrabits[ocode]);
	if(ocode==1) {
		offset += 32;
	}
	else if(ocode>=2) {
		offset += (1<<numextrabits[ocode]) - 352;
	}
	return offset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
movl $0x3, %ebp
movl %r14d, %r15d
addl %r15d, %r15d
movq %rbx, %rdi
callq 0x102c1b
movzbl %al, %r14d
orq %r15, %r14
decl %ebp
jne 0x102c82
leaq 0x48898(%rip), %rax     # 0x14b53a
movzbl (%r14,%rax), %ebp
xorl %eax, %eax
movl %ebp, %r15d
movl %eax, %r12d
addl %eax, %r12d
movq %rbx, %rdi
callq 0x102c1b
movzbl %al, %eax
orl %r12d, %eax
decl %r15d
jne 0x102cac
testl %r14d, %r14d
je 0x102ce5
cmpl $0x1, %r14d
jne 0x102cd5
addl $0x20, %eax
jmp 0x102ce5
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
addl %edx, %eax
addl $0xfffffea0, %eax       # imm = 0xFFFFFEA0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: dfilter_lzw_codec
void dfilter_lzw_codec(struct de_dfilter_ctx *dfctx, void *codec_private_params)
{
	delzwctx *dc = NULL;
	struct de_lzw_params *delzwp = (struct de_lzw_params*)codec_private_params;

	dc = de_malloc(dfctx->c, sizeof(delzwctx));
	dc->c = dfctx->c;
	dc->dfctx = dfctx;
	dc->debug_level = dc->c->debug_level;

	dfctx->codec_private = (void*)dc;
	dfctx->codec_finish_fn = my_lzw_codec_finish;
	dfctx->codec_destroy_fn = my_lzw_codec_destroy;
	dfctx->codec_addbuf_fn = my_lzw_codec_addbuf;
	dfctx->codec_command_fn = my_lzw_codec_command;

	dc->output_len_known = dfctx->dcmpro->len_known;
	dc->output_expected_len = dfctx->dcmpro->expected_len;

	dc->delzwp_copy = *delzwp; // struct copy
	dc->fmt = delzwp->fmt;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movl $0x148, %esi            # imm = 0x148
callq 0xe969b
movq (%r14), %rcx
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
movl (%rcx), %ecx
movl %ecx, 0x10(%rax)
movq %rax, 0x28(%r14)
leaq 0x51(%rip), %rcx        # 0x102d8d
movq %rcx, 0x40(%r14)
leaq 0xe4(%rip), %rcx        # 0x102e2b
movq %rcx, 0x48(%r14)
leaq 0x138(%rip), %rcx       # 0x102e8a
movq %rcx, 0x30(%r14)
leaq 0xdc4(%rip), %rcx       # 0x103b21
movq %rcx, 0x38(%r14)
movq 0x10(%r14), %rcx
movb 0x8(%rcx), %dl
movb %dl, 0x31(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x38(%rax)
movl 0x10(%rbx), %ecx
movl %ecx, 0x28(%rax)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rax)
movl (%rbx), %ecx
movl %ecx, 0x14(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: my_lzw_codec_finish
static void my_lzw_codec_finish(struct de_dfilter_ctx *dfctx)
{
	const char *modname = "delzw";
	delzwctx *dc = (delzwctx*)dfctx->codec_private;

	if(!dc) return;
	delzw_finish(dc);

	dfctx->dres->bytes_consumed = dc->total_nbytes_processed;
	dfctx->dres->bytes_consumed_valid = 1;

	if(dc->errcode) {
		de_dfilter_set_errorf(dfctx->c, dfctx->dres, modname, "%s", dc->errmsg);
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x28(%rdi), %rbx
testq %rbx, %rbx
je 0x102e23
movq %rdi, %r14
cmpb $0x0, 0x31(%rbx)
je 0x102dba
movq 0x70(%rbx), %rax
cmpq 0x38(%rbx), %rax
jne 0x102dba
leaq 0x4882e(%rip), %rcx     # 0x14b5e6
jmp 0x102dc1
leaq 0x48848(%rip), %rcx     # 0x14b609
cmpl $0x3, 0x64(%rbx)
je 0x102de4
leaq 0x48848(%rip), %rdx     # 0x14b616
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x103f65
movl $0x3, 0x64(%rbx)
movq 0x68(%rbx), %rax
movq 0x8(%r14), %rsi
movq %rax, 0x8(%rsi)
movb $0x1, 0x4(%rsi)
cmpl $0x0, 0x60(%rbx)
je 0x102e23
movq (%r14), %rdi
addq $0xf8, %rbx
leaq 0x487d5(%rip), %rdx     # 0x14b5e0
leaq 0x11e9d(%rip), %rcx     # 0x114caf
movq %rbx, %r8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xfa71e
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: my_lzw_codec_destroy
static void my_lzw_codec_destroy(struct de_dfilter_ctx *dfctx)
{
	deark *c = dfctx->c;
	delzwctx *dc = (delzwctx*)dfctx->codec_private;

	if(!dc) return;

	de_free(c, dc->ct);
	if(dc->ct2) de_free(c, dc->ct2);
	de_free(c, dc->valbuf);

	de_free(c, dc);
	dfctx->codec_private = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x28(%rdi), %r14
testq %r14, %r14
je 0x102e84
movq %rdi, %rbx
movq (%rdi), %r15
movq 0xd0(%r14), %rsi
movq %r15, %rdi
callq 0xe9752
movq 0xd8(%r14), %rsi
testq %rsi, %rsi
je 0x102e62
movq %r15, %rdi
callq 0xe9752
movq 0xf0(%r14), %rsi
movq %r15, %rdi
callq 0xe9752
movq %r15, %rdi
movq %r14, %rsi
callq 0xe9752
movq $0x0, 0x28(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: my_lzw_codec_command
static void my_lzw_codec_command(struct de_dfilter_ctx *dfctx, int cmd, UI flags)
{
	delzwctx *dc = (delzwctx*)dfctx->codec_private;

	if(dc->fmt==DE_LZWFMT_SHRINKIT2) {
		if(cmd==DE_DFILTER_COMMAND_FINISH_BLOCK) {
			dc->total_nbytes_processed -= (i64)(dc->bbll.nbits_in_bitbuf/8);
			de_bitbuf_lowlevel_empty(&dc->bbll);
		}
		else if(cmd==DE_DFILTER_COMMAND_SOFTRESET) {
			delzw_clear(dc);
		}
	}
}

// Assembly:
movq 0x28(%rdi), %rdi
cmpl $0xa, 0x14(%rdi)
jne 0x103b55
cmpl $0x1, %esi
je 0x104268
cmpl $0x3, %esi
jne 0x103b55
leaq 0xb8(%rdi), %rax
movl 0xbc(%rdi), %ecx
shrl $0x3, %ecx
subq %rcx, 0x68(%rdi)
movq %rax, %rdi
jmp 0xf2261
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_debugmsg
static void delzw_debugmsg(delzwctx *dc, int level, const char *fmt, ...)
{
	va_list ap;
	char msg[200];

	if(level>dc->debug_level) return;

	va_start(ap, fmt);
	de_vsnprintf(msg, sizeof(msg), fmt, ap);
	va_end(ap);

	de_dbg(dc->c, "[delzw:i%"I64_FMT"/o%"I64_FMT"] %s",
		(i64)dc->total_nbytes_processed, (i64)dc->uncmpr_nbytes_written, msg);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x103fb9
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
cmpl %esi, 0x10(%rdi)
jl 0x104017
movq %rdi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0x1b0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
leaq 0xd0(%rsp), %r14
movl $0xc8, %esi
movq %r14, %rdi
callq 0x109878
movq (%rbx), %rdi
movq 0x68(%rbx), %rdx
movq 0x70(%rbx), %rcx
leaq 0x4761c(%rip), %rsi     # 0x14b629
movq %r14, %r8
xorl %eax, %eax
callq 0xe9226
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_set_error
static void delzw_set_error(delzwctx *dc, int errcode, const char *msg)
{
	delzw_stop(dc, "error");
	if(dc->errcode) return;
	dc->errcode = errcode;
	if(!msg || !msg[0]) {
		msg = "LZW decompression error";
	}
	de_strlcpy(dc->errmsg, msg, sizeof(dc->errmsg));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
cmpl $0x3, 0x64(%rdi)
je 0x104059
leaq 0x475db(%rip), %rdx     # 0x14b616
leaq 0x48ded(%rip), %rcx     # 0x14ce2f
movq %r14, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x103f65
movl $0x3, 0x64(%r14)
cmpl $0x0, 0x60(%r14)
je 0x104065
popq %rbx
popq %r14
popq %rbp
retq
movl %ebp, 0x60(%r14)
testq %rbx, %rbx
je 0x104073
cmpb $0x0, (%rbx)
jne 0x10407a
leaq 0x475f7(%rip), %rbx     # 0x14b671
addq $0xf8, %r14
movl $0x50, %edx
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0xe8ded
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_set_errorf
static void delzw_set_errorf(delzwctx *dc, int errcode, const char *fmt, ...)
{
	va_list ap;

	delzw_stop(dc, "error");
	if(dc->errcode) return;
	dc->errcode = errcode;
	va_start(ap, fmt);
	de_vsnprintf(dc->errmsg, sizeof(dc->errmsg), fmt, ap);
	va_end(ap);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x1040f2
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
cmpl $0x3, 0x64(%rdi)
je 0x10411d
leaq 0x47517(%rip), %rdx     # 0x14b616
leaq 0x48d29(%rip), %rcx     # 0x14ce2f
movq %r14, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x103f65
movl $0x3, 0x64(%r14)
cmpl $0x0, 0x60(%r14)
jne 0x104164
movl %ebp, 0x60(%r14)
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000018, %rax     # imm = 0x3000000018
movq %rax, (%rcx)
addq $0xf8, %r14
movl $0x50, %esi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x109878
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_get_hashed_code
static DELZW_CODE delzw_get_hashed_code(delzwctx *dc, DELZW_CODE code,
	u8 value)
{
	DELZW_CODE h;
	DELZW_CODE saved_h;
	u32 count;

	h = ((code+(DELZW_CODE)value) | 0x0800) & 0xffff;
	h = ((h*h) >> 6) % dc->ct_capacity;

	if(dc->ct[h].codetype==DELZW_CODETYPE_DYN_UNUSED) {
		return h;
	}

	// Collision - First, walk to the end of the duplicates list
	count = 0;
	while(dc->ct2[h].next != DELZW_NEXTPTR_NONE) {
		h = dc->ct2[h].next;

		count++;
		if(count > dc->ct_capacity) {
			delzw_set_error(dc, DELZW_ERRCODE_GENERIC_ERROR, NULL);
			return 0;
		}
	}

	saved_h = h;

	// Then search for an open slot
	count = 0;
	while(1) {
		if(count==0)
			h += 101;
		else
			h += 1;
		h %= dc->ct_capacity;

		if(dc->ct[h].codetype==DELZW_CODETYPE_DYN_UNUSED)
			break;

		count++;
		if(count > dc->ct_capacity) {
			delzw_set_error(dc, DELZW_ERRCODE_GENERIC_ERROR, NULL);
			return 0;
		}
	}

	dc->ct2[saved_h].next = h;
	return h;
}

// Assembly:
pushq %rbx
addl %edx, %esi
orl $0x800, %esi            # imm = 0x800
movzwl %si, %eax
imull %eax, %eax
shrl $0x6, %eax
movl 0xc8(%rdi), %ecx
xorl %r10d, %r10d
xorl %edx, %edx
divl %ecx
movl %edx, %ebx
movq 0xd0(%rdi), %rsi
leaq (%rbx,%rbx,2), %rax
movl %eax, %eax
cmpb $0x2, 0x3(%rsi,%rax,2)
je 0x104206
movq 0xd8(%rdi), %r8
movl %ebx, %r9d
movzwl (%r8,%r9,2), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1041c7
incl %r10d
movl %eax, %ebx
cmpl %ecx, %r10d
jbe 0x1041ac
jmp 0x1041f1
xorl %r10d, %r10d
leal 0x1(%rbx), %eax
addl $0x65, %ebx
testl %r10d, %r10d
cmovnel %eax, %ebx
movl %ebx, %eax
xorl %edx, %edx
divl %ecx
movl %edx, %ebx
leaq (%rbx,%rbx,2), %rax
cmpb $0x2, 0x3(%rsi,%rax,2)
je 0x104201
incl %r10d
cmpl %ecx, %r10d
jbe 0x1041ca
xorl %ebx, %ebx
movl $0x1, %esi
xorl %edx, %edx
callq 0x104022
jmp 0x104206
movw %bx, (%r8,%r9,2)
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_increase_codesize
static void delzw_increase_codesize(delzwctx *dc)
{
	if(dc->fmt==DE_LZWFMT_UNIXCOMPRESS) {
		delzw_unixcompress_end_bitgroup(dc);
	}
	else if(dc->fmt==DE_LZWFMT_ASC2COM) {
		bbll_skip_to_byte_boundary(&dc->bbll);
	}

	if(dc->curr_codesize<dc->max_codesize) {
		dc->curr_codesize++;
		delzw_debugmsg(dc, 2, "increased code size to %u", dc->curr_codesize);
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x14(%rdi), %eax
cmpl $0xc, %eax
je 0x104225
cmpl $0x1, %eax
jne 0x10423c
movq %rbx, %rdi
callq 0x104304
jmp 0x10423c
movl 0xbc(%rbx), %esi
andl $0x7, %esi
je 0x10423c
leaq 0xb8(%rbx), %rdi
callq 0xf221e
movl 0x90(%rbx), %ecx
cmpl 0x48(%rbx), %ecx
jae 0x104266
incl %ecx
movl %ecx, 0x90(%rbx)
leaq 0x475c5(%rip), %rdx     # 0x14b81b
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
popq %rbx
jmp 0x103f65
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_clear
static void delzw_clear(delzwctx *dc)
{
	DELZW_CODE i;

	delzw_debugmsg(dc, 2, "clear code");

	if(dc->fmt==DE_LZWFMT_UNIXCOMPRESS) {
		delzw_unixcompress_end_bitgroup(dc);
	}

	for(i=dc->first_dynamic_code; i<=dc->highest_code_ever_used; i++) {
		delzw_clear_one_dynamic_code(dc, i);
	}

	dc->curr_codesize = dc->min_codesize;
	dc->free_code_search_start = dc->first_dynamic_code;
	dc->have_oldcode = 0;
	dc->oldcode = 0;
	dc->last_code_added = 0;
	dc->last_value = 0;

	delzw_debugmsg(dc, 2, "code size: %u", dc->curr_codesize);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x475db(%rip), %rdx     # 0x14b84e
movl $0x2, %esi
xorl %eax, %eax
callq 0x103f65
cmpl $0x1, 0x14(%rbx)
jne 0x10428d
movq %rbx, %rdi
callq 0x104304
movl 0xa4(%rbx), %ecx
movl 0xac(%rbx), %eax
cmpl %ecx, %eax
ja 0x1042c5
movl %eax, %edx
cmpl %edx, %eax
ja 0x1042bf
cmpl %edx, 0xc8(%rbx)
jbe 0x1042bf
movq 0xd0(%rbx), %rsi
movl %edx, %edi
leaq (%rdi,%rdi,2), %rdi
movl $0x2000000, (%rsi,%rdi,2) # imm = 0x2000000
incl %edx
cmpl %ecx, %edx
jbe 0x10429f
movl 0x44(%rbx), %ecx
movl %ecx, 0x90(%rbx)
movl %eax, 0xa8(%rbx)
xorl %eax, %eax
movb %al, 0x94(%rbx)
movb %al, 0xa0(%rbx)
movq $0x0, 0x98(%rbx)
leaq 0x1bb9e(%rip), %rdx     # 0x11fe92
movq %rbx, %rdi
movl $0x2, %esi
xorl %eax, %eax
popq %rbx
jmp 0x103f65
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-lzw.c
// Function: delzw_add_to_dict
static void delzw_add_to_dict(delzwctx *dc, DELZW_CODE parent, u8 value)
{
	DELZW_CODE newpos;

	if(dc->is_hashed) {
		delzw_hashed_add_code_to_dict(dc, parent, value);
		return;
	}

	if(dc->fmt==DE_LZWFMT_ZIPSHRINK) {
		delzw_find_first_free_entry(dc, &newpos);
	}
	else {
		newpos = dc->free_code_search_start;
	}
	if(dc->errcode) return;
	if(newpos >= dc->ct_capacity) {
		return;
	}

	if(newpos < dc->first_dynamic_code) {
		delzw_set_error(dc, DELZW_ERRCODE_GENERIC_ERROR, NULL);
		return;
	}

	dc->ct[newpos].parent = (DELZW_CODE_MINRANGE)parent;
	dc->ct[newpos].value = value;
	dc->ct[newpos].codetype = DELZW_CODETYPE_DYN_USED;
	dc->ct_code_count++;
	dc->last_code_added = newpos;
	dc->free_code_search_start = newpos+1;
	if(newpos > dc->highest_code_ever_used) {
		dc->highest_code_ever_used = newpos;
	}

	if(dc->auto_inc_codesize) {
		if(dc->early_codesize_inc) {
			if(dc->free_code_search_start>=DELZW_NBITS_TO_MAXCODE(dc->curr_codesize)) {
				delzw_increase_codesize(dc);
			}
		}
		else {
			if(dc->free_code_search_start>DELZW_NBITS_TO_MAXCODE(dc->curr_codesize)) {
				delzw_increase_codesize(dc);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
cmpb $0x0, 0x5b(%rdi)
je 0x1045d1
movl 0xcc(%rbx), %eax
cmpl 0xc8(%rbx), %eax
jae 0x1046b8
movzbl %bpl, %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x104170
cmpl $0x0, 0x60(%rbx)
jne 0x1046b8
movzwl 0x98(%rbx), %ecx
movq 0xd0(%rbx), %rdx
movl %eax, %esi
leaq (%rsi,%rsi,2), %rsi
movw %cx, (%rdx,%rsi,2)
movb %bpl, 0x2(%rdx,%rsi,2)
movb $0x3, 0x3(%rdx,%rsi,2)
incl 0xcc(%rbx)
movl %eax, 0x9c(%rbx)
jmp 0x1046b8
movl 0xa8(%rbx), %eax
cmpl $0x3, 0x14(%rbx)
jne 0x104627
movl 0xc8(%rbx), %r15d
cmpl %r15d, %eax
jae 0x10460d
movq 0xd0(%rbx), %rcx
leaq (%rax,%rax,2), %rdx
leaq (%rcx,%rdx,2), %rcx
addq $0x3, %rcx
cmpb $0x2, (%rcx)
je 0x104627
incq %rax
addq $0x6, %rcx
cmpq %rax, %r15
jne 0x1045fc
decl %r15d
leaq 0x472cd(%rip), %rdx     # 0x14b8e4
movq %rbx, %rdi
movl $0x2, %esi
callq 0x104022
movl %r15d, %eax
cmpl $0x0, 0x60(%rbx)
jne 0x1046b8
cmpl 0xc8(%rbx), %eax
jae 0x1046b8
cmpl 0xac(%rbx), %eax
jae 0x10465a
movq %rbx, %rdi
movl $0x1, %esi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x104022
movq 0xd0(%rbx), %rcx
movl %eax, %edx
leaq (%rdx,%rdx,2), %rdx
movw %r14w, (%rcx,%rdx,2)
movb %bpl, 0x2(%rcx,%rdx,2)
movb $0x3, 0x3(%rcx,%rdx,2)
incl 0xcc(%rbx)
movl %eax, 0x9c(%rbx)
leal 0x1(%rax), %edx
movl %edx, 0xa8(%rbx)
cmpl 0xa4(%rbx), %eax
jbe 0x104699
movl %eax, 0xa4(%rbx)
cmpb $0x0, 0x40(%rbx)
je 0x1046b8
cmpb $0x0, 0x59(%rbx)
movl 0x90(%rbx), %ecx
je 0x1046c3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
notl %eax
cmpl %eax, %edx
jae 0x1046c9
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
shrl %cl, %edx
testl %edx, %edx
je 0x1046b8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x10420a
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/../foreign/dskdcmps.h
// Function: dd_AddMRU
static void dd_AddMRU (struct dd_Ctl *Ctl, struct dd_codet * ct, u16 tcode)
{
	if (ct->usecount[tcode] != 0) {
		dd_tmsg(Ctl, "Usecount not zero in AddMRU, code: %4x", tcode);
	}
	ct->newer[ct->newest] = tcode;
	ct->older[tcode] = ct->newest;
	ct->newer[tcode] = 0;
	ct->newest = tcode;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movl %edx, %r15d
cmpl $0x0, 0x6010(%rsi,%r15,4)
je 0x104704
movzwl %bx, %edx
leaq 0x472a2(%rip), %rsi     # 0x14b99f
xorl %eax, %eax
callq 0x1047b7
movzwl 0xc(%r14), %eax
movw %bx, 0x200e(%r14,%rax,2)
addl %r15d, %r15d
movw %ax, 0xe(%r14,%r15)
movw $0x0, 0x200e(%r14,%r15)
movw %bx, 0xc(%r14)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/../foreign/dskdcmps.h
// Function: dd_ValidateLinkChains
static void dd_ValidateLinkChains (struct dd_Ctl *Ctl, struct dd_codet * ct, u16 tcode)
{
	u16 tnewer, tolder;
	UI errcode = 0;

	if(Ctl->c->debug_level<3) return;
	tnewer = ct->newer[tcode];
	tolder = ct->older[tcode];
	if (tcode == ct->newest) {
		if (tnewer != 0) {
			errcode += 1;
		}
	}
	else {
		if (ct->older[tnewer] != tcode) {
			errcode += 2;
		}
	}
	if (tcode == ct->oldest) {
		if (tolder != 0) {
			errcode += 4;
		}
	}
	else {
		if (ct->newer[tolder] != tcode) {
			errcode += 8;
		}
	}

	if(errcode) {
		dd_tmsg(Ctl, "Link validation error (%u). tcode: %4x, older: %4x, newer: %4x",
			errcode, tcode, tolder, ct->newer[tolder]);
	}
}

// Assembly:
movq (%rdi), %rcx
cmpl $0x3, (%rcx)
jl 0x1047b6
movl %edx, %eax
movzwl %ax, %ecx
movzwl 0x200e(%rsi,%rcx,2), %r9d
movzwl 0xe(%rsi,%rcx,2), %r8d
cmpw %cx, 0xc(%rsi)
jne 0x10475d
xorl %edx, %edx
testq %r9, %r9
setne %dl
jmp 0x10476a
xorl %edx, %edx
cmpw %ax, 0xe(%rsi,%r9,2)
setne %dl
addl %edx, %edx
cmpw %ax, 0xa(%rsi)
jne 0x10477e
testq %r8, %r8
sete %r9b
movl $0x4, %eax
jmp 0x104790
cmpw %ax, 0x200e(%rsi,%r8,2)
sete %r9b
movl $0x8, %eax
xorl %r10d, %r10d
testb %r9b, %r9b
cmovel %eax, %r10d
orl %r10d, %edx
je 0x1047b6
movl %r8d, %eax
movzwl 0x200e(%rsi,%rax,2), %r9d
leaq 0x471ae(%rip), %rsi     # 0x14b960
xorl %eax, %eax
jmp 0x1047b7
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/../foreign/dskdcmps.h
// Function: dd_tmsg
static void dd_tmsg(struct dd_Ctl *Ctl, const char *fmt, ...)
{
	va_list ap;

	if (Ctl->c->debug_level<3) return;

	va_start(ap, fmt);
	de_vsnprintf(Ctl->msg, sizeof(Ctl->msg), fmt, ap);
	va_end(ap);

	de_dbg(Ctl->c, "%s", Ctl->msg);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x104810
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq (%rdi), %rax
cmpl $0x3, (%rax)
jl 0x10486e
movq %rsi, %r10
movq %rdi, %rbx
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rcx)
leaq 0x1050(%rdi), %r14
movl $0x1000, %esi           # imm = 0x1000
movq %r14, %rdi
movq %r10, %rdx
callq 0x109878
movq (%rbx), %rdi
leaq 0x1044b(%rip), %rsi     # 0x114caf
movq %r14, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/../foreign/dskdcmps.h
// Function: dd_UnlinkCode
static void dd_UnlinkCode (struct dd_Ctl *Ctl, struct dd_codet * ct, u16 tcode)
{
	u16 tnewer, tolder;

	dd_ValidateLinkChains(Ctl, ct, ct->oldest);
	tnewer = ct->newer[tcode];
	tolder = ct->older[tcode];
	if (tcode == ct->newest)
		ct->newest = tolder;
	else
		ct->older[tnewer] = tolder;
	if (tcode == ct->oldest)
		ct->oldest = tnewer;
	else
		ct->newer[tolder] = tnewer;
	ct->older[tcode] = ct->newer[tcode] = 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %rbx
leaq 0xa(%rsi), %r14
movzwl 0xa(%rsi), %edx
callq 0x104731
leaq 0x200e(%rbx), %rcx
movl %ebp, %eax
movl %ebp, %esi
addl %esi, %esi
movzwl 0x200e(%rbx,%rsi), %edx
movzwl 0xe(%rbx,%rsi), %edi
movzwl %di, %esi
cmpw %bp, 0xc(%rbx)
jne 0x1048b8
movw %di, 0xc(%rbx)
jmp 0x1048c2
movzwl %dx, %r8d
movw %di, 0xe(%rbx,%r8,2)
cmpw %bp, 0xa(%rbx)
leaq (%rcx,%rsi,2), %rcx
cmoveq %r14, %rcx
movw %dx, (%rcx)
xorl %ecx, %ecx
movw %cx, 0x200e(%rbx,%rax,2)
movw %cx, 0xe(%rbx,%rax,2)
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: huffman_ensure_alloc
static int huffman_ensure_alloc(deark *c, struct fmtutil_huffman_codebook *bk, NODE_REF_TYPE n)
{
	i64 new_nodes_alloc;

	if(n <= bk->nodes_alloc) return 1;
	if((i64)n > bk->max_nodes) return 0;

	new_nodes_alloc = (i64)bk->nodes_alloc * 2;
	if(new_nodes_alloc > bk->max_nodes) new_nodes_alloc = bk->max_nodes;
	if(new_nodes_alloc < (i64)n) new_nodes_alloc = (i64)n;
	if(new_nodes_alloc < 16) new_nodes_alloc = 16;

	bk->nodes = de_reallocarray(c, bk->nodes, bk->nodes_alloc, sizeof(struct huffman_node),
		new_nodes_alloc);
	bk->nodes_alloc = (NODE_REF_TYPE)new_nodes_alloc;
	return 1;
}

// Assembly:
movl %edx, %ecx
movl 0xc(%rsi), %edx
movl $0x1, %eax
cmpl %ecx, %edx
jae 0x104ae9
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %ecx, %esi
movq (%rbx), %rcx
xorl %eax, %eax
cmpq %rsi, %rcx
jl 0x104ae2
leaq (%rdx,%rdx), %rax
cmpq %rcx, %rax
cmovlq %rax, %rcx
cmpq %rsi, %rcx
cmovleq %rsi, %rcx
cmpq $0x11, %rcx
movl $0x10, %r14d
cmovgeq %rcx, %r14
movq 0x10(%rbx), %rsi
movl $0xc, %ecx
movq %r14, %r8
callq 0xea2ba
movq %rax, 0x10(%rbx)
movl %r14d, 0xc(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_decode_bit
int fmtutil_huffman_decode_bit(struct fmtutil_huffman_codebook *bk, struct fmtutil_huffman_cursor *cursor,
	u8 bitval, fmtutil_huffman_valtype *pval)
{
	UI child_idx;
	int retval = 0;
	NODE_REF_TYPE curr_noderef = cursor->curr_noderef;

	if(curr_noderef >= bk->nodes_alloc) goto done;
	if(curr_noderef >= bk->next_avail_node) goto done;
	child_idx = bitval & 0x01;

	if(bk->nodes[curr_noderef].child_status[child_idx]==CHILDSTATUS_VALUE) {
		*pval = bk->nodes[curr_noderef].child[child_idx].hnvd.value;
		retval = 1;
		goto done;
	}
	else if(bk->nodes[curr_noderef].child_status[child_idx]==CHILDSTATUS_POINTER) {
		cursor->curr_noderef = bk->nodes[curr_noderef].child[child_idx].hnpd.noderef;
		retval = 2;
		goto done;
	}

done:
	if(retval!=2) {
		fmtutil_huffman_reset_cursor(cursor);
	}
	return retval;
}

// Assembly:
movl (%rsi), %r9d
xorl %r8d, %r8d
movl $0x0, %eax
cmpl 0xc(%rdi), %r9d
jae 0x104b41
xorl %r8d, %r8d
cmpl 0x8(%rdi), %r9d
jae 0x104b41
movzbl %dl, %edx
leaq (%r9,%r9,2), %r9
shlq $0x2, %r9
addq 0x10(%rdi), %r9
andl $0x1, %edx
movzbl (%rdx,%r9), %edi
xorl %r8d, %r8d
cmpl $0x2, %edi
je 0x104b35
cmpl $0x1, %edi
jne 0x104b41
movl $0x2, %eax
movb $0x1, %r8b
movq %rsi, %rcx
jmp 0x104b3a
movl $0x1, %eax
movl 0x4(%r9,%rdx,4), %edx
movl %edx, (%rcx)
testb %r8b, %r8b
jne 0x104b4c
movl $0x0, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_read_next_value
int fmtutil_huffman_read_next_value(struct fmtutil_huffman_codebook *bk,
	struct de_bitreader *bitrd, fmtutil_huffman_valtype *pval, UI *pnbits)
{
	int bitcount = 0;
	int retval = 0;
	struct fmtutil_huffman_cursor tmpcursor;

	if(bitrd->eof_flag) goto done;
	tmpcursor.curr_noderef = 0;

	if(bk->has_null_code) {
		*pval = bk->value_of_null_code;
		retval = 1;
		goto done;
	}

	while(1) {
		int ret;
		u8 b;

		b = (u8)de_bitreader_getbits(bitrd, 1);
		if(bitrd->eof_flag) goto done;
		bitcount++;
		if(bitcount>FMTUTIL_HUFFMAN_MAX_CODE_LENGTH) goto done; // Should be impossible

		ret = fmtutil_huffman_decode_bit(bk, &tmpcursor, b, pval);
		if(ret==1) { // finished the code
			retval = 1;
			goto done;
		}
		else if(ret!=2) { // decoding error
			goto done;
		}
	}
done:
	if(!retval) {
		*pval = 0;
	}
	if(pnbits) {
		*pnbits = retval ? bitcount : 0;
	}
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
xorl %r13d, %r13d
cmpb $0x0, 0x18(%rsi)
movq %rcx, 0x10(%rsp)
je 0x104b70
xorl %ebp, %ebp
jmp 0x104b8d
movq %rdi, %r15
movl $0x0, 0xc(%rsp)
cmpb $0x0, 0x18(%rdi)
je 0x104bbc
movl 0x1c(%r15), %eax
movl %eax, (%r14)
movl $0x1, %ebp
testl %ebp, %ebp
jne 0x104b98
movl $0x0, (%r14)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x104bab
testl %ebp, %ebp
cmovel %ebp, %r13d
movl %r13d, (%rax)
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r12
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r12, %rdi
movl $0x1, %esi
callq 0xf2271
cmpb $0x0, 0x18(%r12)
je 0x104bdd
xorl %ecx, %ecx
jmp 0x104c0d
leal 0x1(%r13), %ebx
cmpl $0x2f, %r13d
jg 0x104c08
movzbl %al, %edx
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
movq %r14, %rcx
callq 0x104aea
cmpl $0x1, %eax
je 0x104c16
cmpl $0x2, %eax
jne 0x104c08
movb $0x1, %cl
jmp 0x104c0a
xorl %ecx, %ecx
movl %ebx, %r13d
testb %cl, %cl
jne 0x104bc4
jmp 0x104b8d
xorl %ecx, %ecx
movl %eax, %ebp
jmp 0x104c0a
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_record_a_code_length
int fmtutil_huffman_record_a_code_length(deark *c, struct fmtutil_huffman_code_builder *builder,
	fmtutil_huffman_valtype val, UI len)
{
	if(len==0) return 1;
	if(len > FMTUTIL_HUFFMAN_MAX_CODE_LENGTH) return 0;
	if(builder->lengths_arr_numused > MAX_MAX_NODES) return 0;

	if(builder->lengths_arr_numused >= builder->lengths_arr_numalloc) {
		i64 new_numalloc;

		new_numalloc = builder->lengths_arr_numused + 128;
		builder->lengths_arr = de_reallocarray(c, builder->lengths_arr, builder->lengths_arr_numalloc,
			sizeof(struct huffman_lengths_arr_item), new_numalloc);
		builder->lengths_arr_numalloc = new_numalloc;
	}
	builder->lengths_arr[builder->lengths_arr_numused].val = val;
	builder->lengths_arr[builder->lengths_arr_numused++].len = len;
	return 1;
}

// Assembly:
movl $0x1, %eax
testl %ecx, %ecx
je 0x104e5c
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
xorl %eax, %eax
cmpl $0x30, %ecx
ja 0x104e52
movq %rsi, %r14
movq 0x8(%rsi), %r15
cmpq $0x101d0, %r15          # imm = 0x101D0
jg 0x104e52
movl %edx, %ebp
movq (%r14), %rdx
cmpq %rdx, %r15
jl 0x104e36
subq $-0x80, %r15
movq 0x10(%r14), %rsi
movl $0x8, %ecx
movq %r15, %r8
callq 0xea2ba
movq %rax, 0x10(%r14)
movq %r15, (%r14)
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
movl %ebp, (%rcx,%rax,8)
leaq 0x1(%rax), %rdx
movq %rdx, 0x8(%r14)
movl %ebx, 0x4(%rcx,%rax,8)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_create_decoder
struct fmtutil_huffman_decoder *fmtutil_huffman_create_decoder(deark *c, i64 initial_codes, i64 max_codes)
{
	struct fmtutil_huffman_decoder *ht = NULL;

	ht = de_malloc(c, sizeof(struct fmtutil_huffman_decoder));
	ht->cursor = de_malloc(c, sizeof(struct fmtutil_huffman_cursor));
	ht->bk = huffman_create_codebook(c, initial_codes, max_codes);
	ht->builder = de_malloc(c, sizeof(struct fmtutil_huffman_code_builder));
	fmtutil_huffman_reset_cursor(ht->cursor);
	return ht;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %rbx
movl $0x18, %esi
callq 0xe969b
movq %rax, %r14
movl $0x4, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, (%r14)
movl $0x30, %esi
movq %rbx, %rdi
callq 0xe969b
movl $0x101d0, %ecx          # imm = 0x101D0
cmpq %rcx, %r12
movl $0x101d0, %esi          # imm = 0x101D0
cmovbq %r12, %rsi
movq %rax, %r13
testq %r12, %r12
cmovleq %rcx, %rsi
cmpq $0x2, %r15
movl $0x1, %edx
cmovgeq %r15, %rdx
movq %rsi, (%rax)
cmpq %rcx, %rdx
cmovgeq %rcx, %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x104a83
xorl %ebp, %ebp
movl %ebp, 0x8(%r13)
movq $0x0, 0x20(%r13)
movl %ebp, 0x28(%r13)
movq %r13, 0x8(%r14)
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x10(%r14)
movq (%r14), %rax
movl %ebp, (%rax)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-huffman.c
// Function: fmtutil_huffman_destroy_decoder
void fmtutil_huffman_destroy_decoder(deark *c, struct fmtutil_huffman_decoder *ht)
{
	if(!ht) return;
	huffman_destroy_codebook(c, ht->bk);
	ht->bk = NULL;
	de_free(c, ht->builder->lengths_arr);
	de_free(c, ht->builder);
	de_free(c, ht->cursor);
	de_free(c, ht);
}

// Assembly:
testq %rsi, %rsi
je 0x10528d
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %r15
testq %r15, %r15
je 0x10524e
movq 0x10(%r15), %rsi
movq %r14, %rdi
callq 0xe9752
movq %r14, %rdi
movq %r15, %rsi
callq 0xe9752
movq $0x0, 0x8(%rbx)
movq 0x10(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0xe9752
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0xe9752
movq (%rbx), %rsi
movq %r14, %rdi
callq 0xe9752
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0xe9752
retq
nop
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: fmtutil_detect_pklite_by_exe_ep
UI fmtutil_detect_pklite_by_exe_ep(deark *c, const u8 *mem, i64 mem_len, UI flags)
{
	if(mem_len<64) return 0;

	if(flags & 0x01) {
		if(de_memmatch(mem, (const u8*)"\xb8??\xba??\x8c\xdb\x03\xd8\x3b", 11, '?', 0)) {
			return 100; // v1.00-1.05, etc.
		}
		if(de_memmatch(mem, (const u8*)"\xb8??\xba??\x05\x00\x00\x3b\x06", 11, '?', 0)) {
			return 112; // v1.12-1.15, etc.
		}
		if(de_memmatch(mem, (const u8*)"\x50\xb8??\xba??\x05\x00\x00\x3b", 11, '?', 0)) {
			return 150; // v2.01, etc.
		}
		if(de_memmatch(mem, (const u8*)"\x9c\xba?\x00\x2d?\x00\x81\xe1?\x00\x81", 12, '?', 0)) {
			return 250; // Patched by UN^2PACK v2.0?
		}
	}

	if(flags & 0x02) {
		if(de_memmatch(mem, (const u8*)"\x2e\x8c\x1e??\x8b\x1e\x02\x00\x8c\xda\x81", 12, '?', 0)) {
			return 90; // Normal beta
		}
		if(de_memmatch(mem, (const u8*)"\x2e\x8c\x1e??\xfc\x8c\xc8\x2e\x2b\x06", 11, '?', 0)) {
			return 91; // beta/loadhigh
		}
	}

	if(flags & 0x04) {
		if(de_memmatch(mem, (const u8*)"\xb8??\xba??\x05\x00\x00\x3b\x2d", 11, '?', 0)) {
			return 251; // Megalite
		}
	}

	return 0;
}

// Assembly:
xorl %eax, %eax
cmpq $0x40, %rdx
jl 0x1053ed
pushq %rbp
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rsi, %rbx
testb $0x1, %bpl
jne 0x1052ec
testb $0x2, %bpl
jne 0x105395
testb $0x4, %bpl
je 0x1052e5
leaq 0x46957(%rip), %rsi     # 0x14bc18
movl $0xb, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0xfb, %eax
testl %ecx, %ecx
jne 0x1053e7
xorl %eax, %eax
jmp 0x1053e7
leaq 0x4676d(%rip), %rsi     # 0x14ba60
movl $0xb, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0x64, %eax
testl %ecx, %ecx
jne 0x1053e7
leaq 0x468c8(%rip), %rsi     # 0x14bbe6
movl $0xb, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0x70, %eax
testl %ecx, %ecx
jne 0x1053e7
leaq 0x468a9(%rip), %rsi     # 0x14bbf2
movl $0xb, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0x96, %eax
testl %ecx, %ecx
jne 0x1053e7
leaq 0x4688e(%rip), %rsi     # 0x14bbfe
movl $0xc, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0xfa, %eax
testl %ecx, %ecx
jne 0x1053e7
jmp 0x1052aa
leaq 0x4686f(%rip), %rsi     # 0x14bc0b
movl $0xc, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0x5a, %eax
testl %ecx, %ecx
jne 0x1053e7
leaq 0x334f0(%rip), %rsi     # 0x1388b3
movl $0xb, %edx
movq %rbx, %rdi
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0xec00b
movl %eax, %ecx
movl $0x5b, %eax
testl %ecx, %ecx
je 0x1052b4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: calc_entrypoint_crc
static void calc_entrypoint_crc(deark *c, struct fmtutil_exe_info *ei)
{
	struct de_crcobj *crco = NULL;
	u32 crc1, crc2;

	if(ei->have_epcrcs) return;
	ei->have_epcrcs = 1;

	read_exe_testbytes(ei);

	// Sniff some bytes, starting at the code entry point.
	crco = de_crcobj_create(c, DE_CRCOBJ_CRC32_IEEE);
	de_crcobj_addbuf(crco, &ei->ep64b[0], 32);
	crc1 = de_crcobj_getval(crco);
	de_crcobj_reset(crco);
	de_crcobj_addbuf(crco, &ei->ep64b[32], 32);
	crc2 = de_crcobj_getval(crco);
	ei->entrypoint_crcs = ((u64)crc1 << 32) | crc2;
#ifdef DE_EXECOMP_DEVMODE
	de_dbg(c, "execomp crc: %016"U64_FMTx, ei->entrypoint_crcs);
#endif

	de_crcobj_destroy(crco);
}

// Assembly:
cmpb $0x0, 0x64(%rsi)
je 0x105c4b
retq
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movb $0x1, 0x64(%rsi)
movq %rsi, %rdi
callq 0x106061
movq %r14, %rdi
movl $0x10, %esi
callq 0xeba56
movq %rax, %r14
leaq 0x70(%rbx), %rsi
movl $0x20, %edx
movq %rax, %rdi
callq 0xebe72
movq %r14, %rdi
callq 0xebe2a
movl %eax, %r15d
movq %r14, %rdi
callq 0xebdc3
leaq 0x90(%rbx), %rsi
movl $0x20, %edx
movq %r14, %rdi
callq 0xebe72
movq %r14, %rdi
callq 0xebe2a
shlq $0x20, %r15
movl %eax, %eax
orq %r15, %rax
movq %rax, 0x68(%rbx)
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0xebe1d
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: fmtutil_detect_exesfx
void fmtutil_detect_exesfx(deark *c, struct fmtutil_exe_info *ei,
	struct fmtutil_specialexe_detection_data *edd)
{
	size_t i;

	for(i=0; i<DE_ARRAYCOUNT(exesfx_detector_arr); i++) {
		if(ei->overlay_len < (i64)exesfx_detector_arr[i].min_overlay_len) continue;
		exesfx_detector_arr[i].fn(c, ei, edd);
		if(edd->detected_fmt) goto done;
	}

done:
	if(!edd->detected_fmt_name[0]) {
		de_strlcpy(edd->detected_fmt_name, "unknown", sizeof(edd->detected_fmt_name));
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x88ca0(%rip), %r12     # 0x18ec98
xorl %r13d, %r13d
movl -0x4(%r12), %eax
cmpq %rax, 0x50(%r14)
jge 0x10600e
cmpq $0x9, %r13
jbe 0x106027
jmp 0x106030
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq *(%r12)
cmpb $0x0, 0x1(%rbx)
jne 0x106030
cmpq $0xa, %r13
jae 0x106030
incq %r13
addq $0x10, %r12
jmp 0x105ffb
cmpb $0x0, 0x50(%rbx)
je 0x106040
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
addq $0x50, %rbx
leaq 0xc441(%rip), %rsi      # 0x11248c
movl $0x28, %edx
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0xe8ded
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: read_exe_testbytes
static void read_exe_testbytes(struct fmtutil_exe_info *ei)
{
	if(ei->have_testbytes) return;
	ei->have_testbytes = 1;
	dbuf_read(ei->f, ei->ep64b, ei->entry_point, sizeof(ei->ep64b));
	dbuf_read(ei->f, ei->ovl64b, ei->end_of_dos_code, sizeof(ei->ovl64b));
}

// Assembly:
cmpb $0x0, 0x65(%rdi)
je 0x106068
retq
pushq %rbx
movq %rdi, %rbx
movb $0x1, 0x65(%rdi)
leaq 0x70(%rdi), %rsi
movq (%rdi), %rdi
movq 0x40(%rbx), %rdx
movl $0x40, %ecx
callq 0xeeee8
leaq 0xb0(%rbx), %rsi
movq (%rbx), %rdi
movq 0x48(%rbx), %rdx
movl $0x40, %ecx
popq %rbx
jmp 0xeeee8
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: detect_lhark_sfx
static int detect_lhark_sfx(deark *c, struct fmtutil_exe_info *ei,
	struct fmtutil_specialexe_detection_data *edd)
{
	int found;
	i64 foundpos = 0;
	i64 cs, ip;

	if(ei->num_relocs != 0) return 0;
	if(ei->regSP != 128) return 0;
	if(ei->start_of_dos_code != 32) return 0;

	// LHARK SFX uses a modified LZEXE 0.91 decompressor.
	// Try to find the original entry point, and record it in regCS_2/regIP_2.
	ip = dbuf_getu16le(ei->f, ei->entry_point+0x0f);
	cs = dbuf_getu16le(ei->f, ei->entry_point+0x11);
	if(!is_lzexe091_entry_point(ei, cs, ip)) {
		return 0;
	}

	found = is_lhalike_data_at(ei, ei->end_of_dos_code, 'h', &foundpos);
	if(!found) return 0;

	edd->regCS_2 = cs;
	edd->regIP_2 = ip;

	return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq $0x0, 0x8(%rsp)
xorl %ebx, %ebx
cmpq $0x0, 0x8(%rdi)
jne 0x106133
movq %rdi, %r15
cmpq $0x80, 0x18(%rdi)
jne 0x106133
cmpq $0x20, 0x38(%r15)
jne 0x106133
movq %rsi, %r14
movq (%r15), %rdi
movq 0x40(%r15), %rsi
addq $0xf, %rsi
callq 0xef1ca
movq %rax, %r12
movq (%r15), %rdi
movq 0x40(%r15), %rsi
addq $0x11, %rsi
callq 0xef1ca
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x106143
testl %eax, %eax
je 0x106133
movq 0x48(%r15), %rsi
leaq 0x8(%rsp), %rcx
movq %r15, %rdi
movl $0x68, %edx
callq 0x10619f
testl %eax, %eax
je 0x106133
movq %r13, 0x30(%r14)
movq %r12, 0x38(%r14)
movl $0x1, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: is_lzexe091_entry_point
static int is_lzexe091_entry_point(struct fmtutil_exe_info *ei, i64 cs, i64 ip)
{
	i64 n;
	i64 ep;

	ep = ei->start_of_dos_code + cs*16 + ip;

	n = (UI)dbuf_getu32be(ei->f, ep);
	if(n!=0x060e1f8bU) return 0;

	// If this is the right place, the *FAB* signature should be at offset 233.
	if(dbuf_memcmp(ei->f, ep+233, (const void*)"*FAB*", 5)) {
		return 0;
	}
	return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
shlq $0x4, %rbx
addq %rdx, %rbx
addq 0x38(%rdi), %rbx
movq (%rdi), %rdi
movq %rbx, %rsi
callq 0xef32a
movq %rax, %rcx
xorl %eax, %eax
cmpl $0x60e1f8b, %ecx        # imm = 0x60E1F8B
jne 0x106197
movq (%r14), %rdi
addq $0xe9, %rbx
leaq 0x45965(%rip), %rdx     # 0x14bae6
movl $0x5, %ecx
movq %rbx, %rsi
callq 0xf025e
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: is_lhalike_data_at
static int is_lhalike_data_at(struct fmtutil_exe_info *ei, i64 pos, u8 h_or_z, i64 *pfoundpos)
{
	u8 b2[8];

	if(pos+21 > ei->f->len) return 0;
	dbuf_read(ei->f, b2, pos, sizeof(b2));
	if(b2[2]!='-' || b2[6]!='-') return 0;
	if(b2[3]=='l' && b2[4]==h_or_z) {
		*pfoundpos = pos;
		return 1;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
leaq 0x15(%rsi), %rax
movq (%rdi), %rdi
xorl %ebx, %ebx
cmpq 0x18(%rdi), %rax
jle 0x1061c9
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
leaq 0x8(%rsp), %r12
movl $0x8, %ecx
movq %r12, %rsi
movq %r15, %rdx
callq 0xeeee8
cmpb $0x2d, 0x2(%r12)
jne 0x1061ba
cmpb $0x2d, 0xe(%rsp)
jne 0x1061ba
cmpb $0x6c, 0xb(%rsp)
jne 0x1061ba
cmpb %bpl, 0xc(%rsp)
jne 0x1061ba
movq %r15, (%r14)
movl $0x1, %ebx
jmp 0x1061ba
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: detect_exesfx_zip
static void detect_exesfx_zip(deark *c,
	struct fmtutil_exe_info *ei, struct fmtutil_specialexe_detection_data *edd)
{
	int ret;
	i64 foundpos = 0;

	if(!edd->zip_eocd_looked_for) {
		if(c->infile==ei->f && c->detection_data && c->detection_data->zip_eocd_looked_for) {
			edd->zip_eocd_looked_for = 1;
			edd->zip_eocd_found = c->detection_data->zip_eocd_found;
			edd->zip_eocd_pos = c->detection_data->zip_eocd_pos;
		}
		else {
			edd->zip_eocd_found = (u8)fmtutil_find_zip_eocd(c, c->infile, 0, &edd->zip_eocd_pos);
			edd->zip_eocd_looked_for = 1;
		}
	}

	if(!edd->zip_eocd_found) goto done;

	// Look for a ZIP file in the overlay (approximately)
	if(ei->overlay_len < 10) goto done; // Overlay too small

	ret = dbuf_search(ei->f, (const u8*)"PK\x03\x04", 4, ei->end_of_dos_code-10, 20,
		&foundpos);
	if(!ret) goto done;
	edd->detected_fmt = DE_SPECIALEXEFMT_ZIPSFX;

done:
	if(edd->detected_fmt==DE_SPECIALEXEFMT_ZIPSFX) {
		de_strlcpy(edd->detected_fmt_name, "ZIP", sizeof(edd->detected_fmt_name));
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq $0x0, (%rsp)
cmpb $0x0, 0x4(%rdx)
jne 0x106240
movq 0x18(%rdi), %rsi
cmpq (%r14), %rsi
je 0x1062a0
leaq 0x28(%rbx), %rcx
xorl %edx, %edx
callq 0xf93ef
movb %al, 0x5(%rbx)
movb $0x1, 0x4(%rbx)
cmpb $0x0, 0x5(%rbx)
je 0x10627a
cmpq $0xa, 0x50(%r14)
jl 0x10627a
movq (%r14), %rdi
movq 0x48(%r14), %rcx
addq $-0xa, %rcx
leaq 0x45917(%rip), %rsi     # 0x14bb76
movq %rsp, %r9
movl $0x4, %edx
movl $0x14, %r8d
callq 0xf1a9c
testl %eax, %eax
je 0x10627a
movb $0x65, 0x1(%rbx)
cmpb $0x65, 0x1(%rbx)
jne 0x106298
addq $0x50, %rbx
leaq 0x1fdd4(%rip), %rsi     # 0x12605f
movl $0x28, %edx
movq %rbx, %rdi
callq 0xe8ded
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x28(%rdi), %rax
testq %rax, %rax
je 0x10622e
cmpb $0x0, 0x6(%rax)
je 0x10622e
movb $0x1, 0x4(%rbx)
movb 0x7(%rax), %cl
movb %cl, 0x5(%rbx)
movq 0x8(%rax), %rax
movq %rax, 0x28(%rbx)
jmp 0x106240
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: detect_exesfx_car
static void detect_exesfx_car(deark *c,
	struct fmtutil_exe_info *ei, struct fmtutil_specialexe_detection_data *edd)
{
	i64 foundpos = 0;

	if(ei->overlay_len<27) goto done;
	if(ei->entry_point!=11566 || ei->regSS!=978) {
		goto done;
	}

	if(dbuf_memcmp(ei->f, 11256,
		(const void*)"\x43\x41\x52\x20\x53\x65\x6c\xd8\xf0\x6e\x23\xf8\x0a\x41\xdd\xfd", 16))
	{
		goto done;
	}

	if(!is_lhalike_data_at(ei, ei->end_of_dos_code, 'h', &foundpos)) {
		goto done;
	}

	edd->payload_pos = foundpos;
	edd->payload_len = ei->f->len - edd->payload_pos;

	edd->detected_fmt = DE_SPECIALEXEFMT_SFX;
	edd->payload_valid = 1;
	edd->payload_file_ext = "car";

done:
	if(edd->detected_fmt==DE_SPECIALEXEFMT_SFX) {
		de_strlcpy(edd->detected_fmt_name, "CAR (MylesHi!)", sizeof(edd->detected_fmt_name));
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq $0x0, (%rsp)
cmpq $0x1b, 0x50(%rsi)
jl 0x106355
movq %rsi, %r14
cmpq $0x2d2e, 0x40(%rsi)     # imm = 0x2D2E
jne 0x106355
cmpq $0x3d2, 0x10(%r14)      # imm = 0x3D2
jne 0x106355
movq (%r14), %rdi
leaq 0x4587a(%rip), %rdx     # 0x14bb7b
movl $0x2bf8, %esi           # imm = 0x2BF8
movl $0x10, %ecx
callq 0xf025e
testl %eax, %eax
jne 0x106355
movq 0x48(%r14), %rsi
movq %rsp, %rcx
movq %r14, %rdi
movl $0x68, %edx
callq 0x10619f
testl %eax, %eax
je 0x106355
movq (%rsp), %rax
movq %rax, 0x10(%rbx)
movq (%r14), %rcx
movq 0x18(%rcx), %rcx
subq %rax, %rcx
movq %rcx, 0x18(%rbx)
movb $0x64, 0x1(%rbx)
movb $0x1, 0x3(%rbx)
leaq 0x25f86(%rip), %rax     # 0x12c2d7
movq %rax, 0x40(%rbx)
cmpb $0x64, 0x1(%rbx)
jne 0x10637a
addq $0x50, %rbx
leaq 0x45826(%rip), %rsi     # 0x14bb8c
movl $0x28, %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe8ded
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: detect_exesfx_lhark
static void detect_exesfx_lhark(deark *c,
	struct fmtutil_exe_info *ei, struct fmtutil_specialexe_detection_data *edd)
{
	if(!detect_lhark_sfx(c, ei, edd)) {
		goto done;
	}

	edd->payload_pos = ei->end_of_dos_code;
	edd->payload_len = ei->f->len - edd->payload_pos;
	if(edd->payload_len<28) goto done;

	edd->detected_fmt = DE_SPECIALEXEFMT_SFX;
	edd->payload_valid = 1;
	edd->payload_file_ext = "lzh";

done:
	if(edd->detected_fmt==DE_SPECIALEXEFMT_SFX) {
		de_strlcpy(edd->detected_fmt_name, "LHARK", sizeof(edd->detected_fmt_name));
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x10609e
testl %eax, %eax
je 0x1063ca
movq 0x48(%r14), %rax
movq %rax, 0x10(%rbx)
movq (%r14), %rcx
movq 0x18(%rcx), %rcx
subq %rax, %rcx
movq %rcx, 0x18(%rbx)
cmpq $0x1c, %rcx
jl 0x1063ca
movb $0x64, 0x1(%rbx)
movb $0x1, 0x3(%rbx)
leaq 0x3e7dc(%rip), %rax     # 0x144ba2
movq %rax, 0x40(%rbx)
cmpb $0x64, 0x1(%rbx)
jne 0x1063ef
addq $0x50, %rbx
leaq 0x259bf(%rip), %rsi     # 0x12bd9a
movl $0x28, %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe8ded
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-exe.c
// Function: detect_exesfx_larc
static void detect_exesfx_larc(deark *c,
	struct fmtutil_exe_info *ei, struct fmtutil_specialexe_detection_data *edd)
{
	int found;
	i64 foundpos = 0;

	calc_entrypoint_crc(c, ei);
	if(ei->entrypoint_crcs!=0x81681852d3882b18ULL) {
		goto done;
	}

	found = is_lhalike_data_at(ei, ei->entry_point+525, 'z', &foundpos);
	if(!found) goto done;

	edd->payload_pos = foundpos;
	edd->payload_len = ei->f->len - edd->payload_pos;
	if(edd->payload_len<21) goto done;

	edd->detected_fmt = DE_SPECIALEXEFMT_SFX;
	edd->payload_valid = 1;
	edd->payload_file_ext = "lzs";

done:
	if(edd->detected_fmt==DE_SPECIALEXEFMT_SFX) {
		de_strlcpy(edd->detected_fmt_name, "LArc", sizeof(edd->detected_fmt_name));
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq $0x0, (%rsp)
callq 0x105c44
movabsq $-0x7e97e7ad2c77d4e8, %rax # imm = 0x81681852D3882B18
cmpq %rax, 0x68(%r14)
jne 0x106682
movl $0x20d, %esi            # imm = 0x20D
addq 0x40(%r14), %rsi
movq %rsp, %rcx
movq %r14, %rdi
movl $0x7a, %edx
callq 0x10619f
testl %eax, %eax
je 0x106682
movq (%rsp), %rax
movq %rax, 0x10(%rbx)
movq (%r14), %rcx
movq 0x18(%rcx), %rcx
subq %rax, %rcx
movq %rcx, 0x18(%rbx)
cmpq $0x15, %rcx
jl 0x106682
movb $0x64, 0x1(%rbx)
movb $0x1, 0x3(%rbx)
leaq 0x25bba(%rip), %rax     # 0x12c238
movq %rax, 0x40(%rbx)
cmpb $0x64, 0x1(%rbx)
jne 0x1066a7
addq $0x50, %rbx
leaq 0x25d90(%rip), %rsi     # 0x12c423
movl $0x28, %edx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xe8ded
addq $0x8, %rsp
popq %rbx
popq %r14
retq