// File: /workspace/github_c_makefile_star2_O1/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 $0x88, %rsp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r15
movl $0xd0, %esi
callq 0xe969b
movq %rax, %rbx
leaq 0x48b9e(%rip), %rax     # 0x14ad2f
movq %rax, 0x20(%rbx)
movq %r15, (%rbx)
movq %r13, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %r12, 0x40(%rsp)
movq %r12, 0x18(%rbx)
leaq 0x38(%rbx), %rdi
movb $0x0, 0x58(%rbx)
movq (%r13), %rax
movq %rax, 0x38(%rbx)
movq 0x8(%r13), %rax
movq %rax, 0x40(%rbx)
addq 0x10(%r13), %rax
movq %rax, 0x48(%rbx)
movq %rdi, 0x50(%rsp)
movl $0x20, %esi
callq 0xf2271
xorl %r14d, %r14d
movl $0xe, %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x105165
movq %rax, 0xa8(%rbx)
movq %rbx, 0x48(%rsp)
addq $0xa8, %rbx
leaq 0x4930c(%rip), %rbp     # 0x14b510
leaq 0x49313(%rip), %r13     # 0x14b51e
leaq 0x4931a(%rip), %r12     # 0x14b52c
movq (%rbx), %rax
movq 0x8(%rax), %rsi
movzbl (%r14,%rbp), %edx
movzbl (%r14,%r13), %ecx
movzbl (%r14,%r12), %r8d
movq %r15, %rdi
callq 0x104901
incq %r14
cmpq $0xe, %r14
jne 0x102212
movq 0x48(%rsp), %r14
movq (%r14), %rdi
movl $0x20000, %esi          # imm = 0x20000
callq 0xfb2c3
movq %rax, 0x70(%r14)
movq %r14, (%rax)
leaq -0x4c3(%rip), %rcx      # 0x101d96
movq %rcx, 0x8(%rax)
movb $0x1, 0xf(%rsp)
movl $0x10000, %eax          # imm = 0x10000
movq %rax, 0x20(%rsp)
leaq 0x60(%rsp), %rbp
leaq 0x490f3(%rip), %r13     # 0x14b36b
movq 0x50(%rsp), %r12
movq %rbx, 0x58(%rsp)
movq %r15, %rbx
movq %r14, %r15
cmpl $0x4, (%rbx)
jl 0x1022b2
movl $0x20, %edx
movq %r12, %rdi
movq %rbp, %rsi
callq 0xf2360
movzbl 0xf(%rsp), %ecx
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x50(%r15)
jne 0x1022c0
cmpl $0x0, 0x30(%r15)
je 0x1022cd
xorl %r14d, %r14d
testb %r14b, %r14b
jne 0x102288
jmp 0x102690
movq 0x10(%r15), %rax
cmpb $0x0, 0x8(%rax)
je 0x1022e1
movq 0x28(%r15), %rcx
cmpq 0x10(%rax), %rcx
jge 0x1022c0
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%r15)
jl 0x102329
movq %r12, %rdi
callq 0xf22f1
cmpl $0x3, (%rbx)
jl 0x10230e
movq 0x40(%r15), %rdx
movq %rbx, %rdi
leaq 0x49072(%rip), %rsi     # 0x14b379
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
movl $0x20, %esi
callq 0xf2271
addq $0x10000, 0x20(%rsp)    # imm = 0x10000
movb $0x1, 0xf(%rsp)
movq %rbp, %r13
movq %r15, %rdi
movq 0x58(%rsp), %rsi
callq 0x1026f6
movl %eax, %r14d
cmpl $0x64, %eax
jge 0x102345
xorl %ebp, %ebp
jmp 0x10239d
movl $0x3, %ebp
cmpl $0x67, %r14d
je 0x10235e
cmpl $0x68, %r14d
jne 0x102366
movl $0x13, %r14d
jmp 0x10239d
movl $0xb, %r14d
jmp 0x10239d
xorl %ebp, %ebp
cmpl $0x4, %ebp
jbe 0x102371
xorl %ecx, %ecx
jmp 0x102387
movq %r12, %rdi
movl $0x1, %esi
callq 0xf2271
xorl %ecx, %ecx
testb %al, %al
setne %cl
addl %ecx, %ebp
testb %cl, %cl
jne 0x102368
addl $0x5, %ebp
movl $0x1, %r14d
movl %ebp, %ecx
shll %cl, %r14d
addl $-0x5, %r14d
testl %ebp, %ebp
je 0x1023ae
movq %r12, %rdi
movl %ebp, %esi
callq 0xf2271
addl %eax, %r14d
movq %r13, %rbp
cmpl $0x0, 0x30(%r15)
je 0x1023c0
xorl %r14d, %r14d
jmp 0x10245d
testl %r14d, %r14d
jne 0x102469
cmpb $0x0, 0xf(%rsp)
je 0x102469
xorl %ebp, %ebp
cmpl $0x4, %ebp
jbe 0x1023df
xorl %ecx, %ecx
jmp 0x1023f5
movq %r12, %rdi
movl $0x1, %esi
callq 0xf2271
xorl %ecx, %ecx
testb %al, %al
setne %cl
addl %ecx, %ebp
testb %cl, %cl
jne 0x1023d6
movq %r12, %rdi
movl %ebp, %esi
callq 0xf2271
movq %rax, %r14
btsl %ebp, %r14d
cmpl $0x4, (%rbx)
jl 0x102427
movq 0x28(%r15), %rdx
movq %rbx, %rdi
leaq 0x48fa0(%rip), %rsi     # 0x14b3bd
movl %r14d, %ecx
xorl %eax, %eax
callq 0xe9226
cmpl $0x1, %r14d
movl %r14d, %ebp
adcl $0x0, %ebp
movq %r12, %rdi
movl $0x8, %esi
callq 0xf2271
movq 0x70(%r15), %rdi
movzbl %al, %esi
callq 0xfb382
decl %ebp
jne 0x102431
cmpl $0x3f, %r14d
setae 0xf(%rsp)
movb $0x1, %r14b
movq %r13, %rbp
leaq 0x48f07(%rip), %r13     # 0x14b36b
jmp 0x1022c3
cmpb $0x1, 0xf(%rsp)
adcl $0x2, %r14d
movq 0x28(%r15), %rax
movl $0x2, %edx
cmpq $0xb, %rax
jl 0x1024fe
movl $0x3, %edx
cmpq $0x15, %rax
jl 0x1024fe
movl $0x4, %edx
cmpq $0x29, %rax
jl 0x1024fe
movl $0x5, %edx
cmpq $0x51, %rax
jl 0x1024fe
movl $0x6, %edx
cmpq $0xa1, %rax
jl 0x1024fe
movl $0x7, %edx
cmpq $0x2a1, %rax            # imm = 0x2A1
jl 0x1024fe
movl $0x8, %edx
cmpq $0x3e9, %rax            # imm = 0x3E9
jl 0x1024fe
movl $0x9, %edx
cmpq $0xa81, %rax            # imm = 0xA81
jl 0x1024fe
movl $0xa, %edx
cmpq $0x1501, %rax           # imm = 0x1501
jl 0x1024fe
movl $0xb, %edx
cmpq $0x2a01, %rax           # imm = 0x2A01
jl 0x1024fe
xorl %edx, %edx
cmpq $0x5401, %rax           # imm = 0x5401
setl %dl
xorl $0xd, %edx
leal -0x2(%rdx), %ecx
movl $0x1, %ebp
movl %ecx, 0x1c(%rsp)
shll %cl, %ebp
movq %rdx, 0x30(%rsp)
leal -0x3(%rdx), %ecx
movl $0xa, %edx
shll %cl, %edx
movq (%r15), %rcx
movq %rcx, 0x28(%rsp)
movq %rax, 0x38(%rsp)
cmpq $0xb, %rax
movl $0x0, %eax
cmovll %eax, %edx
movq %rdx, 0x10(%rsp)
movq %r12, %rdi
movl $0x1, %esi
callq 0xf2271
movq %r12, %rdi
cmpb $0x1, %al
jne 0x102592
movl $0x1, %esi
callq 0xf2271
testb %al, %al
je 0x1025a0
movq 0x38(%rsp), %r8
cmpq $0xb, %r8
jge 0x102646
movl $0x1, 0x30(%r15)
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
movq 0x28(%rsp), %rdi
leaq 0x48e49(%rip), %rcx     # 0x14b3cf
xorl %eax, %eax
callq 0xfa71e
xorl %r8d, %r8d
jmp 0x1025b2
movl 0x1c(%rsp), %esi
callq 0xf2271
movq %rax, %r8
jmp 0x1025b2
movq %r12, %rdi
movq 0x30(%rsp), %rsi
callq 0xf2271
addl %eax, %ebp
movl %ebp, %r8d
movq %r13, %rbp
leaq 0x48daf(%rip), %r13     # 0x14b36b
cmpl $0x0, 0x30(%r15)
jne 0x1022c0
movl %r8d, %eax
movq 0x28(%r15), %rdx
cmpq %rax, %rdx
jge 0x1025fc
movl $0x1, 0x30(%r15)
movq (%r15), %rdi
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
xorl %r14d, %r14d
leaq 0x48da0(%rip), %rcx     # 0x14b390
xorl %eax, %eax
callq 0xfa71e
jmp 0x1022c3
cmpl $0x4, (%rbx)
jl 0x102623
leal 0x1(%r8), %ecx
movq %rbx, %rdi
leaq 0x48d97(%rip), %rsi     # 0x14b3a6
movq %r8, 0x10(%rsp)
movl %r14d, %r8d
xorl %eax, %eax
callq 0xe9226
movq 0x10(%rsp), %r8
movq 0x70(%r15), %rdi
notl %r8d
addl 0x10(%rdi), %r8d
movl %r8d, %esi
movl %r14d, %edx
callq 0xfb3af
movb $0x1, %r14b
movb $0x1, 0xf(%rsp)
jmp 0x1022c3
leaq -0x66c(%r8), %rax
movl $0xb, %esi
cmpq $0x15, %rax
movq %r13, %rbp
jb 0x10267b
movl $0xf, %esi
cmpq $0xa800, %r8            # imm = 0xA800
jg 0x10267b
movl 0x10(%rsp), %eax
subq %rax, %r8
movq %r8, %rdi
callq 0xea82b
movq %rax, %rsi
movq %r12, %rdi
callq 0xf2271
movq 0x10(%rsp), %r8
addl %eax, %r8d
jmp 0x1025b5
cmpl $0x0, 0x30(%r15)
je 0x1026b3
movq 0x20(%r15), %rdx
leaq 0x48661(%rip), %rcx     # 0x14ad03
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
xorl %eax, %eax
callq 0xfa71e
jmp 0x1026dc
movq %r12, %rdi
callq 0xf22f1
movq 0x40(%r15), %rax
movq 0x8(%r15), %rcx
movq 0x18(%r15), %rdx
subq 0x8(%rcx), %rax
xorl %ecx, %ecx
testq %rax, %rax
cmovgq %rax, %rcx
movq %rcx, 0x8(%rdx)
movb $0x1, 0x4(%rdx)
movq %r15, %rdi
callq 0xffe9f
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq