// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/fmtutil-lzh.c
// Function: fmtutil_xpkMASH_codectype1
void fmtutil_xpkMASH_codectype1(deark *c, struct de_dfilter_in_params *dcmpri,
	struct de_dfilter_out_params *dcmpro, struct de_dfilter_results *dres,
	void *codec_private_params)
{
	struct lzh_ctx *cctx = NULL;

	cctx = de_malloc(c, sizeof(struct lzh_ctx));
	cctx->modname = "mash";
	cctx->c = c;
	cctx->dcmpri = dcmpri;
	cctx->dcmpro = dcmpro;
	cctx->dres = dres;
	cctx->bitrd.bbll.is_lsb = 0;
	cctx->bitrd.f = dcmpri->f;
	cctx->bitrd.curpos = dcmpri->pos;
	cctx->bitrd.endpos = dcmpri->pos + dcmpri->len;

	cctx->ringbuf = de_lz77buffer_create(c, 32768);
	cctx->ringbuf->userdata = (void*)cctx;
	cctx->ringbuf->writebyte_cb = mash_lz77buf_writebytecb;

	mash_main(c, cctx);

	if(cctx->err_flag) {
		de_dfilter_set_generic_error(c, dres, cctx->modname);
	}
	destroy_lzh_ctx(cctx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
movl $0xd0, %esi
callq 0xe8b2b
movq %rax, %r15
leaq 0x49ccc(%rip), %rax     # 0x14b321
movq %rax, 0x20(%r15)
movq %r14, (%r15)
movq %r13, 0x8(%r15)
movq %r12, 0x10(%r15)
movq %rbx, 0x18(%r15)
movb $0x0, 0x58(%r15)
movq (%r13), %rax
movq %rax, 0x38(%r15)
movq 0x8(%r13), %rax
movq %rax, 0x40(%r15)
addq 0x10(%r13), %rax
movq %rax, 0x48(%r15)
movq %r14, %rdi
movl $0x8000, %esi           # imm = 0x8000
callq 0xfad8f
movq %rax, 0x70(%r15)
movq %r15, (%rax)
leaq 0x266(%rip), %rcx       # 0x101906
movq %rcx, 0x8(%rax)
cmpl $0x0, 0x30(%r15)
jne 0x1018e1
movq %r15, %r12
addq $0x40, %r12
movq 0x10(%r15), %rax
cmpb $0x0, 0x8(%rax)
je 0x1016ce
movq 0x28(%r15), %rcx
cmpq 0x10(%rax), %rcx
jge 0x1018b7
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl $0x5, %r13d
je 0x1016eb
movq %r15, %rdi
callq 0x10232d
incl %r13d
testb %al, %al
jne 0x1016d4
jmp 0x101745
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0xf, %r13d
je 0x1018d9
movl %ecx, %ebp
movq %r15, %rdi
callq 0x10232d
incl %r13d
leal 0x1(%rbp), %ecx
testb %al, %al
jne 0x1016f6
movq %rbx, (%rsp)
xorl %eax, %eax
movl %eax, %ebx
addl %eax, %ebx
movq %r15, %rdi
callq 0x10232d
movzbl %al, %eax
orl %ebx, %eax
decl %ebp
jne 0x10171a
movl $0x2, %edx
movl %r13d, %ecx
shll %cl, %edx
leal (%rdx,%rax), %r13d
addl $0x4, %r13d
movq (%rsp), %rbx
testl %r13d, %r13d
je 0x10179e
movq 0x40(%r15), %rax
cmpq 0x48(%r15), %rax
jge 0x1018d9
movq 0x8(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
callq 0xeeb4b
cmpl $0x4, (%r14)
movzbl %al, %ebp
jl 0x101783
movq %r14, %rdi
leaq 0x49382(%rip), %rsi     # 0x14aafc
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%r15), %rdi
movl %ebp, %esi
callq 0xfae4e
cmpl $0x0, 0x30(%r15)
jne 0x1018e1
decl %r13d
jne 0x10174a
movq 0x10(%r15), %rax
cmpb $0x0, 0x8(%rax)
je 0x1017b6
movq 0x28(%r15), %rcx
cmpq 0x10(%rax), %rcx
jge 0x1018b7
movq %r15, %rdi
callq 0x10232d
testb %al, %al
je 0x101823
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x1, %ecx
cmpl $0xe, %r13d
je 0x1018d9
movl %ecx, %ebp
movq %r15, %rdi
callq 0x10232d
incl %r13d
leal 0x1(%rbp), %ecx
testb %al, %al
jne 0x1017cd
movq %rbx, (%rsp)
xorl %eax, %eax
movl %eax, %ebx
addl %eax, %ebx
movq %r15, %rdi
callq 0x10232d
movzbl %al, %eax
orl %ebx, %eax
decl %ebp
jne 0x1017f1
movl $0x2, %edx
movl %r13d, %ecx
shll %cl, %edx
leal (%rdx,%rax), %ebp
addl $0x2, %ebp
movq %r15, %rdi
callq 0x102381
movl %eax, %r13d
jmp 0x10186b
movq %r15, %rdi
callq 0x10232d
testb %al, %al
je 0x101841
movq %r15, %rdi
callq 0x102381
movl %eax, %r13d
movl $0x3, %ebp
jmp 0x10186f
movq %rbx, (%rsp)
xorl %r13d, %r13d
movl $0x9, %ebp
movl %r13d, %ebx
addl %r13d, %ebx
movq %r15, %rdi
callq 0x10232d
movzbl %al, %r13d
orl %ebx, %r13d
decl %ebp
jne 0x10184d
movl $0x2, %ebp
movq (%rsp), %rbx
cmpl $0x4, (%r14)
jl 0x10188b
movq %r14, %rdi
leaq 0x4a125(%rip), %rsi     # 0x14b9a4
movl %r13d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe8617
testl %r13d, %r13d
je 0x1018b7
movl %r13d, %eax
cmpq %rax, 0x28(%r15)
jl 0x1018c0
movq 0x70(%r15), %rdi
movl 0x10(%rdi), %esi
subl %r13d, %esi
movl %ebp, %edx
callq 0xfae7b
cmpl $0x0, 0x30(%r15)
je 0x1016b6
jmp 0x1018e1
cmpl $0x0, 0x30(%r15)
jne 0x1018e1
jmp 0x1018f0
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
leaq 0x4a088(%rip), %rcx     # 0x14b957
movq %r14, %rdi
xorl %eax, %eax
callq 0xfa21a
movl $0x1, 0x30(%r15)
movq 0x20(%r15), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0xfa311
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xff6fb