// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/src/fmtutil-lzh.c
// Function: fmtutil_ic1_codectype1
void fmtutil_ic1_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 = "instacomp1";
	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;

	ic1_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 $0x58, %rsp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
movl $0xd0, %esi
callq 0xe8b2b
movq %rax, %rbx
leaq 0x499c8(%rip), %rax     # 0x14b326
movq %rax, 0x20(%rbx)
movq %r13, (%rbx)
movq %r15, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r12, 0x10(%rsp)
movq %r12, 0x18(%rbx)
leaq 0x38(%rbx), %r12
movb $0x0, 0x58(%rbx)
movq (%r15), %rax
movq %rax, 0x38(%rbx)
movq 0x8(%r15), %rax
movq %rax, 0x40(%rbx)
addq 0x10(%r15), %rax
movq %rax, 0x48(%rbx)
movq %r12, %rdi
movl $0x20, %esi
callq 0xf1bed
xorl %r14d, %r14d
movl $0xe, %esi
movq %r13, %r15
movq %r13, %rdi
xorl %edx, %edx
callq 0x104d0e
movq %rax, 0xa8(%rbx)
leaq 0x4a149(%rip), %r13     # 0x14bb0e
leaq 0x4a150(%rip), %rbp     # 0x14bb1c
movq 0xa8(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x4a122(%rip), %rax     # 0x14bb00
movzbl (%r14,%rax), %edx
movzbl (%r14,%r13), %ecx
movzbl (%r14,%rbp), %r8d
movq %r15, %rdi
callq 0x1044c1
incq %r14
cmpq $0xe, %r14
jne 0x1019cc
movq (%rbx), %rdi
movl $0x20000, %esi          # imm = 0x20000
callq 0xfad8f
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq -0x44a(%rip), %rcx      # 0x1015cf
movq %rcx, 0x8(%rax)
movb $0x1, %bpl
movl $0x10000, %eax          # imm = 0x10000
movq %rax, 0x8(%rsp)
movq %r15, (%rsp)
cmpl $0x4, (%r15)
jl 0x101a61
movl $0x20, %edx
movq %r12, %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0xf1cf3
movzbl %bpl, %ecx
movq %r15, %rdi
leaq 0x49f0b(%rip), %rsi     # 0x14b962
movq %r14, %rdx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x50(%rbx)
jne 0x101de5
cmpl $0x0, 0x30(%rbx)
jne 0x101deb
movq 0x10(%rbx), %rcx
movq 0x28(%rbx), %rax
cmpb $0x0, 0x8(%rcx)
je 0x101a8d
cmpq 0x10(%rcx), %rax
jge 0x101de5
cmpq 0x8(%rsp), %rax
jl 0x101ad0
movq %r12, %rdi
callq 0xf1c84
cmpl $0x3, (%r15)
jl 0x101ab7
movq 0x40(%rbx), %rdx
movq %r15, %rdi
leaq 0x49ec0(%rip), %rsi     # 0x14b970
xorl %eax, %eax
callq 0xe8617
movq %r12, %rdi
movl $0x20, %esi
callq 0xf1bed
addq $0x10000, 0x8(%rsp)     # imm = 0x10000
movb $0x1, %bpl
movq 0xa8(%rbx), %rsi
movq %rbx, %rdi
callq 0x101e47
movl %eax, %r14d
cmpl $0x64, %eax
jl 0x101b4d
movl $0x3, %esi
cmpl $0x67, %r14d
je 0x101b00
cmpl $0x68, %r14d
jne 0x101b08
movl $0x13, %r15d
jmp 0x101b3b
movl $0xb, %r15d
jmp 0x101b3b
xorl %ecx, %ecx
movl %ecx, %r14d
cmpl $0x5, %ecx
je 0x101b27
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
leal 0x1(%r14), %ecx
testb %al, %al
jne 0x101b0a
leal 0x5(%r14), %esi
movl $0x20, %r15d
movl %r14d, %ecx
shll %cl, %r15d
addl $-0x5, %r15d
movq %r12, %rdi
callq 0xf1bed
movq %rax, %r14
addl %r15d, %r14d
movq (%rsp), %r15
cmpl $0x0, 0x30(%rbx)
jne 0x101deb
testl %r14d, %r14d
jne 0x101bf0
testb %bpl, %bpl
je 0x101bf0
xorl %ecx, %ecx
movl %ecx, %r15d
cmpl $0x5, %ecx
je 0x101b88
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
leal 0x1(%r15), %ecx
testb %al, %al
jne 0x101b6b
movq %r12, %rdi
movl %r15d, %esi
callq 0xf1bed
movq %rax, %r14
btsl %r15d, %r14d
movq (%rsp), %r15
cmpl $0x4, (%r15)
jl 0x101bbc
movq 0x28(%rbx), %rdx
movq %r15, %rdi
leaq 0x49e02(%rip), %rsi     # 0x14b9b4
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe8617
cmpl $0x1, %r14d
movl %r14d, %ebp
adcl $0x0, %ebp
movq %r12, %rdi
movl $0x8, %esi
callq 0xf1bed
movq 0x70(%rbx), %rdi
movzbl %al, %esi
callq 0xfae4e
decl %ebp
jne 0x101bc6
cmpl $0x3f, %r14d
setae %bpl
jmp 0x101a2e
cmpb $0x1, %bpl
adcl $0x2, %r14d
movq 0x28(%rbx), %rax
movl $0x2, %edx
cmpq $0xb, %rax
jl 0x101c84
movl $0x3, %edx
cmpq $0x15, %rax
jb 0x101c84
movl $0x4, %edx
cmpq $0x29, %rax
jb 0x101c84
movl $0x5, %edx
cmpq $0x51, %rax
jb 0x101c84
movl $0x6, %edx
cmpq $0xa1, %rax
jb 0x101c84
movl $0x7, %edx
cmpq $0x2a1, %rax            # imm = 0x2A1
jb 0x101c84
movl $0x8, %edx
cmpq $0x3e9, %rax            # imm = 0x3E9
jb 0x101c84
movl $0x9, %edx
cmpq $0xa81, %rax            # imm = 0xA81
jb 0x101c84
movl $0xa, %edx
cmpq $0x1501, %rax           # imm = 0x1501
jb 0x101c84
movl $0xb, %edx
cmpq $0x2a01, %rax           # imm = 0x2A01
jb 0x101c84
cmpq $0x5401, %rax           # imm = 0x5401
movl $0xd, %edx
sbbl $0x0, %edx
movq %rax, 0x28(%rsp)
leal -0x2(%rdx), %r15d
movl $0x1, %ebp
movl %r15d, %ecx
shll %cl, %ebp
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
leal -0x3(%rdx), %ecx
movl $0xa, %r13d
shll %cl, %r13d
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
movq %r12, %rdi
cmpb $0x1, %al
jne 0x101d0c
movl $0x1, %esi
callq 0xf1bed
testb %al, %al
je 0x101d19
movq 0x28(%rsp), %r8
cmpq $0xb, %r8
movq (%rsp), %r15
jge 0x101d81
movl $0x1, 0x30(%rbx)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
xorl %r13d, %r13d
movq 0x18(%rsp), %rdi
leaq 0x49cc3(%rip), %rcx     # 0x14b9c6
xorl %eax, %eax
callq 0xfa21a
jmp 0x101d2f
movl %r15d, %esi
callq 0xf1bed
movq %rax, %r13
jmp 0x101d2b
movq %r12, %rdi
movq 0x20(%rsp), %rsi
callq 0xf1bed
addl %eax, %ebp
movl %ebp, %r13d
movq (%rsp), %r15
cmpl $0x0, 0x30(%rbx)
jne 0x101deb
movl %r13d, %eax
movq 0x28(%rbx), %rdx
cmpq %rax, %rdx
jl 0x101dc2
cmpl $0x4, (%r15)
jl 0x101d63
leal 0x1(%r13), %ecx
movq %r15, %rdi
leaq 0x49c44(%rip), %rsi     # 0x14b99d
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe8617
movq 0x70(%rbx), %rdi
notl %r13d
addl 0x10(%rdi), %r13d
movl %r13d, %esi
movl %r14d, %edx
callq 0xfae7b
movb $0x1, %bpl
jmp 0x101a2e
leaq -0x66c(%r8), %rax
movl $0xb, %esi
cmpq $0x15, %rax
jb 0x101db2
movl $0xf, %esi
cmpq $0xa800, %r8            # imm = 0xA800
ja 0x101db2
movl %r13d, %eax
subq %rax, %r8
movq %r8, %rdi
callq 0xe9cd4
movq %rax, %rsi
movq %r12, %rdi
callq 0xf1bed
addl %eax, %r13d
jmp 0x101d2f
movl $0x1, 0x30(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
leaq 0x49bac(%rip), %rcx     # 0x14b987
movl %r13d, %r8d
xorl %eax, %eax
callq 0xfa21a
cmpl $0x0, 0x30(%rbx)
je 0x101e1c
movq 0x20(%rbx), %rdx
leaq 0x49504(%rip), %rcx     # 0x14b2fa
movq %r15, %rdi
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0xfa21a
movq %rbx, %rdi
callq 0xff6fb
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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)
jmp 0x101e05