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

	cctx = de_malloc(c, sizeof(struct lzh_ctx));
	cctx->modname = "unlzh";
	cctx->c = c;
	cctx->dcmpri = dcmpri;
	cctx->dcmpro = dcmpro;
	cctx->dres = dres;

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

	decompress_lh5x_internal(cctx, lzhp);

	if(cctx->err_flag) {
		// A default error message
		de_dfilter_set_errorf(c, dres, cctx->modname, "LZH 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 $0x98, %rsp
movq %r8, %rbp
movq %rcx, %r13
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl $0xd0, %esi
callq 0xe8b2b
movq %rax, %rbx
leaq 0x4c684(%rip), %rax     # 0x14b2d0
movq %rax, 0x20(%rbx)
movq %r12, 0x28(%rsp)
movq %r12, (%rbx)
movq %r15, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r13, 0x40(%rsp)
movq %r13, 0x18(%rbx)
movq (%r15), %rax
leaq 0x38(%rbx), %r12
movq %rax, 0x38(%rbx)
movq 0x8(%r15), %rax
movq %rax, 0x40(%rbx)
addq 0x10(%r15), %rax
movq %rax, 0x48(%rbx)
movl $0x1fe, 0x80(%rbx)      # imm = 0x1FE
movq %rbp, 0x48(%rsp)
movl (%rbp), %eax
cmpl $0x6, %eax
jg 0xfecb4
cmpl $0x5, %eax
je 0xfecf7
cmpl $0x6, %eax
jne 0xfecd6
movsd 0x4c613(%rip), %xmm0    # 0x14b2c0
movl $0x8000, %esi           # imm = 0x8000
jmp 0xfed13
cmpl $0x7, %eax
je 0xfed06
cmpl $0x64, %eax
jne 0xfecd6
movb $0x1, 0x7d(%rbx)
movl $0x121, 0x80(%rbx)      # imm = 0x121
movsd 0x4c5cc(%rip), %xmm0    # 0x14b2a0
jmp 0xfed0e
leaq 0x4c5f3(%rip), %rdx     # 0x14b2d0
leaq 0x4c64d(%rip), %rcx     # 0x14b331
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %eax, %eax
callq 0xfa21a
jmp 0xfed60
movsd 0x4c591(%rip), %xmm0    # 0x14b290
movl $0x2000, %esi           # imm = 0x2000
jmp 0xfed13
movsd 0x4c5a2(%rip), %xmm0    # 0x14b2b0
movl $0x10000, %esi          # imm = 0x10000
movlps %xmm0, 0x84(%rbx)
movq 0x48(%rsp), %r14
movb 0x4(%r14), %al
movb %al, 0x68(%rbx)
movb 0x5(%r14), %al
movb %al, 0x69(%rbx)
movq 0x28(%rsp), %rdi
callq 0xfad8f
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq 0x24e8(%rip), %rcx      # 0x10122d
movq %rcx, 0x8(%rax)
movzbl 0x6(%r14), %esi
testl %esi, %esi
je 0xfed5a
movq %rax, %rdi
callq 0xfadfe
cmpb $0x0, 0x50(%rbx)
je 0xfedd7
movq 0xc8(%rbx), %rax
movq 0x48(%rsp), %rcx
movq %rax, 0x8(%rcx)
cmpl $0x0, 0x30(%rbx)
je 0xfed94
movq 0x20(%rbx), %rdx
leaq 0x1f40b(%rip), %rcx     # 0x11e18c
movq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
xorl %eax, %eax
callq 0xfa21a
jmp 0xfedbd
movq %r12, %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
callq 0xff6fb
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %r14
xorl %ebp, %ebp
movq %r12, 0x18(%rsp)
movq 0x10(%rbx), %rax
cmpb $0x0, 0x8(%rax)
je 0xfedfb
movq 0x28(%rbx), %rcx
cmpq 0x10(%rax), %rcx
jge 0xfed60
movq (%rbx), %r15
movq %r15, %rdi
leaq 0x3c(%rsp), %rsi
callq 0xe8a1c
movl $0x20, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf1cf3
movq %r12, %rdi
movl $0x10, %esi
callq 0xf1bed
cmpb $0x0, 0x50(%rbx)
movl %ebp, 0x38(%rsp)
je 0xfee4b
movq %r15, %rdi
leaq 0x4c522(%rip), %rsi     # 0x14b35e
movq %r14, %rdx
xorl %eax, %eax
callq 0xe87e4
jmp 0xff42d
movq %rax, %r13
movq %r15, %rdi
leaq 0x4c532(%rip), %rsi     # 0x14b38a
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0xe87e4
movq %r15, %rdi
movl $0x1, %esi
callq 0xe8a15
movq (%rbx), %rdi
leaq 0x4c51e(%rip), %rsi     # 0x14b399
movl %r13d, %edx
xorl %eax, %eax
callq 0xe87e4
testl %r13d, %r13d
je 0xfeff2
movq %r15, 0x10(%rsp)
movq %rbx, %rdi
callq 0x101ec2
movq (%rbx), %r14
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movl $0x20, %edx
movq %r12, %rdi
leaq 0x70(%rsp), %r15
movq %r15, %rsi
callq 0xf1cf3
movq %r14, %rdi
leaq 0x4c58e(%rip), %rsi     # 0x14b458
leaq 0x4c57a(%rip), %rbp     # 0x14b44b
movq %rbp, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe87e4
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r12, %rdi
movl $0x5, %esi
callq 0xf1bed
movq %rax, %r15
movq %r14, %rdi
leaq 0x4c561(%rip), %rsi     # 0x14b466
movq %rbp, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe87e4
cmpl $0x14, %r15d
movq %r12, %rbp
movl $0x14, %r12d
cmovbl %r15d, %r12d
movq %r14, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0x104d0e
movq %rax, 0x90(%rbx)
testl %r15d, %r15d
je 0xff03d
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x101f44
movl %eax, %r15d
movq %r14, %rdi
leaq 0x1f2d5(%rip), %rsi     # 0x11e22d
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe889f
movq 0x90(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x1049cc
incl %ebp
cmpl $0x3, %ebp
jne 0xfefb5
movq 0x18(%rsp), %rdi
movl $0x2, %esi
callq 0xf1bed
movq %rax, %rbp
testl %ebp, %ebp
je 0xfefb0
movq %r14, %rdi
leaq 0x4c4dd(%rip), %rsi     # 0x14b47f
movl %ebp, %edx
xorl %eax, %eax
callq 0xe889f
addl $0x3, %ebp
jmp 0xfefb5
movl $0x3, %ebp
cmpl %r12d, %ebp
jb 0xfef43
cmpb $0x0, 0x50(%rbx)
movq 0x18(%rsp), %r12
jne 0xff3f3
movq 0x90(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x104a46
testl %eax, %eax
jne 0xff07e
jmp 0xff3f3
cmpb $0x0, 0x69(%rbx)
je 0xff013
cmpb $0x0, 0x6a(%rbx)
jne 0xff013
movq %r15, %rdi
leaq 0x4c3a8(%rip), %rsi     # 0x14b3b0
xorl %eax, %eax
callq 0xe8faa
movb $0x1, 0x6a(%rbx)
movzbl 0x68(%rbx), %eax
cmpl $0x1, %eax
je 0xff243
cmpl $0x2, %eax
je 0xff23b
cmpl $0x3, %eax
jne 0xff256
movl $0x10000, %r13d         # imm = 0x10000
jmp 0xfee8e
movq %rbp, %rdi
movl $0x5, %esi
callq 0xf1bed
movq %rax, %r15
movq %r14, %rdi
leaq 0x1f1cd(%rip), %rsi     # 0x11e224
movl %r15d, %edx
xorl %eax, %eax
callq 0xe889f
movq 0x90(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1044c1
movq %rbp, %r12
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq (%rbx), %rbp
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movl $0x20, %edx
movq %r12, %rdi
leaq 0x70(%rsp), %r14
movq %r14, %rsi
callq 0xf1cf3
movq %rbp, %rdi
leaq 0x4c39f(%rip), %rsi     # 0x14b458
leaq 0x2e6d2(%rip), %r15     # 0x12d792
movq %r15, %rdx
movq %r14, %rcx
movq %rbp, %r14
xorl %eax, %eax
callq 0xe87e4
movq %rbp, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r12, %rdi
movl $0x9, %esi
callq 0xf1bed
movq %rax, %rbp
movq %r14, %rdi
leaq 0x4c36f(%rip), %rsi     # 0x14b466
movq %r15, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xe87e4
movl %ebp, %edx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x104d0e
movq %rax, 0x98(%rbx)
cmpl %ebp, 0x80(%rbx)
jb 0xff3f3
testl %ebp, %ebp
je 0xff278
movq %r13, 0x20(%rsp)
xorl %r12d, %r12d
movq %rbp, 0x30(%rsp)
movq 0x90(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
movl %eax, %r13d
cmpl $0x2, %eax
ja 0xff16d
movl %r13d, %r15d
testl %r13d, %r13d
je 0xff1d2
movq %r14, %rbp
cmpl $0x1, %r13d
jne 0xff1af
movl $0x2, %r14d
movl $0x4, %esi
jmp 0xff1ba
movl %r13d, %r15d
addl $-0x2, %r15d
movq %r14, %rdi
leaq 0x4c345(%rip), %rsi     # 0x14b4c3
movl %r12d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0xe889f
movq 0x98(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
movl %r12d, %edx
movl %r15d, %ecx
callq 0x1049cc
movl $0x1, %r15d
jmp 0xff1f2
movl $0x13, %r14d
movl $0x9, %esi
movq 0x18(%rsp), %rdi
callq 0xf1bed
movq %rax, %r15
addl %r14d, %r15d
movq %rbp, %r14
movq 0x30(%rsp), %rbp
movq %r14, %rdi
leaq 0x4c2b2(%rip), %rsi     # 0x14b48e
movl %r12d, %edx
movl %r13d, %ecx
movl %r13d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0xe889f
incl %r15d
addl %r15d, %r12d
cmpl %ebp, %r12d
jb 0xff138
cmpb $0x0, 0x50(%rbx)
movq 0x18(%rsp), %r12
movq 0x20(%rsp), %r13
jne 0xff3f3
movq 0x98(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x104a46
testl %eax, %eax
jne 0xff2c3
jmp 0xff3f3
xorl %r13d, %r13d
jmp 0xfee8e
movq %r15, %rdi
leaq 0x4c1a0(%rip), %rsi     # 0x14b3ed
xorl %eax, %eax
callq 0xe87e4
jmp 0xff26f
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r15, %rdi
leaq 0x4c1a1(%rip), %rcx     # 0x14b409
xorl %eax, %eax
callq 0xfa21a
movb $0x1, 0x50(%rbx)
jmp 0xff428
movq %r12, %rdi
movl $0x9, %esi
callq 0xf1bed
movq %rax, %r15
movq %r14, %rdi
leaq 0x1ef92(%rip), %rsi     # 0x11e224
movl %r15d, %edx
xorl %eax, %eax
callq 0xe889f
cmpl %r15d, 0x80(%rbx)
jbe 0xff3f3
movq 0x98(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1044c1
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq (%rbx), %r14
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movl $0x20, %edx
movq %r12, %rdi
leaq 0x70(%rsp), %r15
movq %r15, %rsi
callq 0xf1cf3
movq %r14, %rdi
leaq 0x4c15a(%rip), %rsi     # 0x14b458
leaq 0x29afe(%rip), %rbp     # 0x128e03
movq %rbp, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0xe87e4
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movl 0x84(%rbx), %esi
movq %r12, %rdi
callq 0xf1bed
movq %rax, %r12
movq %r14, %rdi
leaq 0x4c12c(%rip), %rsi     # 0x14b466
movq %rbp, %rdx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xe87e4
cmpl %r12d, 0x88(%rbx)
jb 0xff6da
movl %r12d, %edx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x104d0e
movq %rax, 0xa0(%rbx)
testl %r12d, %r12d
movq %r13, 0x20(%rsp)
je 0xff472
xorl %ebp, %ebp
leaq 0x1eead(%rip), %r13     # 0x11e22d
movq %rbx, %rdi
callq 0x101f44
movl %eax, %r15d
movq %r14, %rdi
movq %r13, %rsi
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe889f
movq 0xa0(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
movl %ebp, %edx
movl %r15d, %ecx
callq 0x1049cc
incl %ebp
cmpl %ebp, %r12d
jne 0xff380
cmpb $0x0, 0x50(%rbx)
movq 0x20(%rsp), %r13
jne 0xff6da
movq 0xa0(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x104a46
testl %eax, %eax
jne 0xff4c0
jmp 0xff6da
movb $0x1, 0x50(%rbx)
movl $0x1, 0x30(%rbx)
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x4bffc(%rip), %rcx     # 0x14b41d
xorl %eax, %eax
callq 0xfa21a
leaq 0x50(%rsp), %r14
movl $0x20, %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xf1cf3
movq %r15, %rdi
leaq 0x4bff3(%rip), %rsi     # 0x14b43a
movq %r14, %rdx
xorl %eax, %eax
callq 0xe889f
movl 0x3c(%rsp), %esi
movq %r15, %rdi
callq 0xe8a25
movl 0x38(%rsp), %ebp
incl %ebp
cmpb $0x0, 0x50(%rbx)
je 0xfede3
jmp 0xfed60
movl 0x84(%rbx), %esi
movq 0x18(%rsp), %rdi
callq 0xf1bed
movq %rax, %r15
movq %r14, %rdi
leaq 0x1ed95(%rip), %rsi     # 0x11e224
movl %r15d, %edx
xorl %eax, %eax
callq 0xe889f
cmpl %r15d, 0x88(%rbx)
jbe 0xff6da
movq 0xa0(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r15d, %r8d
callq 0x1044c1
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movl $0x20, %edx
movq 0x18(%rsp), %r12
movq %r12, %rdi
leaq 0x50(%rsp), %r14
movq %r14, %rsi
callq 0xf1cf3
movq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x1ecf7(%rip), %rsi     # 0x11e1ec
movq %r14, %rdx
xorl %eax, %eax
callq 0xe87e4
testl %r13d, %r13d
je 0xff42d
cmpb $0x0, 0x50(%rbx)
jne 0xff42d
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
cmpb $0x0, 0x50(%rbx)
jne 0xff42d
movl %eax, %r13d
cmpl $0xff, %eax
ja 0xff56c
movq 0x10(%rsp), %rax
cmpl $0x4, (%rax)
jl 0xff555
movq 0x10(%rsp), %rdi
leaq 0x4b5b1(%rip), %rsi     # 0x14aafc
movl %r13d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%rbx), %rdi
movzbl %r13b, %esi
callq 0xfae4e
movq 0x20(%rsp), %rcx
jmp 0xff6be
cmpb $0x0, 0x7d(%rbx)
setne %al
cmpl $0x108, %r13d           # imm = 0x108
setae %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xff5cf
movl $0x202, %eax            # imm = 0x202
cmpl $0x11f, %r13d           # imm = 0x11F
ja 0xff5d9
leal -0x104(%r13), %ebp
shrl $0x2, %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xf1bed
cmpb $0x0, 0x50(%rbx)
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %r15
jne 0xff42d
andl $0x3, %r13d
orl $0x4, %r13d
movl %ebp, %ecx
shll %cl, %r13d
addl %r13d, %eax
addl $0x3, %eax
jmp 0xff5d9
addl $0xffffff03, %r13d      # imm = 0xFFFFFF03
movl %r13d, %eax
movl %eax, 0x30(%rsp)
movq 0xa0(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
cmpb $0x0, 0x50(%rbx)
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %r15
jne 0xff42d
movl %eax, %ebp
cmpb $0x0, 0x7d(%rbx)
je 0xff63e
cmpl $0x4, %ebp
jb 0xff66e
leal -0x2(%rbp), %r13d
shrl %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0xf1bed
cmpb $0x0, 0x50(%rbx)
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %r15
jne 0xff42d
andl $0x1, %ebp
orl $0x2, %ebp
movl %r13d, %ecx
jmp 0xff66a
cmpl $0x2, %ebp
jb 0xff66e
decl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0xf1bed
cmpb $0x0, 0x50(%rbx)
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %r15
jne 0xff42d
movl %ebp, %ecx
movl $0x1, %ebp
shll %cl, %ebp
addl %eax, %ebp
movq 0x10(%rsp), %rdi
cmpl $0x4, (%rdi)
movl 0x30(%rsp), %r14d
jl 0xff691
leal 0x1(%rbp), %edx
leaq 0x4c31d(%rip), %rsi     # 0x14b9a4
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x70(%rbx), %rdi
movl %ebp, %esi
notl %esi
addl 0x10(%rdi), %esi
movl %r14d, %edx
callq 0xfae7b
movl %ebp, %eax
cmpq %rax, 0xc8(%rbx)
movq 0x20(%rsp), %rcx
jg 0xff6be
incq %rax
movq %rax, 0xc8(%rbx)
decl %ecx
movq %rcx, 0x20(%rsp)
leaq 0x50(%rsp), %r14
movq 0x10(%rsp), %r15
jne 0xff508
jmp 0xff42d
movb $0x1, 0x50(%rbx)
movl $0x1, 0x30(%rbx)
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
movq 0x18(%rsp), %r12
jmp 0xff40a