// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movl $0xd0, %esi
callq 0xe969b
movq %rax, %r13
movq %rax, %rbx
leaq 0x230b8(%rip), %rax     # 0x124268
movq %rax, 0x20(%r13)
movq %r15, (%r13)
movq %r12, 0x8(%r13)
movq %r14, 0x10(%r13)
movq %rbp, 0x20(%rsp)
movq %rbp, 0x18(%r13)
leaq 0x38(%r13), %rbp
movb $0x1, 0x58(%r13)
movq (%r12), %rax
movq %rax, 0x38(%r13)
movq 0x8(%r12), %rax
movq %rax, 0x40(%r13)
movq 0x10(%r12), %rcx
addq %rcx, %rax
movq %rax, 0x48(%r13)
testq %rcx, %rcx
je 0x10149d
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf2271
testb %al, %al
je 0x101218
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x101264
movb $0x1, 0xb1(%rbx)
movzbl 0xb1(%rbx), %edx
leaq 0x4a053(%rip), %rsi     # 0x14b279
movq %r15, %rdi
xorl %eax, %eax
callq 0xe93cf
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf2271
movl %eax, 0xb8(%rbx)
leaq 0x4a045(%rip), %rsi     # 0x14b28f
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe93cf
movl 0xb8(%rbx), %eax
addl $-0x7, %eax
cmpl $-0x3, %eax
jae 0x101270
movl $0x1, 0x30(%rbx)
jmp 0x10149d
cmpb $0x0, 0xb1(%rbx)
je 0x101294
leaq 0x98(%r13), %rsi
leaq 0x4a199(%rip), %rcx     # 0x14b420
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
callq 0x102a66
leaq 0xa8(%r13), %r12
leaq 0x4a1fe(%rip), %rcx     # 0x14b4a0
movl $0x10, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x102a66
leaq 0xa0(%r13), %rsi
leaq 0x4a1f0(%rip), %rcx     # 0x14b4b0
movl $0x40, %edx
movq %r15, %rdi
movq %rsi, 0x18(%rsp)
callq 0x102a66
movq (%rbx), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0xfb2c3
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq 0xaa9(%rip), %rcx       # 0x101d96
movq %rcx, 0x8(%rax)
addq $0x98, %r13
movq %rbp, 0x8(%rsp)
cmpb $0x0, 0x50(%rbx)
jne 0x101309
cmpl $0x0, 0x30(%rbx)
je 0x10133e
movl $0x2, %r14d
cmpl $0x0, 0x30(%rbx)
jne 0x101494
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r15, %rdi
leaq 0x49f7d(%rip), %rcx     # 0x14b2a8
xorl %eax, %eax
callq 0xfa71e
movl $0x1, 0x30(%rbx)
jmp 0x101494
movq %rbp, %rdi
movl $0x1, %esi
callq 0xf2271
testl %eax, %eax
je 0x10137e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1026f6
movl $0x2, %r14d
cmpl $0xf, %eax
ja 0x101409
movl %eax, %ebp
testl %eax, %eax
je 0x1013d2
cmpl $0x1, %ebp
jne 0x1013d9
movl $0x2, %ebp
jmp 0x101401
cmpq $0x0, (%r13)
je 0x101392
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1026f6
jmp 0x10139f
movq %rbp, %rdi
movl $0x8, %esi
callq 0xf2271
movq (%rbx), %rcx
cmpl $0x4, (%rcx)
movzbl %al, %ebp
jl 0x1013bd
movq %r15, %rdi
leaq 0x49198(%rip), %rsi     # 0x14a54c
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x70(%rbx), %rdi
movl %ebp, %esi
callq 0xfb382
movq 0x8(%rsp), %rbp
jmp 0x101491
movl $0x3, %ebp
jmp 0x101401
cmpl $0x7, %ebp
ja 0x1013e3
addl $0x2, %ebp
jmp 0x101401
addl $-0x7, %ebp
movq 0x8(%rsp), %rdi
movl %ebp, %esi
callq 0xf2271
movl $0x1, %edx
movl %ebp, %ecx
shll %cl, %edx
leal (%rdx,%rax), %ebp
addl $0x8, %ebp
cmpl $0x207, %ebp            # imm = 0x207
jne 0x10140d
xorl %eax, %eax
jmp 0x101488
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x1026f6
movl %eax, %r14d
movl $0x2, %r12d
cmpl $0x2, %ebp
je 0x101434
movl 0xb8(%rbx), %r12d
movq 0x8(%rsp), %rdi
movl %r12d, %esi
callq 0xf2271
movl %r12d, %ecx
shll %cl, %r14d
addl %eax, %r14d
movq (%rbx), %rax
cmpl $0x4, (%rax)
jl 0x101469
leal 0x1(%r14), %edx
movq %r15, %rdi
leaq 0x49f4d(%rip), %rsi     # 0x14b3ad
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x70(%rbx), %rdi
notl %r14d
addl 0x10(%rdi), %r14d
movl %r14d, %esi
movl %ebp, %edx
callq 0xfb3af
xorl %r14d, %r14d
movb $0x1, %al
movq 0x10(%rsp), %r12
testb %al, %al
movq 0x8(%rsp), %rbp
je 0x101494
xorl %r14d, %r14d
testl %r14d, %r14d
je 0x1012fd
cmpl $0x0, 0x30(%rbx)
je 0x1014bf
movq 0x20(%rbx), %rdx
leaq 0x49855(%rip), %rcx     # 0x14ad03
movq %r15, %rdi
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0xfa71e
jmp 0x1014e8
movq %rbp, %rdi
callq 0xf22f1
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 $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xffe9f