// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/fmtutil-lzh.c
// Function: fmtutil_dclimplode_codectype1
void fmtutil_dclimplode_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 = "dclimplode";
	cctx->c = c;
	cctx->dcmpri = dcmpri;
	cctx->dcmpro = dcmpro;
	cctx->dres = dres;

	cctx->bitrd.bbll.is_lsb = 1;
	cctx->bitrd.f = dcmpri->f;
	cctx->bitrd.curpos = dcmpri->pos;
	cctx->bitrd.endpos = dcmpri->pos + dcmpri->len;

	dclimplode_internal(cctx);

	if(cctx->err_flag) {
		// A default error message
		de_dfilter_set_errorf(c, dres, cctx->modname, "Decoding error");
		goto done;
	}

	de_bitreader_skip_to_byte_boundary(&cctx->bitrd);
	cctx->dres->bytes_consumed = cctx->bitrd.curpos - cctx->dcmpri->pos;
	if(cctx->dres->bytes_consumed<0) {
		cctx->dres->bytes_consumed = 0;
	}
	cctx->dres->bytes_consumed_valid = 1;

done:
	destroy_lzh_ctx(cctx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movl $0xd0, %esi
callq 0xe8b2b
movq %rax, %rbx
leaq 0x23a6f(%rip), %rax     # 0x124488
movq %rax, 0x20(%rbx)
movq %r15, (%rbx)
movq %r12, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r13, 0x10(%rsp)
movq %r13, 0x18(%rbx)
leaq 0x38(%rbx), %rbp
movb $0x1, 0x58(%rbx)
movq (%r12), %rax
movq %rax, 0x38(%rbx)
movq 0x8(%r12), %rax
movq %rax, 0x40(%rbx)
movq 0x10(%r12), %rcx
addq %rcx, %rax
movq %rax, 0x48(%rbx)
testq %rcx, %rcx
je 0x100adf
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf1bed
cmpb $0x1, %al
je 0x100a80
movzbl %al, %eax
testl %eax, %eax
jne 0x100ad1
movzbl 0xb1(%rbx), %edx
jmp 0x100a8c
movb $0x1, 0xb1(%rbx)
movl $0x1, %edx
leaq 0x4addd(%rip), %rsi     # 0x14b870
movq %r15, %rdi
xorl %eax, %eax
callq 0xe87e4
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf1bed
movl %eax, 0xb8(%rbx)
leaq 0x4adcf(%rip), %rsi     # 0x14b886
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe87e4
movl 0xb8(%rbx), %eax
addl $-0x7, %eax
cmpl $-0x4, %eax
ja 0x100b40
movq %rbx, %r14
addq $0x30, %r14
movl $0x1, (%r14)
cmpl $0x0, 0x30(%rbx)
je 0x100b01
movq 0x20(%rbx), %rdx
leaq 0x4a80a(%rip), %rcx     # 0x14b2fa
movq %r15, %rdi
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0xfa21a
jmp 0x100b2a
movq %rbp, %rdi
callq 0xf1c84
movq 0x40(%rbx), %rax
movq 0x8(%rbx), %rcx
movq 0x18(%rbx), %rdx
subq 0x8(%rcx), %rax
xorl %ecx, %ecx
testq %rax, %rax
cmovgq %rax, %rcx
movq %rcx, 0x8(%rdx)
movb $0x1, 0x4(%rdx)
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xff6fb
cmpb $0x0, 0xb1(%rbx)
je 0x100b64
leaq 0x98(%rbx), %rsi
leaq 0x4aeb9(%rip), %rcx     # 0x14ba10
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
callq 0x102175
leaq 0xa8(%rbx), %rsi
leaq 0x4af1e(%rip), %rcx     # 0x14ba90
movl $0x10, %edx
movq %r15, %rdi
callq 0x102175
leaq 0xa0(%rbx), %rsi
leaq 0x4af13(%rip), %rcx     # 0x14baa0
movl $0x40, %edx
movq %r15, %rdi
callq 0x102175
movq (%rbx), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xfad8f
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq 0xa1a(%rip), %rcx       # 0x1015cf
movq %rcx, 0x8(%rax)
cmpb $0x0, 0x50(%rbx)
je 0x100bee
cmpl $0x0, 0x30(%rbx)
jne 0x100adf
movq %rbx, %r14
addq $0x30, %r14
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
leaq 0x4acc0(%rip), %rcx     # 0x14b89f
movq %r15, %rdi
xorl %eax, %eax
callq 0xfa21a
jmp 0x100ad8
movq %rbp, 0x8(%rsp)
cmpl $0x0, 0x30(%rbx)
jne 0x100bbf
movq %rbp, %rdi
movl $0x1, %esi
callq 0xf1bed
testl %eax, %eax
je 0x100c4e
movq 0xa8(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
cmpl $0xf, %eax
ja 0x100adf
movl %eax, %r13d
testl %eax, %eax
je 0x100c6b
cmpl $0x1, %r13d
jne 0x100c73
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
movl %eax, %ebp
movl $0x2, %r14d
movl $0x2, %r12d
jmp 0x100c9c
movq 0x98(%rbx), %rsi
testq %rsi, %rsi
je 0x100ce4
movq %rbx, %rdi
callq 0x101e47
jmp 0x100cf1
movl $0x3, %r13d
jmp 0x100c81
cmpl $0x7, %r13d
ja 0x100d2e
addl $0x2, %r13d
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
movl %eax, %ebp
movl 0xb8(%rbx), %r12d
movl %r13d, %r14d
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0xf1bed
movl %r12d, %ecx
shll %cl, %ebp
addl %eax, %ebp
movq (%rbx), %rax
cmpl $0x4, (%rax)
jl 0x100ccf
leal 0x1(%rbp), %edx
movq %r15, %rdi
leaq 0x4acdf(%rip), %rsi     # 0x14b9a4
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%rbx), %rdi
notl %ebp
addl 0x10(%rdi), %ebp
movl %ebp, %esi
movl %r14d, %edx
callq 0xfae7b
jmp 0x100d1a
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf1bed
movq (%rbx), %rcx
cmpl $0x4, (%rcx)
movzbl %al, %ebp
jl 0x100d0f
movq %r15, %rdi
leaq 0x49df6(%rip), %rsi     # 0x14aafc
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%rbx), %rdi
movl %ebp, %esi
callq 0xfae4e
cmpb $0x0, 0x50(%rbx)
movq 0x8(%rsp), %rbp
je 0x100bf3
jmp 0x100bbf
addl $-0x7, %r13d
movq %rbp, %rdi
movl %r13d, %esi
callq 0xf1bed
movl $0x1, %edx
movl %r13d, %ecx
shll %cl, %edx
leal (%rdx,%rax), %r13d
addl $0x8, %r13d
cmpl $0x207, %r13d           # imm = 0x207
je 0x100adf
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
movl %eax, %ebp
movl $0x2, %r14d
movl $0x2, %r12d
cmpl $0x2, %r13d
jne 0x100c92
jmp 0x100c9c