// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exectext.c
// Function: de_run_gtxt
static void de_run_gtxt(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 endpos;
	UI b1, b2;
	dbuf *outf = NULL;

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

	d->chartypes[7] = ETCT_CONTROL;
	d->chartypes[8] = ETCT_CONTROL;
	d->chartypes[9] = ETCT_CONTROL;
	d->chartypes[10] = ETCT_CONTROL;
	d->chartypes[13] = ETCT_CONTROL;
	d->chartypes[27] = ETCT_CONTROL;

	d->tpos = 188;
	de_dbg(c, "tpos: %"I64_FMT, d->tpos);

	endpos = c->infile->len;
	b1 = de_getbyte(endpos-2);
	b2 = de_getbyte(endpos-1);

	if(b1==0) {
		endpos -= 2;
	}
	else if(b2==0) {
		endpos -= 1;
	}

	d->tlen = endpos - d->tpos;
	de_dbg(c, "tlen: %"I64_FMT, d->tlen);
	exectext_check_tpos(c, d);
	if(d->errflag) goto done;

	outf = dbuf_create_output_file(c, "txt", NULL, 0);
	dbuf_enable_wbuffer(outf);

	if(d->proctype==ET_PROCTYPE_RAW) {
		dbuf_copy(c->infile, d->tpos, d->tlen, outf);
	}
	else {
		gtxt_convert_to_text(c, d, outf);
	}

done:
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Not a GTXT file, or unsupported version");
		}
		destroy_lctx(c, d);
	}
	dbuf_close(outf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8dcb0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb $0x1, 0x17(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0xd, %edx
callq 0x8dcf0
movq -0x18(%rbp), %rax
movb $0x1, 0x3f(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x40(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x41(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x42(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x45(%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x53(%rax)
movq -0x18(%rbp), %rax
movq $0xbc, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
leaq 0x12279b(%rip), %rsi    # 0x1af571
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
subq $0x2, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
subq $0x1, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x8ce37
movq -0x20(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x20(%rbp)
jmp 0x8ce4b
cmpl $0x0, -0x28(%rbp)
jne 0x8ce49
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x8ce4b
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
subq 0x28(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdx
leaq 0x1224eb(%rip), %rsi    # 0x1af35d
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8e1d0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x12(%rax)
je 0x8ce92
jmp 0x8cef5
movq -0x8(%rbp), %rdi
leaq 0x128d54(%rip), %rsi    # 0x1b5bf1
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x166c60
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x167b90
movq -0x18(%rbp), %rax
cmpl $0x1, 0x18(%rax)
jne 0x8cee2
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdx
movq -0x30(%rbp), %rcx
callq 0x166070
jmp 0x8cef3
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x8f6e0
jmp 0x8cef5
cmpq $0x0, -0x18(%rbp)
je 0x8cf25
movq -0x18(%rbp), %rax
cmpb $0x0, 0x13(%rax)
je 0x8cf18
movq -0x8(%rbp), %rdi
leaq 0x1226d0(%rip), %rsi    # 0x1af5e1
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8e0b0
movq -0x30(%rbp), %rdi
callq 0x1676a0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)