// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/src/fmtutil-fax.c
// Function: fmtutil_fax34_codectype1
void fmtutil_fax34_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 fax_ctx *fc = NULL;
	struct fax34_huffman_tree *f34ht = NULL;

	fc = de_malloc(c, sizeof(struct fax_ctx));
	fc->modname = "fax_decode";
	fc->fax34params = (struct de_fax34_params*)codec_private_params;
	fc->dcmpri = dcmpri;
	fc->dcmpro = dcmpro;
	fc->dres = dres;
	fc->image_width = fc->fax34params->image_width;
	fc->image_height = fc->fax34params->image_height;

	if((fc->fax34params->tiff_cmpr_meth==3 && (fc->fax34params->t4options & 0x1)) ||
		(fc->fax34params->tiff_cmpr_meth==4))
	{
		fc->is_2d = 1;
	}

	if(fc->fax34params->tiff_cmpr_meth==2) {
		fc->has_eol_codes = 0;
		fc->rows_padded_to_next_byte = 1;
	}
	else if(fc->fax34params->tiff_cmpr_meth==3) {
		fc->has_eol_codes = 1;
	}

	if(fc->image_width < 1 ||
		fc->image_width > c->max_image_dimension)
	{
		goto done;
	}

	fc->rowspan_final = (fc->image_width+7)/8;
	if(fc->rowspan_final < fc->fax34params->out_rowspan) {
		fc->rowspan_final = fc->fax34params->out_rowspan;
	}

	fc->curr_row = de_malloc(c, fc->image_width);
	fc->prev_row = de_malloc(c, fc->image_width);
	fc->tmp_row_packed = de_malloc(c, fc->rowspan_final);

	f34ht = create_fax34_huffman_tree(c, (int)fc->is_2d);
	do_decompress_fax34(c, fc, f34ht);

done:
	destroy_fax34_huffman_tree(c, f34ht);
	if(fc) {
		de_free(c, fc->curr_row);
		de_free(c, fc->prev_row);
		de_free(c, fc->tmp_row_packed);
		de_free(c, fc);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %rbx
movl $0xd0, %esi
callq 0xe969b
movq %rax, %r14
leaq 0x4c3b4(%rip), %rcx     # 0x14ab4c
movq %rcx, 0x18(%rax)
movq %r15, 0x20(%rax)
movq %r12, (%rax)
movq %rbp, 0x8(%rax)
movq %r13, 0x10(%rax)
movq (%r15), %rsi
movq %rsi, 0x30(%rax)
movq 0x8(%r15), %rcx
movq %rax, 0x10(%rsp)
movq %rcx, 0x38(%rax)
movl 0x18(%r15), %eax
cmpl $0x2, %eax
je 0xfe7ef
cmpl $0x4, %eax
je 0xfe7e0
cmpl $0x3, %eax
jne 0xfe7fd
cmpl $0x4, %eax
je 0xfe7e0
movl 0x20(%r15), %ecx
andl $0x1, %ecx
je 0xfe7e5
movb $0x1, 0x2a(%r14)
cmpl $0x3, %eax
je 0xfe7f8
cmpl $0x2, %eax
jne 0xfe7fd
movw $0x100, 0x28(%r14)      # imm = 0x100
jmp 0xfe7fd
movb $0x1, 0x28(%r14)
testq %rsi, %rsi
jle 0xfe80f
cmpq 0xa8(%rbx), %rsi
jle 0xfe891
xorl %r15d, %r15d
testq %r15, %r15
je 0xfe84a
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x10521e
movq 0x8(%r15), %rsi
movq %rbx, %rdi
callq 0x10521e
movq 0x10(%r15), %rsi
testq %rsi, %rsi
je 0xfe83f
movq %rbx, %rdi
callq 0x10521e
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
movq 0x78(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq 0x80(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq 0x90(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7(%rsi), %rax
shrq $0x3, %rax
movq %rax, 0x88(%r14)
movq 0x10(%r15), %rcx
cmpq %rcx, %rax
cmovleq %rcx, %rax
movq %rax, 0x88(%r14)
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x78(%r14)
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x80(%r14)
movq 0x88(%r14), %rsi
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x90(%r14)
movq %r14, 0x18(%rsp)
movb 0x2a(%r14), %bpl
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movl $0x73, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x105165
movq %rax, (%r15)
movl $0x73, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x105165
movq %rax, 0x8(%r15)
testb %bpl, %bpl
je 0xfe980
movl $0xb, %esi
movl $0xb, %edx
movq %rbx, %rdi
callq 0x105165
movq %rax, 0x10(%r15)
xorl %r12d, %r12d
leaq 0x4c0c6(%rip), %r13     # 0x14aa10
leaq 0x4c0ca(%rip), %rbp     # 0x14aa1b
leaq 0x4c0ce(%rip), %r14     # 0x14aa26
movq 0x10(%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r12,%r13), %edx
movzbl (%r12,%rbp), %ecx
movzbl (%r12,%r14), %r8d
movq %rbx, %rdi
callq 0x104901
incq %r12
cmpq $0xb, %r12
jne 0xfe958
xorl %r13d, %r13d
leaq 0x4c276(%rip), %rbp     # 0x14ac00
leaq 0x4c0af(%rip), %r12     # 0x14aa40
cmpq $0x40, %r13
ja 0xfe99c
movl %r13d, %r8d
jmp 0xfe9b6
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpq $0x68, %r13
je 0xfe9b6
movl %r13d, %r8d
shll $0x6, %r8d
addl $0xfffff040, %r8d       # imm = 0xFFFFF040
movq (%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r13,%rbp), %edx
movzbl (%r13,%r12), %ecx
shrl $0x4, %ecx
movq %rbx, %rdi
callq 0x104901
incq %r13
cmpq $0x69, %r13
jne 0xfe991
xorl %r13d, %r13d
leaq 0x4c289(%rip), %rbp     # 0x14ac70
movq 0x18(%rsp), %r14
cmpq $0x40, %r13
ja 0xfe9f7
movl %r13d, %r8d
jmp 0xfea11
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpq $0x68, %r13
je 0xfea11
movl %r13d, %r8d
shll $0x6, %r8d
addl $0xfffff040, %r8d       # imm = 0xFFFFF040
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r13,%rbp), %edx
movzbl (%r13,%r12), %ecx
andl $0xf, %ecx
movq %rbx, %rdi
callq 0x104901
incq %r13
cmpq $0x69, %r13
jne 0xfe9ec
movb $0x0, 0x20(%rsp)
movq 0x10(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x68(%r14)
movups %xmm0, 0x58(%r14)
movups %xmm0, 0x48(%r14)
movq (%r14), %rax
movq 0x20(%r14), %rcx
movq (%rax), %rdx
movq %rdx, 0x48(%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%r14)
addq 0x10(%rax), %rdx
movq %rdx, 0x58(%r14)
movb 0x1c(%rcx), %al
movb %al, 0x68(%r14)
cmpb $0x0, 0x28(%r14)
je 0xfeb9f
xorl %r12d, %r12d
xorl %ebp, %ebp
movl $0x4, %r13d
cmpq $0x3ff, %r12            # imm = 0x3FF
jg 0xfead8
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xf2271
cmpb $0x0, 0x60(%r14)
jne 0xfead8
incq %r12
testq %rax, %rax
je 0xfeaca
movl $0x2, %r13d
xorl %ebp, %ebp
jmp 0xfead8
incl %ebp
xorl %eax, %eax
cmpl $0x8, %ebp
setae %al
leal (%rax,%rax,2), %r13d
testl %r13d, %r13d
je 0xfea93
cmpl $0x2, %r13d
je 0xfea93
cmpl $0x3, %r13d
jne 0xfeb33
movl $0x400, %ebp            # imm = 0x400
subq %r12, %rbp
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq %rbp, %r12
jge 0xfeb12
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xf2271
cmpb $0x0, 0x60(%r14)
je 0xfeb1a
xorl %eax, %eax
testb %al, %al
jne 0xfeaf7
jmp 0xfeb2e
incq %r12
testq %rax, %rax
sete %al
movl $0x1, %ecx
cmovnel %ecx, %r13d
jmp 0xfeb14
testl %r13d, %r13d
jne 0xfeb9f
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xff06c
movq (%r14), %rax
cmpq $0x0, 0x10(%rax)
jle 0xff06c
leaq 0x4c001(%rip), %rsi     # 0x14ab57
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movw $0x0, 0x28(%r14)
xorps %xmm0, %xmm0
movq 0x8(%rsp), %rax
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq (%r14), %rax
movq 0x20(%r14), %rcx
movq (%rax), %rdx
movq %rdx, 0x48(%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%r14)
addq 0x10(%rax), %rdx
movq %rdx, 0x58(%r14)
movb 0x1c(%rcx), %al
movb %al, 0x68(%r14)
addq $0x68, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x98(%r14)
movl $0x0, 0xa0(%r14)
movq %rax, 0xa8(%r14)
movq $-0x1, 0xb0(%r14)
movw $0x0, 0xb8(%r14)
leaq 0x4(%rsp), %r13
leaq 0x4beff(%rip), %rbp     # 0x14aae0
movl $0x0, 0x4(%rsp)
movq 0x38(%r14), %rax
movq 0xa8(%r14), %rcx
movl $0x2, %r12d
cmpq %rax, %rcx
jge 0xfec45
decq %rax
cmpq %rax, %rcx
jne 0xfec14
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jge 0xfec45
movq 0x8(%r14), %rax
cmpb $0x0, 0x8(%rax)
je 0xfec28
movq 0x40(%r14), %rcx
cmpq 0x10(%rax), %rcx
jg 0xfec45
cmpb $0x0, 0x60(%r14)
je 0xfec4f
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
leaq 0x4be70(%rip), %rsi     # 0x14aab0
callq 0xe8ded
testl %r12d, %r12d
je 0xfebe1
jmp 0xff082
cmpb $0x0, 0x28(%r14)
jne 0xfec8b
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jl 0xfec8b
cmpl $0x0, 0xa0(%r14)
jne 0xfec8b
cmpb $0x0, 0x29(%r14)
je 0xfec7e
movq 0x10(%rsp), %rdi
callq 0xf2261
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xff0f0
cmpb $0x0, 0x2a(%r14)
je 0xfecc4
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xfecc4
cmpb $0x0, 0xb9(%r14)
jne 0xfecc4
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xf2271
movb %al, 0xba(%r14)
movb $0x1, 0xb9(%r14)
cmpb $0x0, 0x2a(%r14)
je 0xfecd9
cmpl $0x0, 0xa0(%r14)
je 0xfed6e
movzbl 0xb8(%r14), %eax
movq (%r15,%rax,8), %rax
movq 0x8(%rax), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x104b4d
testl %eax, %eax
je 0xfee2e
movslq 0x4(%rsp), %rax
cmpq $-0x1, %rax
je 0xfee4b
movq 0x98(%r14), %rdx
addq %rax, %rdx
cmpl $0x3f, %eax
jg 0xfee83
movq %rdx, 0x98(%r14)
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xff249
movq $0x0, 0x98(%r14)
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
movl 0xa0(%r14), %eax
testl %eax, %eax
je 0xfee8a
decl %eax
movl %eax, 0xa0(%r14)
jmp 0xfee8a
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xfed86
cmpb $0x0, 0xba(%r14)
jne 0xfecd9
movq 0x10(%r15), %rax
movq 0x8(%rax), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x104b4d
testl %eax, %eax
je 0xfee2e
movl 0x4(%rsp), %edx
movq %rbx, %rdi
leaq 0x2bd8b(%rip), %rsi     # 0x12ab3e
xorl %eax, %eax
callq 0xe9461
movl 0x4(%rsp), %eax
leal -0x61(%rax), %ecx
cmpl $0x6, %ecx
ja 0xfee92
movq %r14, %rdi
callq 0xff1f4
movl 0xb0(%r14), %edx
movl 0xc0(%r14), %ecx
movq %rbx, %rdi
leaq 0x4bdb1(%rip), %rsi     # 0x14ab9b
xorl %eax, %eax
callq 0xe9461
movq 0xc0(%r14), %rax
movslq 0x4(%rsp), %rcx
subq 0xb0(%r14), %rax
leaq (%rax,%rcx), %rdx
addq $-0x64, %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq 0xff249
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
jmp 0xfee8a
cmpb $0x0, 0x60(%r14)
jne 0xfec2f
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
jmp 0xfec40
cmpb $0x0, 0x28(%r14)
je 0xfee60
cmpl $0x0, 0xa0(%r14)
je 0xfeef8
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0xe8ded
movl $0x2, %r12d
xorl %eax, %eax
testb %al, %al
jne 0xfee8a
jmp 0xfec45
movq %rdx, 0x98(%r14)
xorl %r12d, %r12d
jmp 0xfec45
cmpl $0x3, %eax
ja 0xfec45
movl %eax, %eax
leaq 0x4bb5c(%rip), %rcx     # 0x14aa00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x28(%r14)
je 0xff036
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpq $0x3f, %rbp
jg 0xfeed9
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xf2271
cmpb $0x0, 0x60(%r14)
je 0xfeee4
xorl %eax, %eax
testb %al, %al
jne 0xfeebd
jmp 0xff010
incq %rbp
testq %rax, %rax
sete %al
movl $0x1, %ecx
cmovnel %ecx, %r13d
jmp 0xfeedb
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq $0x3f, %r12
jg 0xfef19
movq 0x8(%rsp), %rdi
movl $0x1, %esi
callq 0xf2271
cmpb $0x0, 0x60(%r14)
je 0xfef21
xorl %eax, %eax
testb %al, %al
jne 0xfeefd
jmp 0xfef34
incq %r12
testq %rax, %rax
sete %al
movl $0x1, %ecx
cmovnel %ecx, %ebp
jmp 0xfef1b
testl %ebp, %ebp
je 0xfef5b
cmpq $0x3, %r12
leaq 0x4bb9d(%rip), %rbp     # 0x14aae0
jg 0xfef85
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
leaq 0x4bbca(%rip), %rsi     # 0x14ab20
jmp 0xfee6d
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
leaq 0x4bb94(%rip), %rsi     # 0x14ab00
callq 0xe8ded
movl $0x2, %r12d
xorl %eax, %eax
leaq 0x4bb60(%rip), %rbp     # 0x14aae0
jmp 0xfee7a
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xff0f0
xorl %r12d, %r12d
movb $0x1, %al
jmp 0xfee7a
movl $0x2, 0xa0(%r14)
jmp 0xfee8a
movq 0x8(%rsp), %rdi
movl $0x3, %esi
callq 0xf2271
movl $0x64, %esi
leaq 0x20(%rsp), %rdi
leaq 0x4bbdd(%rip), %rdx     # 0x14abac
leaq 0x4bb4a(%rip), %rcx     # 0x14ab20
movl %eax, %r8d
xorl %eax, %eax
callq 0xe8d67
jmp 0xfec45
movq %r14, %rdi
callq 0xff2ed
movq 0xc8(%r14), %rdx
subq 0xb0(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq 0xff249
jmp 0xfee8a
testl %r13d, %r13d
leaq 0x4bac6(%rip), %rbp     # 0x14aae0
je 0xff04c
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xff0f0
leaq 0x4(%rsp), %r13
jmp 0xfee8a
movq %rbx, %rdi
leaq 0x4bb67(%rip), %rsi     # 0x14aba7
xorl %eax, %eax
callq 0xe9461
jmp 0xfec45
movl $0x64, %edx
leaq 0x20(%rsp), %rdi
leaq 0x4baa3(%rip), %rsi     # 0x14ab00
callq 0xe8ded
leaq 0x4(%rsp), %r13
jmp 0xfec45
leaq 0x4bb0f(%rip), %rsi     # 0x14ab82
leaq 0x20(%rsp), %rdi
movl $0x64, %edx
callq 0xe8ded
cmpq $0x0, 0xb0(%r14)
jle 0xff099
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xff0f0
cmpb $0x0, 0x20(%rsp)
je 0xfe812
cmpq $0x0, 0xa8(%r14)
jle 0xff0cd
movq 0x18(%r14), %rdx
leaq 0x4bafb(%rip), %rsi     # 0x14abb4
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
jmp 0xfe812
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
leaq 0x15bd3(%rip), %rcx     # 0x114caf
leaq 0x20(%rsp), %r8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfa71e
jmp 0xfe812