// File: /workspace/github_c_makefile_star2_O3/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, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
movl $0xd0, %esi
callq 0xe8b2b
movq %rax, %r14
leaq 0x4cfa0(%rip), %rax     # 0x14b0fc
movq %rax, 0x18(%r14)
movq %r15, 0x20(%r14)
movq %rbp, (%r14)
movq %r13, 0x8(%r14)
movq %r12, 0x10(%r14)
movdqu (%r15), %xmm0
movdqu %xmm0, 0x30(%r14)
movl 0x18(%r15), %eax
cmpl $0x2, %eax
je 0xfe1a7
cmpl $0x3, %eax
je 0xfe194
cmpl $0x4, %eax
jne 0xfe1ae
movb $0x1, 0x2a(%r14)
jmp 0xfe1ae
testb $0x1, 0x20(%r15)
je 0xfe1a0
movb $0x1, 0x2a(%r14)
movb $0x1, 0x28(%r14)
jmp 0xfe1ae
movw $0x100, 0x28(%r14)      # imm = 0x100
movq %xmm0, %rsi
testq %rsi, %rsi
jle 0xfe913
cmpq 0xa8(%rbx), %rsi
jg 0xfe913
leaq 0x7(%rsi), %rax
shrq $0x3, %rax
movq 0x10(%r15), %rcx
cmpq %rcx, %rax
cmovleq %rcx, %rax
movq %rax, 0x88(%r14)
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, 0x78(%r14)
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, 0x80(%r14)
movq 0x88(%r14), %rsi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, 0x90(%r14)
movq %r14, 0x18(%rsp)
movb 0x2a(%r14), %bpl
movl $0x18, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movl $0x73, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x104d0e
movq %rax, (%r15)
movl $0x73, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x104d0e
movq %rax, 0x8(%r15)
testb %bpl, %bpl
je 0xfe2b1
movl $0xb, %esi
movl $0xb, %edx
movq %rbx, %rdi
callq 0x104d0e
movq %rax, 0x10(%r15)
xorl %r12d, %r12d
leaq 0x4cd45(%rip), %r13     # 0x14afc0
leaq 0x4cd49(%rip), %rbp     # 0x14afcb
leaq 0x4cd4d(%rip), %r14     # 0x14afd6
movq 0x10(%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r12,%r13), %edx
movzbl (%r12,%rbp), %ecx
movzbl (%r12,%r14), %r8d
movq %rbx, %rdi
callq 0x1044c1
incq %r12
cmpq $0xb, %r12
jne 0xfe289
xorl %r13d, %r13d
leaq 0x4cef5(%rip), %rbp     # 0x14b1b0
leaq 0x4cd2e(%rip), %r12     # 0x14aff0
movq (%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r13,%rbp), %edx
movzbl (%r13,%r12), %ecx
shrl $0x4, %ecx
cmpq $0x40, %r13
ja 0xfe2e3
movl %r13d, %r8d
jmp 0xfe2f7
cmpq $0x68, %r13
je 0xfe30a
movl %r13d, %r8d
shll $0x6, %r8d
addl $0xfffff040, %r8d       # imm = 0xFFFFF040
movq %rbx, %rdi
callq 0x1044c1
incq %r13
cmpq $0x69, %r13
jne 0xfe2c2
jmp 0xfe318
movq %rbx, %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x1044c1
xorl %r13d, %r13d
leaq 0x4cefe(%rip), %rbp     # 0x14b220
movq 0x18(%rsp), %r14
movq 0x8(%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r13,%rbp), %edx
movzbl (%r13,%r12), %ecx
andl $0xf, %ecx
cmpq $0x40, %r13
ja 0xfe349
movl %r13d, %r8d
jmp 0xfe35d
cmpq $0x68, %r13
je 0xfe370
movl %r13d, %r8d
shll $0x6, %r8d
addl $0xfffff040, %r8d       # imm = 0xFFFFF040
movq %rbx, %rdi
callq 0x1044c1
incq %r13
cmpq $0x69, %r13
jne 0xfe327
jmp 0xfe37e
movq %rbx, %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x1044c1
movb $0x0, 0x20(%rsp)
leaq 0x48(%r14), %r12
pxor %xmm0, %xmm0
movdqu %xmm0, 0x68(%r14)
movdqu %xmm0, 0x58(%r14)
movdqu %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 0xfe475
xorl %ebp, %ebp
movl $0x400, %r13d           # imm = 0x400
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
cmpb $0x0, 0x60(%r14)
jne 0xfe404
xorl %ecx, %ecx
testq %rax, %rax
jne 0xfe3fd
cmpl $0x6, %ebp
ja 0xfe83c
incl %ebp
movl %ebp, %ecx
movl %ecx, %ebp
decq %r13
jne 0xfe3d5
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xfe846
movq (%r14), %rax
cmpq $0x0, 0x10(%rax)
jle 0xfe846
leaq 0x4cce0(%rip), %rsi     # 0x14b107
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movw $0x0, 0x28(%r14)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x20(%r12)
movdqu %xmm0, 0x10(%r12)
movdqu %xmm0, (%r12)
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)
xorl %eax, %eax
movq %rax, 0x98(%r14)
movl %eax, 0xa0(%r14)
movq %rax, 0xa8(%r14)
movq $-0x1, 0xb0(%r14)
movw $0x0, 0xb8(%r14)
movl %eax, 0xc(%rsp)
movq 0x38(%r14), %rax
testq %rax, %rax
jle 0xfe87e
movq %r14, %rcx
addq $0x68, %rcx
movq %rcx, 0x10(%rsp)
leaq 0xc(%rsp), %rbp
leaq 0x2c944(%rip), %r13     # 0x12ae0e
xorl %ecx, %ecx
decq %rax
cmpq %rax, %rcx
jne 0xfe4e5
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jge 0xfe87e
movq 0x8(%r14), %rax
cmpb $0x0, 0x8(%rax)
je 0xfe4fd
movq 0x40(%r14), %rcx
cmpq 0x10(%rax), %rcx
jg 0xfe87e
cmpb $0x0, 0x60(%r14)
jne 0xfe85f
cmpb $0x0, 0x28(%r14)
jne 0xfe544
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jl 0xfe544
cmpl $0x0, 0xa0(%r14)
jne 0xfe544
cmpb $0x0, 0x29(%r14)
je 0xfe537
movq 0x10(%rsp), %rdi
callq 0xf1bdd
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xfe9ce
cmpb $0x0, 0x2a(%r14)
je 0xfe590
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xfe582
cmpb $0x0, 0xb9(%r14)
jne 0xfe582
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
movb %al, 0xba(%r14)
movb $0x1, 0xb9(%r14)
cmpb $0x0, 0x2a(%r14)
je 0xfe590
cmpl $0x0, 0xa0(%r14)
je 0xfe6a1
movzbl 0xb8(%r14), %eax
movq (%r15,%rax,8), %rax
movq 0x8(%rax), %rdi
movq %r12, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x1046f3
testl %eax, %eax
je 0xfe858
movslq 0xc(%rsp), %rax
cmpq $-0x1, %rax
je 0xfe61f
movq 0x98(%r14), %rdx
addq %rax, %rdx
cmpl $0x3f, %eax
jg 0xfe695
movq %rdx, 0x98(%r14)
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xfeb2c
movq $0x0, 0x98(%r14)
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
movl 0xa0(%r14), %eax
testl %eax, %eax
je 0xfe7fd
decl %eax
movl %eax, 0xa0(%r14)
jmp 0xfe7fd
cmpb $0x0, 0x28(%r14)
je 0xfe868
cmpl $0x0, 0xa0(%r14)
jne 0xfe868
movq %rbp, %r13
movq $-0x1, %rbp
cmpq $0x3f, %rbp
je 0xfe84f
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
cmpb $0x0, 0x60(%r14)
jne 0xfe84f
incq %rbp
testq %rax, %rax
je 0xfe642
cmpq $0x2, %rbp
jbe 0xfe978
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xfe9ce
movq %r13, %rbp
leaq 0x2c77e(%rip), %r13     # 0x12ae0e
jmp 0xfe7fd
movq %rdx, 0x98(%r14)
jmp 0xfe7fd
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xfe6b9
cmpb $0x0, 0xba(%r14)
jne 0xfe590
movq 0x10(%r15), %rax
movq 0x8(%rax), %rdi
movq %r12, %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x1046f3
testl %eax, %eax
je 0xfe858
movl 0xc(%rsp), %edx
movq %rbx, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0xe889f
movl 0xc(%rsp), %eax
leal -0x61(%rax), %ecx
cmpl $0x6, %ecx
ja 0xfe75a
movq %r14, %rdi
callq 0xfead7
movl 0xb0(%r14), %edx
movl 0xc0(%r14), %ecx
movq %rbx, %rdi
leaq 0x4ca38(%rip), %rsi     # 0x14b14b
xorl %eax, %eax
callq 0xe889f
movq 0xc0(%r14), %rax
movslq 0xc(%rsp), %rcx
subq 0xb0(%r14), %rax
leaq (%rax,%rcx), %rdx
addq $-0x64, %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq 0xfeb2c
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
jmp 0xfe7fd
cmpl $0x3, %eax
ja 0xfe87e
movl %eax, %eax
leaq 0x4c844(%rip), %rcx     # 0x14afb0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x28(%r14)
je 0xfe9b8
movq %rbp, %r13
movq %r15, %rbp
movl $0x41, %r15d
decq %r15
je 0xfe95a
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
cmpb $0x0, 0x60(%r14)
jne 0xfe95a
testq %rax, %rax
je 0xfe78c
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0xfe9ce
movq %rbp, %r15
jmp 0xfe686
movl $0x2, 0xa0(%r14)
jmp 0xfe7fd
movq %r14, %rdi
callq 0xfebd8
movq 0xc8(%r14), %rdx
subq 0xb0(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq 0xfeb2c
movl $0x0, 0xc(%rsp)
movq 0x38(%r14), %rax
movq 0xa8(%r14), %rcx
cmpq %rax, %rcx
jl 0xfe4cc
jmp 0xfe87e
movq %r12, %rdi
movl $0x1, %esi
callq 0xf1bed
cmpb $0x0, 0x60(%r14)
jne 0xfe404
testq %rax, %rax
jne 0xfe475
decq %r13
jne 0xfe81b
jmp 0xfe404
leaq 0x4c8e5(%rip), %rsi     # 0x14b132
jmp 0xfe86f
leaq 0x4c85a(%rip), %rsi     # 0x14b0b0
jmp 0xfe86f
cmpb $0x0, 0x60(%r14)
je 0xfe868
leaq 0x4c7fa(%rip), %rsi     # 0x14b060
jmp 0xfe86f
leaq 0x4c821(%rip), %rsi     # 0x14b090
leaq 0x20(%rsp), %rdi
movl $0x64, %edx
callq 0xe8219
cmpq $0x0, 0xb0(%r14)
jle 0xfe895
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xfe9ce
cmpb $0x0, 0x20(%rsp)
je 0xfe8e0
cmpq $0x0, 0xa8(%r14)
jle 0xfe8c2
movq 0x18(%r14), %rdx
leaq 0x4c8b3(%rip), %rsi     # 0x14b164
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
jmp 0xfe8e0
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
leaq 0x1648e(%rip), %rcx     # 0x114d5f
leaq 0x20(%rsp), %r8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfa21a
movq (%r15), %rsi
movq %rbx, %rdi
callq 0x104dc7
movq 0x8(%r15), %rsi
movq %rbx, %rdi
callq 0x104dc7
movq 0x10(%r15), %rsi
testq %rsi, %rsi
je 0xfe908
movq %rbx, %rdi
callq 0x104dc7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movq 0x78(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq 0x80(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq 0x90(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4c74f(%rip), %rsi     # 0x14b0b0
leaq 0x20(%rsp), %rdi
movl $0x64, %edx
callq 0xe8219
movq %rbp, %r15
jmp 0xfe87e
leaq 0x4c751(%rip), %rsi     # 0x14b0d0
jmp 0xfe86f
movq %r12, %rdi
movl $0x3, %esi
callq 0xf1bed
leaq 0x4c7c4(%rip), %rdx     # 0x14b15c
leaq 0x4c731(%rip), %rcx     # 0x14b0d0
leaq 0x20(%rsp), %rdi
movl $0x64, %esi
movl %eax, %r8d
xorl %eax, %eax
callq 0xe8193
jmp 0xfe87e
leaq 0x4c798(%rip), %rsi     # 0x14b157
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe889f
jmp 0xfe87e