// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
movl $0xd0, %esi
callq 0xdecaf
movq %rax, %r15
leaq 0x487a5(%rip), %rax     # 0x13de51
movq %rax, 0x20(%r15)
movq %r14, (%r15)
movq %r13, 0x8(%r15)
movq %rbx, 0x10(%r15)
movq %r12, (%rsp)
movq %r12, 0x18(%r15)
movb $0x0, 0x58(%r15)
movq (%r13), %rax
movq %rax, 0x38(%r15)
movq 0x8(%r13), %rax
leaq 0x40(%r15), %r12
movq %rax, 0x40(%r15)
addq 0x10(%r13), %rax
movq %rax, 0x48(%r15)
movq %r14, %rdi
movl $0x8000, %esi           # imm = 0x8000
callq 0xef27c
movq %rax, 0x70(%r15)
movq %r15, (%rax)
leaq 0x1c8(%rip), %rcx       # 0xf58c7
movq %rcx, 0x8(%rax)
leaq 0x47f22(%rip), %r13     # 0x13d62c
cmpl $0x0, 0x30(%r15)
jne 0xf58a1
movq %r15, %rdi
callq 0xf5ddd
testl %eax, %eax
jne 0xf58b1
movq %r15, %rdi
pushq $0x6
popq %rsi
callq 0xf6313
movl %eax, %ebp
cmpl $0x6, %eax
jb 0xf5768
movq %r15, %rdi
pushq $0x10
popq %rsi
callq 0xf6313
cmpl $0xf, %eax
ja 0xf5899
movl %eax, %ebx
movl %eax, %esi
incl %esi
movq %r15, %rdi
callq 0xf6356
pushq $0x2
popq %rcx
movl %ecx, %edx
movl %ebx, %ecx
shll %cl, %edx
leal (%rdx,%rax), %ebp
addl $0x4, %ebp
testl %ebp, %ebp
je 0xf57be
incl %ebp
decl %ebp
je 0xf57be
movq 0x40(%r15), %rax
cmpq 0x48(%r15), %rax
jge 0xf5899
movq 0x8(%r15), %rax
movq (%rax), %rdi
movq %r12, %rsi
callq 0xe3f2a
cmpl $0x4, (%r14)
movzbl %al, %ebx
jl 0xf57a7
movq %r14, %rdi
movq %r13, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0xde896
movq 0x70(%r15), %rdi
movl %ebx, %esi
callq 0xef336
cmpl $0x0, 0x30(%r15)
je 0xf576e
jmp 0xf58a1
movq %r15, %rdi
callq 0xf5ddd
testl %eax, %eax
jne 0xf5877
movq %r15, %rdi
callq 0xf637e
movq %r15, %rdi
testb %al, %al
je 0xf5817
pushq $0xf
popq %rsi
callq 0xf6313
cmpl $0xe, %eax
ja 0xf5899
movl %eax, %ebx
movl %eax, %esi
incl %esi
movq %r15, %rdi
callq 0xf6356
pushq $0x2
popq %rcx
movl %ecx, %edx
movl %ebx, %ecx
shll %cl, %edx
leal (%rdx,%rax), %ebp
addl $0x2, %ebp
movq %r15, %rdi
callq 0xf63d0
movl %eax, %ebx
jmp 0xf583b
callq 0xf637e
movq %r15, %rdi
testb %al, %al
je 0xf582e
callq 0xf63d0
movl %eax, %ebx
pushq $0x3
jmp 0xf583a
pushq $0x9
popq %rsi
callq 0xf6356
movl %eax, %ebx
pushq $0x2
popq %rbp
cmpl $0x4, (%r14)
jl 0xf5856
movq %r14, %rdi
leaq 0x48c89(%rip), %rsi     # 0x13e4d4
movl %ebx, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xde896
testl %ebx, %ebx
je 0xf5877
movl %ebx, %eax
cmpq %rax, 0x28(%r15)
jl 0xf5880
movq 0x70(%r15), %rdi
movl 0x10(%rdi), %esi
subl %ebx, %esi
movl %ebp, %edx
callq 0xef363
jmp 0xf570a
cmpl $0x0, 0x30(%r15)
jne 0xf58a1
jmp 0xf58b1
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
leaq 0x48bf8(%rip), %rcx     # 0x13e487
movq %r14, %rdi
xorl %eax, %eax
callq 0xee823
movl $0x1, 0x30(%r15)
movq 0x20(%r15), %rdx
movq %r14, %rdi
movq (%rsp), %rsi
callq 0xee91c
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf3885