// File: /workspace/github_c_makefile_star2_O2/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 $0x68, %rsp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
movl $0xd0, %esi
callq 0xdecaf
movq %rax, %rbx
leaq 0x48532(%rip), %rax     # 0x13de56
movq %rax, 0x20(%rbx)
movq %r13, (%rbx)
movq %r15, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r12, 0x20(%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)
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0xe6a4a
xorl %r14d, %r14d
pushq $0xe
popq %rsi
movq %r13, 0x8(%rsp)
movq %r13, %rdi
xorl %edx, %edx
callq 0xf8601
movq %rax, 0xa8(%rbx)
movq %rbx, %rax
addq $0xa8, %rax
movq %rax, 0x18(%rsp)
leaq 0x48c99(%rip), %r15     # 0x13e630
leaq 0x48ca0(%rip), %r13     # 0x13e63e
leaq 0x48ca7(%rip), %rbp     # 0x13e64c
cmpq $0xe, %r14
je 0xf59d5
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rsi
movzbl (%r14,%r15), %edx
movzbl (%r14,%r13), %ecx
movzbl (%r14,%rbp), %r8d
movq 0x8(%rsp), %rdi
callq 0xf7e56
incq %r14
jmp 0xf59a5
movq (%rbx), %rdi
movl $0x20000, %esi          # imm = 0x20000
callq 0xef27c
movq %rax, 0x70(%rbx)
movq %rbx, (%rax)
leaq -0x3bd(%rip), %rcx      # 0xf5633
movq %rcx, 0x8(%rax)
movb $0x1, %bpl
movl $0x10000, %eax          # imm = 0x10000
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
jl 0xf5a38
movq %r12, %rdi
leaq 0x40(%rsp), %r14
movq %r14, %rsi
pushq $0x20
popq %rdx
callq 0xe6b25
movzbl %bpl, %ecx
movq 0x8(%rsp), %rdi
leaq 0x48a64(%rip), %rsi     # 0x13e492
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x50(%rbx)
jne 0xf5d79
cmpl $0x0, 0x30(%rbx)
jne 0xf5d7f
movq %rbx, %rdi
callq 0xf5ddd
testl %eax, %eax
jne 0xf5d9d
movq 0x10(%rsp), %rax
cmpq %rax, 0x28(%rbx)
jl 0xf5aa7
movq %r12, %rdi
callq 0xe6abe
movq 0x8(%rsp), %rax
cmpl $0x3, (%rax)
jl 0xf5a90
movq 0x40(%rbx), %rdx
movq 0x8(%rsp), %rdi
leaq 0x48a17(%rip), %rsi     # 0x13e4a0
xorl %eax, %eax
callq 0xde896
movq %r12, %rdi
pushq $0x20
popq %rsi
callq 0xe6a4a
addq $0x10000, 0x10(%rsp)    # imm = 0x10000
movb $0x1, %bpl
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0xf5df8
movl %eax, %r14d
cmpl $0x64, %eax
jl 0xf5b04
pushq $0xb
popq %r15
pushq $0x3
popq %rsi
cmpl $0x67, %r14d
je 0xf5af6
cmpl $0x68, %r14d
jne 0xf5ad5
pushq $0x13
popq %r15
jmp 0xf5af6
movq %rbx, %rdi
callq 0xf6419
movl %eax, %esi
addl $0x5, %esi
pushq $0x1
popq %r15
movl %esi, %ecx
shll %cl, %r15d
addl $-0x5, %r15d
movl %r15d, %r14d
testl %esi, %esi
je 0xf5b04
movq %r12, %rdi
callq 0xe6a4a
movq %rax, %r14
addl %r15d, %r14d
cmpl $0x0, 0x30(%rbx)
jne 0xf5d7f
testl %r14d, %r14d
jne 0xf5b80
testb %bpl, %bpl
je 0xf5b80
movq %rbx, %rdi
callq 0xf6419
movl %eax, %ebp
movq %r12, %rdi
movl %eax, %esi
callq 0xe6a4a
movq %rax, %r14
btsl %ebp, %r14d
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
pushq $0x8
popq %r15
jl 0xf5b5b
movq 0x28(%rbx), %rdx
movq 0x8(%rsp), %rdi
leaq 0x48993(%rip), %rsi     # 0x13e4e4
movl %r14d, %ecx
xorl %eax, %eax
callq 0xde896
movl %r14d, %ebp
subl $0x1, %ebp
jb 0xf5c98
movq %r12, %rdi
movl %r15d, %esi
callq 0xe6a4a
movq 0x70(%rbx), %rdi
movzbl %al, %esi
callq 0xef336
jmp 0xf5b5e
cmpb $0x1, %bpl
adcl $0x2, %r14d
movq 0x28(%rbx), %rcx
pushq $0x2
popq %rax
movl %eax, %edx
cmpq $0xb, %rcx
jl 0xf5c1f
pushq $0x3
popq %rax
movl %eax, %edx
cmpq $0x15, %rcx
jb 0xf5c1f
pushq $0x4
popq %rax
movl %eax, %edx
cmpq $0x29, %rcx
jb 0xf5c1f
pushq $0x5
popq %rax
movl %eax, %edx
cmpq $0x51, %rcx
jb 0xf5c1f
pushq $0x6
popq %rax
movl %eax, %edx
cmpq $0xa1, %rcx
jb 0xf5c1f
pushq $0x7
popq %rax
movl %eax, %edx
cmpq $0x2a1, %rcx            # imm = 0x2A1
jb 0xf5c1f
pushq $0x8
popq %rax
movl %eax, %edx
cmpq $0x3e9, %rcx            # imm = 0x3E9
jb 0xf5c1f
pushq $0x9
popq %rax
movl %eax, %edx
cmpq $0xa81, %rcx            # imm = 0xA81
jb 0xf5c1f
pushq $0xa
popq %rax
movl %eax, %edx
cmpq $0x1501, %rcx           # imm = 0x1501
jb 0xf5c1f
pushq $0xb
popq %rax
movl %eax, %edx
cmpq $0x2a01, %rcx           # imm = 0x2A01
jb 0xf5c1f
cmpq $0x5401, %rcx           # imm = 0x5401
pushq $0xd
popq %rax
movl %eax, %edx
sbbl $0x0, %edx
movq %rcx, 0x38(%rsp)
leal -0x2(%rdx), %ebp
pushq $0x1
popq %rsi
movl %esi, %r15d
movl %ebp, %ecx
shll %cl, %r15d
movq (%rbx), %rax
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
leal -0x3(%rdx), %ecx
pushq $0xa
popq %rax
movl %eax, %r13d
shll %cl, %r13d
movq %r12, %rdi
callq 0xe6a4a
movq %r12, %rdi
cmpb $0x1, %al
jne 0xf5ca5
pushq $0x1
popq %rsi
callq 0xe6a4a
testb %al, %al
je 0xf5cb1
movq 0x38(%rsp), %r8
cmpq $0xb, %r8
jge 0xf5cc6
movl $0x1, 0x30(%rbx)
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
xorl %r13d, %r13d
movq 0x28(%rsp), %rdi
leaq 0x48867(%rip), %rcx     # 0x13e4f6
xorl %eax, %eax
callq 0xee823
jmp 0xf5d02
cmpl $0x3f, %r14d
setae %bpl
jmp 0xf5a01
movl %ebp, %esi
callq 0xe6a4a
movq %rax, %r13
jmp 0xf5d02
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq 0xe6a4a
addl %eax, %r15d
movl %r15d, %r13d
jmp 0xf5d02
leaq -0x66c(%r8), %rax
pushq $0xb
popq %rcx
movl %ecx, %esi
cmpq $0x15, %rax
jb 0xf5cf7
pushq $0xf
popq %rax
movl %eax, %esi
cmpq $0xa800, %r8            # imm = 0xA800
ja 0xf5cf7
movl %r13d, %eax
subq %rax, %r8
movq %r8, %rdi
callq 0xdfbd6
movq %rax, %rsi
movq %r12, %rdi
callq 0xe6a4a
addl %eax, %r13d
cmpl $0x0, 0x30(%rbx)
jne 0xf5d7f
movl %r13d, %eax
movq 0x28(%rbx), %rdx
cmpq %rax, %rdx
jl 0xf5d56
movq 0x8(%rsp), %rax
cmpl $0x4, (%rax)
jl 0xf5d38
leal 0x1(%r13), %ecx
movq 0x8(%rsp), %rdi
leaq 0x4879f(%rip), %rsi     # 0x13e4cd
movl %r14d, %r8d
xorl %eax, %eax
callq 0xde896
movq 0x70(%rbx), %rdi
notl %r13d
addl 0x10(%rdi), %r13d
movl %r13d, %esi
movl %r14d, %edx
callq 0xef363
movb $0x1, %bpl
jmp 0xf5a01
movl $0x1, 0x30(%rbx)
movq (%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
leaq 0x48748(%rip), %rcx     # 0x13e4b7
movl %r13d, %r8d
xorl %eax, %eax
callq 0xee823
cmpl $0x0, 0x30(%rbx)
je 0xf5d9d
movq 0x20(%rbx), %rdx
leaq 0x480a0(%rip), %rcx     # 0x13de2a
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0xee823
jmp 0xf5dc6
movq %r12, %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 $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq