// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-cmpr.c
// Function: fmtutil_huff_squeeze_codectype1
void fmtutil_huff_squeeze_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 squeeze_ctx *sqctx = NULL;
	int ok = 0;

	sqctx = de_malloc(c, sizeof(struct squeeze_ctx));
	sqctx->c = c;
	sqctx->modname = "unsqueeze";
	sqctx->dcmpri = dcmpri;
	sqctx->dcmpro = dcmpro;
	sqctx->dres = dres;

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

	sqctx->ht = fmtutil_huffman_create_decoder(c, 257, 257);

	if(!squeeze_read_nodetable(c, sqctx)) goto done;
	if(!squeeze_read_codes(c, sqctx)) goto done;

	dres->bytes_consumed = sqctx->bitrd.curpos - dcmpri->pos;
	if(dres->bytes_consumed > dcmpri->len) {
		dres->bytes_consumed = dcmpri->len;
	}
	dres->bytes_consumed_valid = 1;
	ok = 1;

done:
	if(!ok || dres->errcode) {
		de_dfilter_set_errorf(c, dres, sqctx->modname, "Squeeze decompression failed");
	}

	if(sqctx) {
		fmtutil_huffman_destroy_decoder(c, sqctx->ht);
		de_free(c, sqctx);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %rbx
movl $0x670, %esi            # imm = 0x670
callq 0xe969b
movq %rax, %r14
movq %rbx, (%rax)
leaq 0x4ecfd(%rip), %rax     # 0x14a59f
movq %rax, 0x20(%r14)
movq %rbp, 0x8(%r14)
movq %r15, 0x10(%r14)
movq %r12, 0x18(%r14)
movq (%rbp), %rax
movq %rax, 0x40(%r14)
movq 0x8(%rbp), %rax
movq %rax, 0x48(%r14)
addq 0x10(%rbp), %rax
movq %rax, 0x50(%r14)
movl $0x101, %esi            # imm = 0x101
movl $0x101, %edx            # imm = 0x101
movq %rbx, %rdi
callq 0x105165
movq %rax, 0x38(%r14)
movq 0x48(%r14), %rax
addq $0x2, %rax
cmpq 0x50(%r14), %rax
jg 0xfbb6a
leaq 0x48(%r14), %r13
movq 0x8(%r14), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0xef1ed
movq %rax, 0x30(%r14)
leaq 0x4edfd(%rip), %rsi     # 0x14a70d
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x101, 0x30(%r14)      # imm = 0x101
jl 0xfb941
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rdx
leaq 0x4ede7(%rip), %rcx     # 0x14a71c
xorl %eax, %eax
callq 0xfa71e
jmp 0xfbb6a
movq %rbp, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq 0x48(%r14), %rdx
leaq 0x229d5(%rip), %rsi     # 0x11e32b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe93cf
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpq $0x0, 0x30(%r14)
jle 0xfb9d4
leaq 0x72(%r14), %r12
leaq 0x4edb0(%rip), %r15     # 0x14a72f
xorl %ebp, %ebp
movq 0x8(%r14), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0xef2dd
movw %ax, (%r12)
movq 0x8(%r14), %rax
movq (%rax), %rdi
movq %r13, %rsi
callq 0xef2dd
movw %ax, 0x2(%r12)
cmpl $0x2, (%rbx)
jl 0xfb9c7
movswl (%r12), %ecx
movswl %ax, %r8d
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe93cf
incq %rbp
addq $0x6, %r12
cmpq 0x30(%r14), %rbp
jl 0xfb981
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x48(%r14), %rax
cmpq 0x50(%r14), %rax
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rbp
jg 0xfbb6a
leaq 0x4ebc6(%rip), %rsi     # 0x14a5c6
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9461
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xfc8e1
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpl $0x4, (%rbx)
jl 0xfba43
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0x104c1c
movq 0x48(%r14), %rdx
leaq 0x4ecf6(%rip), %rsi     # 0x14a744
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
leaq 0x60(%r14), %rdi
movb $0x1, 0x60(%r14)
callq 0xf2261
movq 0x38(%r14), %rax
movq 0x8(%rax), %rdi
callq 0x1048e8
testl %eax, %eax
je 0xfbb40
movq %r14, %rbp
addq $0x40, %rbp
movl $0x0, 0x4(%rsp)
movq 0x38(%r14), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
leaq 0x4(%rsp), %rdx
xorl %ecx, %ecx
callq 0x104b4d
testl %eax, %eax
sete %cl
movl 0x4(%rsp), %eax
cmpl $0x101, %eax            # imm = 0x101
setae %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0xfbace
cmpb $0x0, 0x58(%r14)
je 0xfbb0f
movl $0x1, %r15d
xorl %r12d, %r12d
jmp 0xfbb28
cmpl $0xff, %eax
jg 0xfbb04
movq 0x10(%r14), %rcx
movq (%rcx), %rdi
movzbl %al, %esi
callq 0xf11be
movq 0x10(%r14), %rax
movq 0x28(%r14), %rcx
incq %rcx
movq %rcx, 0x28(%r14)
cmpb $0x0, 0x8(%rax)
je 0xfbaff
cmpq 0x10(%rax), %rcx
jge 0xfbb04
movb $0x1, %r12b
jmp 0xfbb28
xorl %r12d, %r12d
movl $0x1, %r15d
jmp 0xfbb28
movq 0x18(%r14), %rsi
movq 0x20(%r14), %rdx
xorl %r12d, %r12d
leaq 0x3c457(%rip), %rcx     # 0x137f78
xorl %eax, %eax
callq 0xfa71e
testb %r12b, %r12b
jne 0xfba85
testl %r15d, %r15d
movq 0x10(%rsp), %r12
movq 0x8(%rsp), %rbp
je 0xfbb6a
movq (%r13), %rax
subq 0x8(%rbp), %rax
movq %rax, 0x8(%r12)
movq 0x10(%rbp), %rcx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
movq %rax, 0x8(%r12)
movb $0x1, 0x4(%r12)
cmpl $0x0, (%r12)
je 0xfbb7f
movq 0x20(%r14), %rdx
leaq 0x4ea34(%rip), %rcx     # 0x14a5a9
movq %r12, %rsi
xorl %eax, %eax
callq 0xfa71e
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0x10521e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq