// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pklite.c
// Function: do_pklite_com
static void do_pklite_com(deark *c, lctx *d)
{
	i64 verpos = 0;

	if(!detect_pklite_com_quick(c->infile, &verpos)) {
		de_err(c, "Not a known/supported PKLITE format");
		goto done;
	}

	d->is_com = 1;
	d->host_ei->f = c->infile;
	de_declare_fmt(c, "PKLITE-compressed COM");

	de_read(d->epbytes, 0, EPBYTES_LEN);

	read_and_process_com_version_number(c, d, verpos);

	if(c->module_disposition==DE_MODDISP_AUTODETECT) {
		// Check if the user requested that we not do executable decompression.
		// This feels like a hack. I'm not sure how it should work.
		if(de_get_ext_option_bool(c, "execomp", 1) == 0) {
			goto done;
		}
	}

	do_analyze_pklite_com(c, d);

	report_detected_version_number_com(c, d);

	if(d->errflag || d->dparams.cmpr_data_pos==0) {
		de_err(c, "Unsupported PKLITE format version");
		goto done;
	}

	do_decompress(c, d);
	if(!d->dcmpr_code) goto done;
	dbuf_flush(d->dcmpr_code);
	if(d->errflag) goto done;
	d->dcmpr_ok = 1;

	dbuf_create_file_from_slice(d->dcmpr_code, 0, d->dcmpr_code->len, "com", NULL, 0);
	de_stdwarn_execomp(c);

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x18(%rbp), %rsi
callq 0x116f60
cmpl $0x0, %eax
jne 0x1136f5
movq -0x8(%rbp), %rdi
leaq 0xb0f9a(%rip), %rsi     # 0x1c4683
movb $0x0, %al
callq 0x15bfb0
jmp 0x11383c
movq -0x10(%rbp), %rax
movb $0x1, 0x5(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
leaq 0xb0f8c(%rip), %rsi     # 0x1c46a7
callq 0x15e380
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0x10c, %rsi            # imm = 0x10C
xorl %eax, %eax
movl %eax, %edx
movl $0x3e8, %ecx            # imm = 0x3E8
callq 0x164d10
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x117080
movq -0x8(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0x11377d
movq -0x8(%rbp), %rdi
leaq 0x94b29(%rip), %rsi     # 0x1a8290
movl $0x1, %edx
callq 0x15cbc0
cmpl $0x0, %eax
jne 0x11377b
jmp 0x11383c
jmp 0x11377d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1170d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x117140
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1137ae
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1137c2
movq -0x8(%rbp), %rdi
leaq 0xb0f04(%rip), %rsi     # 0x1c46bd
movb $0x0, %al
callq 0x15bfb0
jmp 0x11383c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x113ae0
movq -0x10(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
jne 0x1137df
jmp 0x11383c
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x167c30
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1137fa
jmp 0x11383c
movq -0x10(%rbp), %rax
movb $0x1, 0x2(%rax)
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movq 0x18(%rax), %rdx
xorl %eax, %eax
movl %eax, %r8d
leaq 0x9b9ae(%rip), %rcx     # 0x1af1d6
xorl %r9d, %r9d
movq %r8, %rsi
callq 0x166be0
movq -0x8(%rbp), %rdi
callq 0x15bbe0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)