// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %r13
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
movaps %xmm0, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x63864
cmpb $0x0, (%r15)
je 0x61bc2
movl 0x14(%rsp), %ebp
leaq 0xc1ff4(%rip), %rsi     # 0x123b45
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movb 0x11(%rsp), %r14b
movzbl %r14b, %edx
leaq 0xc1fec(%rip), %rsi     # 0x123b59
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
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 0xe8b2b
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 0x63336
movq (%r15), %rcx
cmpl $0x4, 0x4(%rcx)
jne 0x61bd8
movb $0x1, 0x41(%r15)
jmp 0x61be1
leaq 0xc1f61(%rip), %rsi     # 0x123b2a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x61e9e
movl (%rcx), %eax
cmpl $0x165, %eax            # imm = 0x165
jae 0x61be9
xorl %r12d, %r12d
jmp 0x61cf1
cmpl $0x175, %eax            # imm = 0x175
jb 0x61bf7
movb $0x64, 0x41(%r15)
movl (%rcx), %eax
leal -0x165(%rax), %ecx
cmpl $0x2, %ecx
movq %r13, 0x8(%rsp)
jae 0x61c0e
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x61c34
leal -0x175(%rax), %ecx
cmpl $0x2, %ecx
jae 0x61c20
movb $0x1, %r13b
xorl %ebp, %ebp
jmp 0x61c34
addl $0xfffffe00, %eax       # imm = 0xFFFFFE00
xorl %r13d, %r13d
cmpl $0x5, %eax
ja 0x61ce9
movb $0x1, %bpl
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r12
movb $0x2, %al
movb %al, 0x38(%r15)
movb %al, 0x137(%r15)
leaq 0xc1f2a(%rip), %rsi     # 0x123b7d
movq %r12, %rdi
movl $0x5, %edx
callq 0xf65e3
testb %r13b, %r13b
je 0x61ca5
movl $0x6, %r13d
leaq 0xc1f12(%rip), %rbp     # 0x123b84
addq $0x2, %r13
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeead3
movzbl %al, %ecx
movb $0x2, 0x38(%r15,%rcx)
movq %r12, %rdi
movl $0x5, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xf6653
cmpq $0xb, %r13
jb 0x61c72
jmp 0x61cec
testb %bpl, %bpl
je 0x61cec
movl $0x50, %r13d
leaq 0xc1ecd(%rip), %rbp     # 0x123b84
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeead3
movzbl %al, %ecx
movb $0x2, 0x38(%r15,%rcx)
movq %r12, %rdi
movl $0x5, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xf6653
incq %r13
cmpq $0x54, %r13
jne 0x61cb7
jmp 0x61cec
xorl %r12d, %r12d
movq 0x8(%rsp), %r13
movq %r12, %rdi
callq 0xf67a3
testl %eax, %eax
je 0x61d19
movq %r12, %rdi
callq 0xf705c
leaq 0xc1e7e(%rip), %rsi     # 0x123b8a
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r12, %rdi
callq 0xf6753
movq 0x18(%rsp), %rdx
movq %rdx, 0x28(%r15)
leaq 0xc1f0f(%rip), %rsi     # 0x123c40
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rax
movq 0x18(%rax), %rax
subq 0x28(%r15), %rax
movq %rax, 0x30(%r15)
testb %r14b, %r14b
je 0x61e54
movq %r13, 0x8(%rsp)
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
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 0xfa1dc
movq 0x18(%rbx), %rax
movq %rax, (%rbp)
movups 0x28(%r15), %xmm0
movups %xmm0, 0x8(%rbp)
movq %r12, (%r14)
movb $0x0, 0x8(%r14)
xorps %xmm0, %xmm0
leaq 0x2c(%rsp), %r8
movups %xmm0, 0x4(%r8)
movl $0xc, (%r8)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
leaq 0x40(%rsp), %rcx
callq 0x102400
movq %r12, %rdi
callq 0xf08ba
cmpq $0x0, 0x18(%r12)
jle 0x61e15
leaq 0xc84cb(%rip), %rsi     # 0x12a2b0
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r13
movq %rax, %rdi
callq 0xf0855
movq %r12, 0x20(%r15)
movq 0x18(%r12), %rcx
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %r13, %r8
callq 0x639c6
cmpl $0x0, 0x40(%rsp)
je 0x61e3d
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa1a4
leaq 0xb2f2f(%rip), %rsi     # 0x114d5f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
movq %r12, %rdi
callq 0xf052b
movq %r13, %rdi
callq 0xf052b
movq 0x8(%rsp), %r13
jmp 0x61e93
leaq 0xc8455(%rip), %rsi     # 0x12a2b0
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xefda1
movq %rax, %r14
movq %rax, %rdi
callq 0xf0855
movq 0x28(%r15), %rdx
movq 0x30(%r15), %rcx
addq %rdx, %rcx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %r8
callq 0x639c6
movq %r14, %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe8be2
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq