// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/exectext.c
// Function: de_run_asc2com
static void de_run_asc2com(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	struct asc2com_ctx *a2cc = NULL;
	struct asc2com_detection_data idd;

	a2cc = de_malloc(c, sizeof(struct asc2com_ctx));

	de_zeromem(&idd, sizeof(struct asc2com_detection_data));
	asc2com_identify(c, &idd, 0);
	if(!idd.found) {
		de_err(c, "Not a known Asc2Com format");
		goto done;
	}
	de_dbg(c, "format code: 0x%08x", idd.fmtcode);
	de_dbg(c, "compressed: %u", (UI)idd.is_compressed);
	a2cc->version = (idd.fmtcode >> 20) & 0xfff;
	a2cc->lister = idd.fmtcode & 0xf;

	d = create_lctx(c);
	d->userdata = (void*)a2cc;

	d->supports_fmtconv = 1;
	exectext_set_common_enc_opts(c, d, DE_ENCODING_CP437);

	asc2com_find_special_chars(c, d, &idd);

	d->tpos = idd.tpos;
	de_dbg(c, "tpos: %"I64_FMT, d->tpos);
	d->tlen = c->infile->len - d->tpos;

	// TODO: Can we read and use the original filename?
	if(idd.is_compressed) {
		asc2com_extract_compressed(c, d);
	}
	else {
		asc2com_extract_uncompressed(c, d);
	}

done:
	destroy_lctx(c, d);
	de_free(c, a2cc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
movl $0x8, %esi
callq 0xe969b
movq %rax, %r13
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x63a2c
cmpb $0x0, (%r15)
je 0x61d24
movl 0x14(%rsp), %ebp
leaq 0xc1cb2(%rip), %rsi     # 0x123965
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movb 0x11(%rsp), %r14b
movzbl %r14b, %edx
leaq 0xc1caa(%rip), %rsi     # 0x123979
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl %ebp, %eax
shrl $0x14, %eax
movl %eax, (%r13)
andl $0xf, %ebp
movl %ebp, 0x4(%r13)
movl $0x138, %esi            # imm = 0x138
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movq 0x18(%rbx), %rax
movq %rax, 0x20(%r15)
movq %r13, (%r15)
movb $0x1, 0x17(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x634f2
movq (%r15), %rax
cmpl $0x4, 0x4(%rax)
jne 0x61d3d
movb $0x1, 0x41(%r15)
jmp 0x61d47
leaq 0xc1c1f(%rip), %rsi     # 0x12394a
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x6200e
movl (%rax), %ecx
cmpl $0x165, %ecx            # imm = 0x165
jae 0x61d4f
xorl %r12d, %r12d
jmp 0x61e5e
cmpl $0x175, %ecx            # imm = 0x175
jb 0x61d5c
movb $0x64, 0x41(%r15)
movl (%rax), %eax
leal -0x165(%rax), %ecx
cmpl $0x2, %ecx
movq %r13, 0x8(%rsp)
jae 0x61d74
xorl %eax, %eax
xorl %ebp, %ebp
jmp 0x61d84
leal -0x175(%rax), %ecx
cmpl $0x2, %ecx
jae 0x61d89
movb $0x1, %bpl
xorl %eax, %eax
xorl %r13d, %r13d
jmp 0x61d9a
addl $0xfffffe00, %eax       # imm = 0xFFFFFE00
cmpl $0x6, %eax
setb %r13b
setae %al
xorl %ebp, %ebp
testb %al, %al
je 0x61da6
xorl %r12d, %r12d
jmp 0x61e59
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r12
movb $0x2, %al
movb %al, 0x38(%r15)
movb %al, 0x137(%r15)
leaq 0xc1bd8(%rip), %rsi     # 0x12399d
movq %r12, %rdi
movl $0x5, %edx
callq 0xf6a40
testb %bpl, %bpl
je 0x61e17
movl $0x6, %r13d
leaq 0xc1bc0(%rip), %rbp     # 0x1239a4
addq $0x2, %r13
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef0d5
movzbl %al, %ecx
movb $0x2, 0x38(%r15,%rcx)
movq %r12, %rdi
movl $0x5, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xf6ab0
cmpq $0xb, %r13
jb 0x61de4
jmp 0x61e59
testb %r13b, %r13b
je 0x61e59
movl $0x50, %r13d
leaq 0xc1b7b(%rip), %rbp     # 0x1239a4
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef0d5
movzbl %al, %ecx
movb $0x2, 0x38(%r15,%rcx)
movq %r12, %rdi
movl $0x5, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xf6ab0
incq %r13
cmpq $0x54, %r13
jne 0x61e29
movq 0x8(%rsp), %r13
movq %r12, %rdi
callq 0xf6c00
testl %eax, %eax
je 0x61e86
movq %r12, %rdi
callq 0xf74bd
leaq 0xc1b31(%rip), %rsi     # 0x1239aa
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
callq 0xf6bb0
movq 0x18(%rsp), %rdx
movq %rdx, 0x28(%r15)
leaq 0xc1bc2(%rip), %rsi     # 0x123a60
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rax
subq 0x28(%r15), %rax
movq %rax, 0x30(%r15)
testb %r14b, %r14b
je 0x61fcf
movq %r13, 0x8(%rsp)
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, %r12
leaq 0xb8(%rsp), %rbp
leaq 0xa0(%rsp), %r14
leaq 0x40(%rsp), %rcx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0xfa6e0
movq 0x18(%rbx), %rax
movq %rax, (%rbp)
movq 0x28(%r15), %rax
movq %rax, 0x8(%rbp)
movq 0x30(%r15), %rax
movq %rax, 0x10(%rbp)
movq %r12, (%r14)
movb $0x0, 0x8(%r14)
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %r8
movaps %xmm0, (%r8)
movl $0x0, 0x10(%r8)
movl $0xc, (%r8)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
leaq 0x40(%rsp), %rcx
callq 0x102cf0
movq %r12, %rdi
callq 0xf0ea4
cmpq $0x0, 0x18(%r12)
jle 0x61f90
leaq 0xc80e0(%rip), %rsi     # 0x12a040
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r13
movq %rax, %rdi
callq 0xf0e3f
movq %r12, 0x20(%r15)
movq 0x18(%r12), %rcx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %r13, %r8
callq 0x63bac
cmpl $0x0, 0x40(%rsp)
je 0x61fb8
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa6a8
leaq 0xb2d04(%rip), %rsi     # 0x114caf
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
movq %r12, %rdi
callq 0xf0b13
movq %r13, %rdi
callq 0xf0b13
movq 0x8(%rsp), %r13
jmp 0x6200e
leaq 0xc806a(%rip), %rsi     # 0x12a040
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf037a
movq %rax, %r14
movq %rax, %rdi
callq 0xf0e3f
movq 0x28(%r15), %rdx
movq 0x30(%r15), %rcx
addq %rdx, %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %r8
callq 0x63bac
movq %r14, %rdi
callq 0xf0b13
testq %r15, %r15
je 0x6201e
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq