// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exepack.c
// Function: de_run_exepack
static void de_run_exepack(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	const char *s;
	struct fmtutil_specialexe_detection_data edd;

	d = de_malloc(c, sizeof(lctx));

	s = de_get_ext_option(c, "execomp:align");
	if(s) {
		d->default_code_alignment = de_atoi(s);
	}
	if(d->default_code_alignment != 512) {
		d->default_code_alignment = 16;
	}

	d->guest_reloc_table = dbuf_create_membuf(c, 0, 0);
	d->dcmpr_code = dbuf_create_membuf(c, 0, 0);
	d->host_ei = de_malloc(c, sizeof(struct fmtutil_exe_info));
	fmtutil_collect_exe_info(c, c->infile, d->host_ei);

	de_zeromem(&edd, sizeof(struct fmtutil_specialexe_detection_data));
	edd.restrict_to_fmt = DE_SPECIALEXEFMT_EXEPACK;
	fmtutil_detect_execomp(c, d->host_ei, &edd);
	if(edd.detected_fmt != DE_SPECIALEXEFMT_EXEPACK) {
		de_err(c, "Not an EXEPACK-compressed file");
		goto done;
	}
	de_declare_fmt(c, "EXEPACK-compressed EXE");

	d->epilog_pos = edd.special_pos_1;
	de_dbg(c, "epilog pos: %"I64_FMT, d->epilog_pos);

	calc_decoder_fingerprint(c, d);

	do_read_header(c, d);
	if(d->errflag) goto done;
	find_decoder_len(c, d);
	if(d->errflag) goto done;

	report_exepack_version(c, d);

	do_read_reloc_tbl(c, d);
	if(d->errflag) goto done;

	do_decompress_code(c, d);
	if(d->errflag) goto done;

	do_write_dcmpr(c, d);

done:
	if(d) {
		if(d->errflag && !d->errmsg_handled) {
			de_err(c, "EXEPACK decompression failed");
		}
		dbuf_close(d->guest_reloc_table);
		dbuf_close(d->dcmpr_code);
		de_free(c, d->host_ei);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x80, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x145d2c(%rip), %rsi    # 0x1a9654
callq 0x15cb30
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x6394a
movq -0x20(%rbp), %rdi
callq 0x15cca0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpl $0x200, 0x8(%rax)       # imm = 0x200
je 0x63962
movq -0x18(%rbp), %rax
movl $0x10, 0x8(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movl $0xf0, %esi
callq 0x15b780
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x188930
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x19140
movb $0x3, -0x98(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x98(%rbp), %rdx
callq 0x188c80
movzbl -0x97(%rbp), %eax
cmpl $0x3, %eax
je 0x63a1d
movq -0x8(%rbp), %rdi
leaq 0x145c51(%rip), %rsi    # 0x1a9662
movb $0x0, %al
callq 0x15bfb0
jmp 0x63ada
movq -0x8(%rbp), %rdi
leaq 0x145c15(%rip), %rsi    # 0x1a963d
callq 0x15e380
movq -0x78(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
leaq 0x145c35(%rip), %rsi    # 0x1a9681
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x63b80
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x63c10
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63a78
jmp 0x63ada
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x63e80
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63a90
jmp 0x63ada
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x63ff0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x640d0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63ab5
jmp 0x63ada
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x64140
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63acd
jmp 0x63ada
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x64480
cmpq $0x0, -0x18(%rbp)
je 0x63b3e
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x63b06
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x63b06
movq -0x8(%rbp), %rdi
leaq 0x145b92(%rip), %rsi    # 0x1a9691
movb $0x0, %al
callq 0x15bfb0
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x1676a0
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x1676a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)