// File: /workspace/github_c_makefile_star2_O2/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 $0xb8, %rsp
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
movl $0xd0, %esi
callq 0xdecaf
movq %rax, %rbx
leaq 0x4b020(%rip), %rcx     # 0x13de00
movq %rcx, 0x20(%rax)
movq %r13, 0x40(%rsp)
movq %r13, (%rax)
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r12, 0x58(%rsp)
movq %r12, 0x18(%rax)
movq (%r15), %rcx
leaq 0x38(%rax), %r13
movq %rcx, 0x38(%rax)
movq 0x8(%r15), %rcx
movq %rcx, 0x40(%rax)
addq 0x10(%r15), %rcx
movq %rcx, 0x48(%rax)
movq %rax, %r15
movl $0x1fe, 0x80(%rax)      # imm = 0x1FE
movq %rbp, 0x60(%rsp)
movl (%rbp), %eax
cmpl $0x5, %eax
je 0xf2e7b
cmpl $0x64, %eax
je 0xf2e54
cmpl $0x7, %eax
je 0xf2e6c
cmpl $0x6, %eax
jne 0xf37ef
movsd 0x4afa3(%rip), %xmm0    # 0x13ddf0
movl $0x8000, %esi           # imm = 0x8000
jmp 0xf2e88
movb $0x1, 0x7d(%rbx)
movl $0x121, 0x80(%rbx)      # imm = 0x121
movsd 0x4af66(%rip), %xmm0    # 0x13ddd0
jmp 0xf2e74
movsd 0x4af6c(%rip), %xmm0    # 0x13dde0
movl $0x10000, %esi          # imm = 0x10000
jmp 0xf2e88
movsd 0x4af3d(%rip), %xmm0    # 0x13ddc0
movl $0x2000, %esi           # imm = 0x2000
movlps %xmm0, 0x84(%rbx)
movq 0x60(%rsp), %r14
movb 0x4(%r14), %al
movb %al, 0x68(%rbx)
movb 0x5(%r14), %al
movb %al, 0x69(%rbx)
movq 0x40(%rsp), %rdi
callq 0xef27c
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq 0x23d9(%rip), %rcx      # 0xf5293
movq %rcx, 0x8(%rax)
movzbl 0x6(%r14), %esi
testl %esi, %esi
je 0xf2ecf
movq %rax, %rdi
callq 0xef2e9
leaq 0x90(%r15), %rax
movq %rax, 0x48(%rsp)
leaq 0x98(%r15), %rax
movq %rax, 0x38(%rsp)
addq $0xa0, %r15
movq %r15, 0x30(%rsp)
leaq 0x24(%rsp), %r14
leaq 0x70(%rsp), %r15
xorl %ebp, %ebp
cmpb $0x0, 0x50(%rbx)
jne 0xf380e
movq %rbx, %rdi
callq 0xf5ddd
testl %eax, %eax
jne 0xf380e
movq (%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0xdebae
movq %r13, %rdi
movq %r15, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %r13, %rdi
pushq $0x10
popq %rsi
callq 0xe6a4a
cmpb $0x0, 0x50(%rbx)
movl %ebp, 0x54(%rsp)
movq %r12, %rdi
je 0xf2f63
leaq 0x4af3a(%rip), %rsi     # 0x13de8e
movq %r15, %rdx
xorl %eax, %eax
callq 0xde9f1
jmp 0xf3521
leaq 0x4af50(%rip), %rsi     # 0x13deba
movl %ebp, %edx
movq %r15, %rcx
movq %rax, %r15
xorl %eax, %eax
callq 0xde9f1
movq %r12, 0x10(%rsp)
movq %r12, %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0xdeba7
movq (%rbx), %rdi
leaq 0x4af34(%rip), %rsi     # 0x13dec9
movl %r15d, %edx
xorl %eax, %eax
callq 0xde9f1
testl %r15d, %r15d
jne 0xf2ff3
cmpb $0x0, 0x69(%rbx)
movq 0x10(%rsp), %r12
je 0xf2fca
cmpb $0x0, 0x6a(%rbx)
jne 0xf2fca
movq %r12, %rdi
leaq 0x4af21(%rip), %rsi     # 0x13dee0
xorl %eax, %eax
callq 0xdf05a
movb $0x1, 0x6a(%rbx)
movzbl 0x68(%rbx), %eax
cmpl $0x1, %eax
je 0xf3360
cmpl $0x2, %eax
je 0xf2fed
cmpl $0x3, %eax
jne 0xf3373
movl $0x10000, %r15d         # imm = 0x10000
jmp 0xf2ff0
xorl %r15d, %r15d
pushq $0x1
popq %rbp
movq %r15, 0x68(%rsp)
movq %rbx, %rdi
callq 0xf5e7a
movq (%rbx), %r15
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
movq %r13, %rdi
leaq 0x90(%rsp), %r14
movq %r14, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %r15, %rdi
leaq 0x4af58(%rip), %rsi     # 0x13df88
leaq 0x4af44(%rip), %r12     # 0x13df7b
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xde9f1
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq %r13, %rdi
pushq $0x5
popq %rbp
movl %ebp, %esi
callq 0xe6a4a
movq %rax, %r14
movq %r15, %rdi
leaq 0x4af2e(%rip), %rsi     # 0x13df96
movq %r12, %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xde9f1
cmpl $0x14, %r14d
pushq $0x14
popq %rax
movl %eax, %r12d
cmovbl %r14d, %r12d
movq %r15, %rdi
movq %r12, %rsi
movq %r12, %rdx
callq 0xf8601
movq %rax, 0x90(%rbx)
testl %r14d, %r14d
je 0xf3137
xorl %ebp, %ebp
cmpl %r12d, %ebp
jae 0xf311a
movq %rbx, %rdi
callq 0xf5ef0
movl %eax, %r14d
movq %r15, %rdi
leaq 0x1e09c(%rip), %rsi     # 0x111159
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xdea83
movq 0x90(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r15, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xf82ee
incl %ebp
cmpl $0x3, %ebp
jne 0xf30a3
movq %r13, %rdi
pushq $0x2
popq %rsi
callq 0xe6a4a
movq %rax, %r14
pushq $0x3
popq %rbp
testl %r14d, %r14d
je 0xf30a3
movq %r15, %rdi
leaq 0x4aea8(%rip), %rsi     # 0x13dfaf
movl %r14d, %edx
xorl %eax, %eax
callq 0xdea83
addl $0x3, %r14d
movl %r14d, %ebp
jmp 0xf30a3
cmpb $0x0, 0x50(%rbx)
je 0xf3175
movb $0x1, 0x50(%rbx)
movl $0x1, 0x30(%rbx)
movl 0xc(%rsp), %esi
movq %r15, %rdi
jmp 0xf34f1
movq %r13, %rdi
movl %ebp, %esi
callq 0xe6a4a
movq %rax, %r14
movq %r15, %rdi
leaq 0x1e002(%rip), %rsi     # 0x111150
movl %r14d, %edx
xorl %eax, %eax
callq 0xdea83
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0xf7e56
jmp 0xf3196
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf8362
testl %eax, %eax
je 0xf3120
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0xdebb7
movq (%rbx), %r12
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
movq %r13, %rdi
leaq 0x90(%rsp), %r14
movq %r14, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %r12, %rdi
leaq 0x4adb6(%rip), %rsi     # 0x13df88
leaq 0x2d349(%rip), %r15     # 0x120522
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xde9f1
movq %r12, %rdi
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0xdeba7
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0xe6a4a
movq %rax, %r14
movq %r12, %rdi
leaq 0x4ad8b(%rip), %rsi     # 0x13df96
movq %r15, %rdx
movl %r14d, %ecx
xorl %eax, %eax
callq 0xde9f1
movl %r14d, %edx
movq %r12, %rdi
movq %rdx, %rsi
callq 0xf8601
movq %rax, 0x98(%rbx)
cmpl %r14d, 0x80(%rbx)
jb 0xf34df
movq %r14, 0x28(%rsp)
testl %r14d, %r14d
je 0xf339a
movq %r12, 0x18(%rsp)
xorl %ebp, %ebp
movq 0x28(%rsp), %r15
cmpl %r15d, %ebp
jae 0xf3324
movq %r13, %r12
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
callq 0xf5df8
movl %eax, %r13d
cmpl $0x2, %eax
ja 0xf32c7
movl %r13d, %r14d
testl %r13d, %r13d
je 0xf32a4
pushq $0x4
popq %rsi
pushq $0x2
popq %r15
cmpl $0x1, %r13d
je 0xf3291
pushq $0x9
popq %rsi
pushq $0x13
popq %r15
movq %r12, %rdi
callq 0xe6a4a
movq %rax, %r14
addl %r15d, %r14d
movq 0x28(%rsp), %r15
movq 0x18(%rsp), %rdi
leaq 0x4ad0e(%rip), %rsi     # 0x13dfbe
movl %ebp, %edx
movl %r13d, %ecx
movl %r13d, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0xdea83
incl %r14d
jmp 0xf3316
movl %r13d, %r14d
addl $-0x2, %r14d
movq %rbx, %r15
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x4ad13(%rip), %rsi     # 0x13dff3
movl %ebp, %edx
movl %r13d, %ecx
movl %r14d, %r8d
xorl %eax, %eax
callq 0xdea83
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rsi
movq %rbx, %rdi
movq %r15, %rbx
movq 0x28(%rsp), %r15
movl %ebp, %edx
movl %r14d, %ecx
callq 0xf82ee
pushq $0x1
popq %rax
movl %eax, %r14d
addl %ebp, %r14d
movl %r14d, %ebp
movq %r12, %r13
jmp 0xf3254
cmpb $0x0, 0x50(%rbx)
pushq $0x1
popq %rbp
movq 0x18(%rsp), %r12
jne 0xf34df
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf8362
testl %eax, %eax
jne 0xf33e4
jmp 0xf34df
movq %r12, %rdi
leaq 0x4abb3(%rip), %rsi     # 0x13df1d
xorl %eax, %eax
callq 0xde9f1
jmp 0xf338c
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %r12, %rdi
leaq 0x4abb4(%rip), %rcx     # 0x13df39
xorl %eax, %eax
callq 0xee823
movb $0x1, 0x50(%rbx)
leaq 0x70(%rsp), %r15
jmp 0xf3521
movq %r13, %rdi
pushq $0x9
popq %rsi
callq 0xe6a4a
movq %rax, %r14
movq %r12, %rdi
leaq 0x1dd9e(%rip), %rsi     # 0x111150
movl %r14d, %edx
xorl %eax, %eax
callq 0xdea83
cmpl %r14d, 0x80(%rbx)
jbe 0xf34df
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0xf7e56
movl 0xc(%rsp), %esi
movq %r12, %rdi
callq 0xdebb7
movq (%rbx), %r15
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
movq %r13, %rdi
leaq 0x90(%rsp), %r14
movq %r14, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %r15, %rdi
leaq 0x4ab68(%rip), %rsi     # 0x13df88
leaq 0x2879c(%rip), %rdx     # 0x11bbc3
movq %r14, %rcx
xorl %eax, %eax
callq 0xde9f1
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movl 0x84(%rbx), %esi
movq %r13, %rdi
callq 0xe6a4a
movq %rax, %r12
movq %r15, %rdi
leaq 0x4ab40(%rip), %rsi     # 0x13df96
leaq 0x28766(%rip), %rdx     # 0x11bbc3
movl %r12d, %ecx
xorl %eax, %eax
callq 0xde9f1
cmpl %r12d, 0x88(%rbx)
movq 0x10(%rsp), %rbp
jb 0xf37d3
movl %r12d, %edx
movq %r15, %rdi
movq %rdx, %rsi
callq 0xf8601
movq 0x30(%rsp), %rcx
movq %rax, (%rcx)
testl %r12d, %r12d
je 0xf358f
xorl %ebp, %ebp
cmpl %ebp, %r12d
je 0xf355a
movq %rbx, %rdi
callq 0xf5ef0
movl %eax, %r14d
movq %r15, %rdi
leaq 0x1dca1(%rip), %rsi     # 0x111159
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xdea83
movq 0xa0(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r15, %rdi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xf82ee
incl %ebp
jmp 0xf349a
movb $0x1, 0x50(%rbx)
movl $0x1, 0x30(%rbx)
movl 0xc(%rsp), %esi
movq %r12, %rdi
callq 0xdebb7
movq 0x10(%rsp), %rbp
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movq %rbp, %rdi
leaq 0x4aa40(%rip), %rcx     # 0x13df4d
xorl %eax, %eax
callq 0xee823
leaq 0x24(%rsp), %r14
leaq 0x70(%rsp), %r15
movq %rbp, %r12
movq %r13, %rdi
movq %r15, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %r12, %rdi
leaq 0x4aa31(%rip), %rsi     # 0x13df6a
movq %r15, %rdx
xorl %eax, %eax
callq 0xdea83
movl 0x24(%rsp), %esi
movq %r12, %rdi
callq 0xdebb7
movl 0x54(%rsp), %ebp
incl %ebp
jmp 0xf2eff
cmpb $0x0, 0x50(%rbx)
movq 0x10(%rsp), %rbp
jne 0xf37d3
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xf8362
testl %eax, %eax
jne 0xf35dc
jmp 0xf37d3
movl 0x84(%rbx), %esi
movq %r13, %rdi
callq 0xe6a4a
movq %rax, %r14
movq %r15, %rdi
leaq 0x1dba6(%rip), %rsi     # 0x111150
movl %r14d, %edx
xorl %eax, %eax
callq 0xdea83
cmpl %r14d, 0x88(%rbx)
jbe 0xf37d3
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0xf7e56
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0xdebb7
movq %r13, %rdi
leaq 0x70(%rsp), %r14
movq %r14, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movq %rbp, %rdi
leaq 0x1db13(%rip), %rsi     # 0x111118
movq %r14, %rdx
xorl %eax, %eax
callq 0xde9f1
leaq 0x24(%rsp), %r14
movq 0x68(%rsp), %rax
subl $0x1, %eax
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %r12
jb 0xf3521
cmpb $0x0, 0x50(%rbx)
jne 0xf3521
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
callq 0xf5df8
cmpb $0x0, 0x50(%rbx)
jne 0xf3521
movl %eax, %ebp
cmpl $0xff, %eax
ja 0xf3684
movq 0x10(%rsp), %rdi
cmpl $0x4, (%rdi)
jl 0xf3675
leaq 0x49fc0(%rip), %rsi     # 0x13d62c
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
movq 0x70(%rbx), %rdi
movzbl %bpl, %esi
callq 0xef336
jmp 0xf3614
cmpb $0x0, 0x7d(%rbx)
setne %al
cmpl $0x108, %ebp            # imm = 0x108
setae %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xf36e4
movl $0x202, %eax            # imm = 0x202
cmpl $0x11f, %ebp            # imm = 0x11F
ja 0xf36ec
leal -0x104(%rbp), %esi
shrl $0x2, %esi
movq %r13, %rdi
movl %esi, 0x18(%rsp)
callq 0xe6a4a
cmpb $0x0, 0x50(%rbx)
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %r12
jne 0xf3521
andl $0x3, %ebp
orl $0x4, %ebp
movl 0x18(%rsp), %ecx
shll %cl, %ebp
addl %ebp, %eax
addl $0x3, %eax
jmp 0xf36ec
addl $0xffffff03, %ebp       # imm = 0xFFFFFF03
movl %ebp, %eax
movl %eax, 0x18(%rsp)
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xf5df8
cmpb $0x0, 0x50(%rbx)
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %r12
jne 0xf3521
movl %eax, %ebp
cmpb $0x0, 0x7d(%rbx)
je 0xf374f
cmpl $0x4, %ebp
jb 0xf377f
leal -0x2(%rbp), %esi
shrl %esi
movq %r13, %rdi
movl %esi, 0x28(%rsp)
callq 0xe6a4a
cmpb $0x0, 0x50(%rbx)
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %r12
jne 0xf3521
andl $0x1, %ebp
orl $0x2, %ebp
movl 0x28(%rsp), %ecx
jmp 0xf377b
cmpl $0x2, %ebp
jb 0xf377f
decl %ebp
movq %r13, %rdi
movl %ebp, %esi
callq 0xe6a4a
cmpb $0x0, 0x50(%rbx)
leaq 0x70(%rsp), %r15
movq 0x10(%rsp), %r12
jne 0xf3521
movl %ebp, %ecx
pushq $0x1
popq %rdx
movl %edx, %ebp
shll %cl, %ebp
addl %eax, %ebp
movq 0x10(%rsp), %rdi
cmpl $0x4, (%rdi)
movl 0x18(%rsp), %r15d
jl 0xf37a2
leal 0x1(%rbp), %edx
leaq 0x4ad3c(%rip), %rsi     # 0x13e4d4
movl %r15d, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x70(%rbx), %rdi
movl %ebp, %esi
notl %esi
addl 0x10(%rdi), %esi
movl %r15d, %edx
callq 0xef363
movl %ebp, %eax
cmpq %rax, 0xc8(%rbx)
jg 0xf3614
incq %rax
movq %rax, 0xc8(%rbx)
jmp 0xf3614
movb $0x1, 0x50(%rbx)
movl $0x1, 0x30(%rbx)
movl 0xc(%rsp), %esi
movq %r15, %rdi
callq 0xdebb7
jmp 0xf34fb
leaq 0x4a60a(%rip), %rdx     # 0x13de00
leaq 0x4a664(%rip), %rcx     # 0x13de61
movq 0x40(%rsp), %rdi
movq 0x58(%rsp), %rsi
xorl %eax, %eax
callq 0xee823
movq 0xc8(%rbx), %rax
movq 0x60(%rsp), %rcx
movq %rax, 0x8(%rcx)
cmpl $0x0, 0x30(%rbx)
je 0xf3842
movq 0x20(%rbx), %rdx
leaq 0x1d889(%rip), %rcx     # 0x1110b8
movq 0x40(%rsp), %rdi
movq 0x58(%rsp), %rsi
xorl %eax, %eax
callq 0xee823
jmp 0xf386b
movq %r13, %rdi
callq 0xe6abe
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 0xf3885
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq