// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/colorix.c
// Function: do_colorix_decompress
static int do_colorix_decompress(deark *c, struct colorix_ctx *d, i64 pos1,
	dbuf *unc_pixels)
{
	int retval = 0;
	struct de_dfilter_in_params dcmpri;
	struct de_dfilter_out_params dcmpro;
	struct de_dfilter_results dres;
	struct de_rixdecomp_params params;

	de_zeromem(&params, sizeof(struct de_rixdecomp_params));
	params.known_segment_size = d->known_segment_size;
	params.rowspan = d->rowspan;
	params.imgtype = d->imgtype;

	de_dfilter_init_objects(c, &dcmpri, &dcmpro, &dres);
	dcmpri.f = c->infile;
	dcmpri.pos = pos1;
	dcmpri.len = c->infile->len - pos1;
	dcmpro.f = unc_pixels;
	dcmpro.expected_len = d->unc_image_size;
	dcmpro.len_known = 1;

	rixdecomp_codectype1(c, &dcmpri, &dcmpro, &dres, (void*)&params);
	dbuf_flush(dcmpro.f);

	if(dres.errcode) {
		de_err(c, "Decompression failed: %s", de_dfilter_get_errmsg(c, &dres));
		goto done;
	}

	retval = 1;
done:
	return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x60(%rsp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq 0x28(%rsi), %rax
movq %rax, (%rbx)
movq 0x20(%rsi), %rax
movq %rax, 0x8(%rbx)
movb 0x6(%rsi), %al
movb %al, 0x10(%rbx)
leaq 0xd8(%rsp), %r12
leaq 0x48(%rsp), %r15
leaq 0x78(%rsp), %rcx
movq %r12, %rsi
movq %r15, %rdx
callq 0xfa6e0
movq 0x18(%r14), %rax
movq %rax, (%r12)
movq %rbp, 0x8(%r12)
movq 0x18(%rax), %rax
subq %rbp, %rax
movq %rax, 0x10(%r12)
movq 0x18(%rsp), %rax
movq %rax, (%r15)
movq 0x38(%r13), %rax
movq %r14, %r13
movq %rax, 0x10(%r15)
movb $0x1, 0x8(%r15)
leaq 0x24(%rsp), %rsi
movq %r14, %rdi
callq 0xe958c
movl $0xe8, %esi
movq %r14, %rdi
callq 0xe969b
movq %rax, %r14
movq %r13, (%rax)
movq %rbx, 0x8(%rax)
leaq 0xd34f5(%rip), %rax     # 0x11e251
movq %rax, 0x28(%r14)
movq %r12, 0x10(%r14)
movq %r15, 0x18(%r14)
leaq 0x78(%rsp), %rax
movq %rax, 0x20(%r14)
movq 0x8(%r12), %rax
movq 0x10(%r12), %rbp
addq %rax, %rbp
cmpb $0x0, 0x10(%rbx)
sete 0x31(%r14)
movq (%r15), %rcx
cmpl $0x3, (%rcx)
jne 0x4b20c
cmpq $0x0, 0x18(%rcx)
jne 0x4b20c
cmpb $0x0, 0x50(%rsp)
je 0x4b20c
cmpq $0x0, 0x68(%rsp)
jle 0x4b20c
movq %rax, 0x40(%r14)
leaq 0xc(%rsp), %rsi
movq %r13, %rdi
callq 0xe958c
movq 0x40(%r14), %rdx
leaq 0x10(%rsp), %r12
movq %rdx, (%r12)
leaq 0xd351a(%rip), %rsi     # 0x11e2f4
movq %r13, %rdi
xorl %eax, %eax
callq 0xe9226
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x10(%r14), %rax
movq (%rax), %rdi
movq %r12, %rsi
callq 0xef1ed
movq %rax, %r15
leaq (%rax,%rax), %rdx
movq %rdx, 0x90(%r14)
leaq 0xd3501(%rip), %rsi     # 0x11e316
movq %r13, %rdi
xorl %eax, %eax
callq 0xe9226
movq (%r12), %rax
movq %rax, 0x88(%r14)
addq 0x90(%r14), %rax
movq %rax, 0x48(%r14)
movl $0x100, %esi            # imm = 0x100
movl $0x100, %edx            # imm = 0x100
movq %r13, %rdi
callq 0x105165
movq %rax, 0x50(%r14)
testq %r15, %r15
jle 0x4aeaa
movq 0x88(%r14), %rdx
leaq 0xd34cd(%rip), %rsi     # 0x11e32b
movq %r13, %rdi
xorl %eax, %eax
callq 0xe93cf
movq %r13, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x88(%r14), %rsi
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x4b28f
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpl $0x4, (%r13)
jl 0x4aeba
movq 0x50(%r14), %rsi
movq %r13, %rdi
callq 0x104c1c
jmp 0x4aeba
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r13, %rdi
callq 0xfa815
movl 0xc(%rsp), %esi
movq %r13, %rdi
callq 0xe9595
testq %r15, %r15
jle 0x4b20c
movq 0x48(%r14), %rax
leaq 0x10(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x58(%r14), %r12
movq %r14, %rax
addq $0x78, %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq %r13, 0x38(%rsp)
movq 0x10(%rsp), %r15
leaq 0x2(%r15), %rax
movl $0x4, %ebx
cmpq %rbp, %rax
jge 0x4b1f8
movq 0x18(%r14), %rax
movq (%rax), %rcx
movq 0x18(%rcx), %rcx
movq %rcx, 0x38(%r14)
cmpq 0x10(%rax), %rcx
jge 0x4b1f8
movq 0xd8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xef1ed
testq %rax, %rax
je 0x4b1f8
movq %r13, %rbx
movq 0x10(%rsp), %r13
movq %rbx, %rdi
leaq 0xd3305(%rip), %rsi     # 0x11e25b
movq %r15, %rdx
movq %r13, %rcx
movq %rax, %r8
movq %rax, %r15
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r14), %rax
movq (%rax), %rdi
movq 0x18(%rdi), %rax
movq %rax, 0x18(%rsp)
callq 0xf0e3f
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movq 0x10(%r14), %rax
movq (%rax), %rax
movq %rax, 0x58(%r14)
movq %r13, 0x60(%r14)
movq %r15, 0x40(%rsp)
addq %r15, %r13
movq %r13, 0x68(%r14)
movq 0x30(%rsp), %rdi
callq 0xf2261
movq 0x50(%r14), %rax
movq (%rax), %rdi
callq 0x1048fa
xorl %eax, %eax
movl %eax, 0x98(%r14)
movb $0x0, 0x9c(%r14)
movl %eax, 0xc(%rsp)
movq 0x50(%r14), %rax
movq 0x8(%rax), %rdi
movq %r12, %rsi
leaq 0xc(%rsp), %r13
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x104b4d
testl %eax, %eax
setne %al
movl 0xc(%rsp), %r15d
cmpl $0x100, %r15d           # imm = 0x100
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x4b0f3
movq 0x18(%r14), %rax
movq 0x38(%r14), %rcx
cmpq 0x10(%rax), %rcx
jge 0x4b0c0
movl 0x98(%r14), %eax
cmpl $0x1, %eax
je 0x4b061
testl %eax, %eax
jne 0x4b07e
leal 0x1(%r15), %eax
movl $0x1, %ebx
cmpb $0x1, %al
ja 0x4b080
movl $0x1, 0x98(%r14)
movb %r15b, 0x9d(%r14)
jmp 0x4b0c0
incl %r15d
movq %r15, %rbx
movb 0x9d(%r14), %al
movl $0x0, 0x98(%r14)
movl %eax, %r15d
jmp 0x4b080
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x4b0b7
movq %rbx, %r13
cmpb $0x0, 0x31(%r14)
movl %r15d, %eax
je 0x4b09c
movb 0x9c(%r14), %al
xorb %r15b, %al
movb %al, 0x9c(%r14)
movq 0x18(%r14), %rcx
movq (%rcx), %rdi
movzbl %al, %esi
callq 0xf11be
decq %r13
jne 0x4b088
addq %rbx, 0x38(%r14)
leaq 0xc(%rsp), %r13
movl $0x0, 0xc(%rsp)
movq 0x50(%r14), %rax
movq 0x8(%rax), %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x104b4d
testl %eax, %eax
je 0x4b0f3
movl 0xc(%rsp), %r15d
cmpl $0x100, %r15d           # imm = 0x100
jb 0x4b01e
movq 0x18(%r14), %rax
movq (%rax), %rdi
callq 0xf0e67
movq 0x18(%r14), %rax
movq (%rax), %rax
movq 0x18(%rax), %r15
subq 0x18(%rsp), %r15
movq 0x38(%rsp), %r13
movq %r13, %rdi
leaq 0xd316b(%rip), %rsi     # 0x11e289
movq %r15, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x8(%r14), %rax
movq 0x8(%rax), %rcx
cmpq %rcx, %r15
jge 0x4b150
movq 0x28(%r14), %rdx
movq %r13, %rdi
leaq 0x78(%rsp), %rsi
callq 0xfa815
movl $0x2, %ebx
jmp 0x4b1f8
movq %r15, %rax
cqto
idivq %rcx
movq %r13, %rdi
leaq 0xd313e(%rip), %rsi     # 0x11e2a0
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x8(%r14), %rcx
movq (%rcx), %rsi
testq %rsi, %rsi
je 0x4b196
movq 0x28(%rsp), %rax
incq %rax
imulq %rax, %rsi
movq %rsi, 0x38(%r14)
movq 0x18(%r14), %rax
movq (%rax), %rdi
callq 0xf152a
jmp 0x4b1da
movq 0x18(%r14), %rdx
movq (%rdx), %rax
movq 0x18(%rax), %rax
cmpq 0x10(%rdx), %rax
jge 0x4b1da
cqto
idivq 0x8(%rcx)
testq %rdx, %rdx
jle 0x4b1da
movq %rdx, %r15
movq %r13, %rdi
leaq 0xd30f5(%rip), %rsi     # 0x11e2b4
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r14), %rax
movq (%rax), %rdi
movq 0x18(%rdi), %rsi
subq %r15, %rsi
movq %rsi, 0x38(%r14)
jmp 0x4b18f
movq 0x40(%rsp), %rax
addq %rax, 0x10(%rsp)
incq 0x28(%rsp)
movq %r13, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
xorl %ebx, %ebx
testl %ebx, %ebx
je 0x4aef9
cmpl $0x2, %ebx
je 0x4b20c
cmpl $0x0, 0x78(%rsp)
je 0x4b21d
movq 0x28(%r14), %rdx
leaq 0x78(%rsp), %rsi
movq %r13, %rdi
callq 0xfa815
movq 0x50(%r14), %rsi
movq %r13, %rdi
callq 0x10521e
movq %r13, %rdi
movq %r14, %rsi
callq 0xe9752
movl 0x24(%rsp), %esi
movq %r13, %rdi
callq 0xe9595
movq 0x48(%rsp), %rdi
callq 0xf0ea4
cmpl $0x0, 0x78(%rsp)
je 0x4b276
leaq 0x78(%rsp), %rsi
movq %r13, %rdi
callq 0xfa6a8
leaq 0xc8f0c(%rip), %rsi     # 0x114171
xorl %ebp, %ebp
movq %r13, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0x4b27b
movl $0x1, %ebp
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq