// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/misc3.c
// Function: de_run_edi_pack
static void de_run_edi_pack(deark *c, de_module_params *mparams)
{
	de_arch_lctx *d = NULL;
	struct de_arch_member_data *md = NULL;
	i64 pos = 0;

	d = de_arch_create_lctx(c);
	d->is_le = 1;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	edi_detect_fmt(c, d);
	if(d->fmtver==0) goto done;
	else if(d->fmtver==10) {
		de_declare_fmt(c, "EDI LZSSLib");
	}
	else {
		de_declare_fmtf(c, "EDI Pack LZSS%d", d->fmtver);
	}
	pos = 8;

	md = de_arch_create_md(c, d);
	if(d->fmtver==1 || d->fmtver==2) {
		dbuf_read_to_ucstring(c->infile, pos, 12, md->filename, DE_CONVFLAG_STOP_AT_NUL,
			d->input_encoding);
		de_dbg(c, "filename: \"%s\"", ucstring_getpsz_d(md->filename));
		pos += 13;
	}

	if(d->fmtver==2) {
		de_arch_read_field_orig_len_p(md, &pos);
	}

	if(pos > c->infile->len) {
		d->need_errmsg = 1;
		goto done;
	}

	md->cmpr_pos = pos;
	md->cmpr_len = c->infile->len - md->cmpr_pos;
	md->dfn = edi_pack_decompressor_fn;
	de_arch_extract_member_file(md);

done:
	de_arch_destroy_md(c, md);
	if(d->need_errmsg) {
		de_err(c, "Bad or unsupported EDI Pack format");
	}
	de_arch_destroy_lctx(c, d);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq $0x0, 0x8(%rsp)
callq 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
leaq 0xb801b(%rip), %rdx     # 0x126165
movl $0x7, %ecx
xorl %esi, %esi
callq 0xefc85
testl %eax, %eax
je 0x6e17d
movb $0x1, 0x14(%r14)
movl 0x58(%r14), %edx
testl %edx, %edx
je 0x6e1c3
cmpl $0xa, %edx
jne 0x6e1cb
leaq 0xb7fb3(%rip), %rsi     # 0x126126
movq %rbx, %rdi
callq 0xeb125
jmp 0x6e1dc
leaq 0x10(%rsp), %rsi
movq $0x7, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xeeb4b
cmpb $0x32, %al
je 0x6e2d6
movzbl %al, %eax
cmpl $0x31, %eax
jne 0x6e15a
movq 0x10(%rsp), %rdx
movq 0x18(%rbx), %rdi
leaq 0xd(%rdx), %rax
cmpq 0x18(%rdi), %rax
jle 0x6e2e3
movl $0xa, 0x58(%r14)
jmp 0x6e15f
xorl %r15d, %r15d
jmp 0x6e29c
leaq 0xb7f60(%rip), %rsi     # 0x126132
movq %rbx, %rdi
xorl %eax, %eax
callq 0xeb152
movq $0x8, 0x8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movl 0x58(%r14), %ecx
decl %ecx
movl $0x8, %eax
cmpl $0x1, %ecx
ja 0x6e26a
movq 0x18(%rbx), %rdi
movq 0x58(%r15), %rcx
movl 0x18(%r14), %r9d
movl $0x8, %esi
movl $0xc, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x58(%r15), %rdi
callq 0xf70f6
leaq 0xcdb1a(%rip), %rsi     # 0x13bd4e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq $0x15, 0x8(%rsp)
movl $0x15, %eax
cmpl $0x2, 0x58(%r14)
jne 0x6e26a
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0xfd538
movq (%r12), %rax
movq 0x18(%rbx), %rcx
movq 0x18(%rcx), %rcx
subq %rax, %rcx
jge 0x6e27e
movb $0x1, 0x14(%r14)
jmp 0x6e29c
movq %rax, 0x40(%r15)
movq %rcx, 0x30(%r15)
leaq 0x3195(%rip), %rax      # 0x71422
movq %rax, 0xa8(%r15)
movq %r15, %rdi
callq 0xfd85e
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
cmpb $0x0, 0x14(%r14)
je 0x6e2bf
leaq 0xb7e8d(%rip), %rsi     # 0x126142
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x2, 0x58(%r14)
jmp 0x6e15f
leaq 0x1b(%rsp), %rsi
movl $0xd, %ecx
callq 0xee8d4
xorl %eax, %eax
movb $0x1, %r8b
movabsq $0xe0000003f002701, %rdx # imm = 0xE0000003F002701
xorl %ecx, %ecx
xorl %edi, %edi
xorl %esi, %esi
movzbl 0x1b(%rsp,%rsi), %r9d
cmpl $0x2e, %r9d
je 0x6e357
testl %r9d, %r9d
je 0x6e381
cmpb $0x21, %r9b
jb 0x6e1b9
leal -0x22(%r9), %r8d
cmpl $0x3b, %r8d
ja 0x6e336
btq %r8, %rdx
jb 0x6e1b9
cmpl $0x7c, %r9d
je 0x6e1b9
cmpl $0x7f, %r9d
je 0x6e1b9
testl %edi, %edi
je 0x6e37b
incl %eax
movl $0x1, %edi
jmp 0x6e364
testl %edi, %edi
movl $0x1, %edi
jne 0x6e1b9
cmpq $0xc, %rsi
leaq 0x1(%rsi), %r9
setb %r8b
movq %r9, %rsi
cmpq $0xd, %r9
jne 0x6e307
jmp 0x6e381
incl %ecx
xorl %edi, %edi
jmp 0x6e364
addl $-0x9, %ecx
cmpl $-0x8, %ecx
setb %cl
notb %r8b
cmpl $0x4, %eax
setge %al
orb %r8b, %al
orb %cl, %al
testb $0x1, %al
jne 0x6e1b9
movl $0x1, 0x58(%r14)
jmp 0x6e15f