// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r12
movl $0xd0, %esi
callq 0xe969b
movq %rax, %r15
leaq 0x48f0b(%rip), %rax     # 0x14ad2a
movq %rax, 0x20(%r15)
movq %r12, (%r15)
movq %r13, 0x8(%r15)
movq %rbx, 0x10(%r15)
movq %r14, 0x8(%rsp)
movq %r14, 0x18(%r15)
movb $0x0, 0x58(%r15)
movq (%r13), %rax
movq %rax, 0x38(%r15)
movq 0x8(%r13), %rax
leaq 0x40(%r15), %rcx
movq %rcx, 0x10(%rsp)
movq %rax, 0x40(%r15)
addq 0x10(%r13), %rax
movq %rax, 0x48(%r15)
movq %r12, (%rsp)
movq %r12, %rdi
movl $0x8000, %esi           # imm = 0x8000
callq 0xfb2c3
movq %rax, 0x70(%r15)
movq %r15, (%rax)
leaq 0x2ba(%rip), %rcx       # 0x102136
movq %rcx, 0x8(%rax)
cmpl $0x0, 0x30(%r15)
je 0x101e95
movl $0x4, %eax
testl %eax, %eax
je 0x101e80
jmp 0x102107
movq 0x10(%r15), %rax
cmpb $0x0, 0x8(%rax)
je 0x101ea9
movq 0x28(%r15), %rcx
cmpq 0x10(%rax), %rcx
jge 0x101e87
xorl %r13d, %r13d
cmpl $0x5, %r13d
ja 0x101ec6
movq %r15, %rdi
callq 0x102c1b
xorl %ecx, %ecx
testb %al, %al
setne %cl
addl %ecx, %r13d
jmp 0x101ec8
xorl %ecx, %ecx
testb %cl, %cl
jne 0x101eac
cmpl $0x6, %r13d
jb 0x101f30
xorl %r13d, %r13d
cmpl $0xf, %r13d
ja 0x101eef
movq %r15, %rdi
callq 0x102c1b
xorl %ecx, %ecx
testb %al, %al
setne %cl
addl %ecx, %r13d
jmp 0x101ef1
xorl %ecx, %ecx
testb %cl, %cl
jne 0x101ed5
cmpl $0xf, %r13d
ja 0x1020e2
xorl %eax, %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %eax, %ebp
addl %eax, %ebp
movq %r15, %rdi
callq 0x102c1b
movzbl %al, %eax
orl %ebp, %eax
incl %ebx
cmpl %ebx, %r13d
jne 0x101f06
movl $0x2, %edx
movl %r13d, %ecx
shll %cl, %edx
leal (%rdx,%rax), %r13d
addl $0x4, %r13d
testl %r13d, %r13d
je 0x101fd1
movl %r13d, %r12d
negl %r12d
movb $0x1, %bpl
movl $0x1, %r14d
movq 0x40(%r15), %rax
cmpq 0x48(%r15), %rax
jge 0x101fb3
movq 0x8(%r15), %rax
movq (%rax), %rdi
movq 0x10(%rsp), %rsi
callq 0xef14d
movq (%rsp), %rcx
cmpl $0x4, (%rcx)
movzbl %al, %ebx
jl 0x101f83
movq (%rsp), %rdi
leaq 0x485d2(%rip), %rsi     # 0x14a54c
movl %ebx, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x70(%r15), %rdi
movl %ebx, %esi
callq 0xfb382
cmpl $0x0, 0x30(%r15)
jne 0x101fc2
cmpl %r13d, %r14d
setb %bpl
leal (%r12,%r14), %eax
incl %eax
movl %r14d, %ecx
incl %ecx
movl %ecx, %r14d
cmpl $0x1, %eax
jne 0x101f48
xorl %eax, %eax
jmp 0x101fc7
movl $0x1, 0x30(%r15)
movl $0x1, %eax
jmp 0x101fc7
movl $0x4, %eax
testb $0x1, %bpl
jne 0x101e8c
movq 0x10(%r15), %rax
cmpb $0x0, 0x8(%rax)
je 0x101fe9
movq 0x28(%r15), %rcx
cmpq 0x10(%rax), %rcx
jge 0x101e87
movq %r15, %rdi
callq 0x102c1b
testb %al, %al
je 0x102055
xorl %r13d, %r13d
cmpl $0xe, %r13d
ja 0x102012
movq %r15, %rdi
callq 0x102c1b
xorl %ecx, %ecx
testb %al, %al
setne %cl
addl %ecx, %r13d
jmp 0x102014
xorl %ecx, %ecx
testb %cl, %cl
jne 0x101ff8
cmpl $0xe, %r13d
ja 0x1020e2
xorl %eax, %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %eax, %ebp
addl %eax, %ebp
movq %r15, %rdi
callq 0x102c1b
movzbl %al, %eax
orl %ebp, %eax
incl %ebx
cmpl %ebx, %r13d
jne 0x102029
movl $0x2, %edx
movl %r13d, %ecx
shll %cl, %edx
leal (%rdx,%rax), %r13d
addl $0x2, %r13d
jmp 0x102067
movq %r15, %rdi
callq 0x102c1b
movl $0x3, %r13d
testb %al, %al
je 0x102073
movq %r15, %rdi
callq 0x102c6f
movl %eax, %ebx
jmp 0x102098
xorl %ebx, %ebx
movl $0x9, %ebp
movl %ebx, %r14d
addl %ebx, %r14d
movq %r15, %rdi
callq 0x102c1b
movzbl %al, %ebx
orl %r14d, %ebx
decl %ebp
jne 0x10207a
movl $0x2, %r13d
movq (%rsp), %rax
cmpl $0x4, (%rax)
jl 0x1020b8
movq (%rsp), %rdi
leaq 0x49301(%rip), %rsi     # 0x14b3ad
movl %ebx, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0xe9226
testl %ebx, %ebx
je 0x101e87
movl %ebx, %eax
cmpq %rax, 0x28(%r15)
jge 0x1020ef
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
movq (%rsp), %rdi
leaq 0x49285(%rip), %rcx     # 0x14b360
xorl %eax, %eax
callq 0xfa71e
movl $0x1, 0x30(%r15)
jmp 0x101e87
movq 0x70(%r15), %rdi
movl 0x10(%rdi), %esi
subl %ebx, %esi
movl %r13d, %edx
callq 0xfb3af
xorl %eax, %eax
jmp 0x101e8c
cmpl $0x0, 0x30(%r15)
je 0x102120
movq 0x20(%r15), %rdx
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xfa815
movq %r15, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xffe9f