// File: /workspace/github_c_makefile_star2_O2/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 0xdecaf
movq %rax, %r14
leaq 0x4b8bc(%rip), %rcx     # 0x13dc2c
movq %rcx, 0x18(%rax)
movq %r15, 0x20(%rax)
movq %rbp, (%rax)
movq %r13, 0x8(%rax)
movq %r12, 0x10(%rax)
movdqu (%r15), %xmm0
movdqu %xmm0, 0x30(%rax)
movl 0x18(%r15), %ecx
cmpl $0x2, %ecx
je 0xf23ba
cmpl $0x3, %ecx
je 0xf23a7
cmpl $0x4, %ecx
jne 0xf23c1
movb $0x1, 0x2a(%r14)
jmp 0xf23c1
testb $0x1, 0x20(%r15)
je 0xf23b3
movb $0x1, 0x2a(%r14)
movb $0x1, 0x28(%r14)
jmp 0xf23c1
movw $0x100, 0x28(%r14)      # imm = 0x100
movq %xmm0, %rsi
testq %rsi, %rsi
jle 0xf2a73
cmpq 0xa8(%rbx), %rsi
jg 0xf2a73
movq %rax, 0x10(%rsp)
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 0xdecaf
movq %rax, 0x78(%r14)
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, 0x80(%r14)
movq 0x88(%r14), %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, 0x90(%r14)
movq %r14, 0x8(%rsp)
movb 0x2a(%r14), %bpl
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
pushq $0x73
popq %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xf8601
movq %rax, (%r15)
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xf8601
movq %rax, 0x8(%r15)
testb %bpl, %bpl
je 0xf24c5
pushq $0xb
popq %rdx
movq %rbx, %rdi
movq %rdx, %rsi
callq 0xf8601
movq %rax, 0x10(%r15)
xorl %r14d, %r14d
leaq 0x4b663(%rip), %r12     # 0x13daf0
leaq 0x4b667(%rip), %r13     # 0x13dafb
leaq 0x4b66b(%rip), %rbp     # 0x13db06
cmpq $0xb, %r14
je 0xf24c5
movq 0x10(%r15), %rax
movq 0x8(%rax), %rsi
movzbl (%r14,%r12), %edx
movzbl (%r14,%r13), %ecx
movzbl (%r14,%rbp), %r8d
movq %rbx, %rdi
callq 0xf7e56
incq %r14
jmp 0xf249b
xorl %r13d, %r13d
leaq 0x4b811(%rip), %rbp     # 0x13dce0
leaq 0x4b64a(%rip), %r12     # 0x13db20
pushq $-0x1
popq %r14
cmpq $0x69, %r13
je 0xf2525
cmpq $0x40, %r13
ja 0xf24eb
movl %r13d, %r8d
jmp 0xf2502
movl %r14d, %r8d
cmpq $0x68, %r13
je 0xf2502
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 0xf7e56
incq %r13
jmp 0xf24da
xorl %r13d, %r13d
leaq 0x4b821(%rip), %rbp     # 0x13dd50
pushq $-0x1
popq %r14
cmpq $0x69, %r13
je 0xf257f
cmpq $0x40, %r13
ja 0xf2544
movl %r13d, %r8d
jmp 0xf255b
movl %r14d, %r8d
cmpq $0x68, %r13
je 0xf255b
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 0xf7e56
incq %r13
jmp 0xf2533
movb $0x0, 0x20(%rsp)
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0xf2b00
cmpb $0x0, 0x28(%r14)
je 0xf263c
movq 0x10(%rsp), %rax
leaq 0x48(%rax), %rbp
xorl %r14d, %r14d
movl $0x3ff, %r13d           # imm = 0x3FF
pushq $0x1
popq %r12
cmpq $-0x1, %r13
je 0xf25fc
movq %rbp, %rdi
movl %r12d, %esi
callq 0xe6a4a
movq 0x8(%rsp), %rcx
cmpb $0x0, 0x60(%rcx)
jne 0xf25fc
xorl %ecx, %ecx
testq %rax, %rax
jne 0xf25e1
cmpl $0x6, %r14d
ja 0xf25e9
incl %r14d
movl %r14d, %ecx
decq %r13
movl %ecx, %r14d
jmp 0xf25b2
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xf2d39
testl %eax, %eax
jne 0xf263c
movq 0x8(%rsp), %r14
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xf299f
movq (%r14), %rax
cmpq $0x0, 0x10(%rax)
jle 0xf299f
leaq 0x4b613(%rip), %rsi     # 0x13dc37
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
andw $0x0, 0x28(%r14)
movq %r14, %rdi
callq 0xf2b00
movq 0x8(%rsp), %r14
andq $0x0, 0x98(%r14)
andl $0x0, 0xa0(%r14)
andq $0x0, 0xa8(%r14)
orq $-0x1, 0xb0(%r14)
andw $0x0, 0xb8(%r14)
movq 0x10(%rsp), %r12
leaq 0x48(%r12), %rbp
addq $0x68, %r12
leaq 0x4(%rsp), %r13
xorl %eax, %eax
andl $0x0, 0x4(%rsp)
movq 0x38(%r14), %rcx
cmpq %rcx, %rax
jge 0xf29de
decq %rcx
cmpq %rcx, %rax
jne 0xf26aa
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jge 0xf29de
movq 0x8(%r14), %rax
cmpb $0x0, 0x8(%rax)
je 0xf26c2
movq 0x40(%r14), %rcx
cmpq 0x10(%rax), %rcx
jg 0xf29de
cmpb $0x0, 0x60(%r14)
jne 0xf29af
cmpb $0x0, 0x28(%r14)
jne 0xf2707
movq 0xb0(%r14), %rax
cmpq 0x30(%r14), %rax
jl 0xf2707
cmpl $0x0, 0xa0(%r14)
jne 0xf2707
cmpb $0x0, 0x29(%r14)
je 0xf26fa
movq %r12, %rdi
callq 0xe6a40
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xf2b34
cmpb $0x0, 0x2a(%r14)
je 0xf2751
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xf2743
cmpb $0x0, 0xb9(%r14)
jne 0xf2743
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xe6a4a
movb %al, 0xba(%r14)
movb $0x1, 0xb9(%r14)
cmpb $0x0, 0x2a(%r14)
je 0xf2751
cmpl $0x0, 0xa0(%r14)
je 0xf2839
movzbl 0xb8(%r14), %eax
movq (%r15,%rax,8), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xf8071
testl %eax, %eax
je 0xf29a8
movslq 0x4(%rsp), %rax
cmpq $-0x1, %rax
je 0xf27dd
movq 0x98(%r14), %rdx
addq %rax, %rdx
cmpl $0x3f, %eax
jg 0xf282d
movq %rdx, 0x98(%r14)
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0xf2c92
andq $0x0, 0x98(%r14)
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
movl 0xa0(%r14), %eax
testl %eax, %eax
je 0xf2993
decl %eax
movl %eax, 0xa0(%r14)
jmp 0xf2993
cmpb $0x0, 0x28(%r14)
je 0xf29b8
cmpl $0x0, 0xa0(%r14)
jne 0xf29b8
movq %r14, %rdi
pushq $0x40
popq %rsi
leaq 0x18(%rsp), %rdx
callq 0xf2d39
testl %eax, %eax
je 0xf29c1
cmpq $0x3, 0x18(%rsp)
jle 0xf29ca
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x1
popq %rdx
callq 0xf2b34
jmp 0xf2993
movq %rdx, 0x98(%r14)
jmp 0xf2993
movq 0x20(%r14), %rax
cmpl $0x3, 0x18(%rax)
jne 0xf2851
cmpb $0x0, 0xba(%r14)
jne 0xf2751
movq 0x10(%r15), %rax
movq 0x8(%rax), %rdi
movq %rbp, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xf8071
testl %eax, %eax
je 0xf29a8
movl 0x4(%rsp), %edx
movq %rbx, %rdi
leaq 0x2b322(%rip), %rsi     # 0x11db9e
xorl %eax, %eax
callq 0xdea83
movl 0x4(%rsp), %eax
leal -0x61(%rax), %ecx
cmpl $0x6, %ecx
ja 0xf28f4
movq %r14, %rdi
callq 0xf2c35
movl 0xb0(%r14), %edx
movl 0xc0(%r14), %ecx
movq %rbx, %rdi
leaq 0x4b3cc(%rip), %rsi     # 0x13dc7b
xorl %eax, %eax
callq 0xdea83
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
pushq $0x1
popq %rcx
callq 0xf2c92
cmpb $0x0, 0xb8(%r14)
sete 0xb8(%r14)
jmp 0xf2993
cmpl $0x3, %eax
ja 0xf29de
movl %eax, %eax
leaq 0x4b1da(%rip), %rcx     # 0x13dae0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x28(%r14)
je 0xf2aea
movq %r14, %rdi
pushq $0x40
popq %rsi
xorl %edx, %edx
callq 0xf2d39
testl %eax, %eax
jne 0xf281a
jmp 0xf29c1
movl $0x2, 0xa0(%r14)
jmp 0xf2993
movq %r14, %rdi
callq 0xf2c35
movq 0x30(%r14), %rax
movq 0xc0(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rax, %rdx
jge 0xf2974
movq 0x80(%r14), %rsi
movb (%rcx,%rsi), %dil
cmpb 0x1(%rcx,%rsi), %dil
movq %rdx, %rcx
je 0xf2954
jmp 0xf2977
movq %rax, %rdx
movq %rdx, 0xc8(%r14)
subq 0xb0(%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
pushq $0x1
popq %rcx
callq 0xf2c92
movq 0xa8(%r14), %rax
jmp 0xf267f
leaq 0x4b2bc(%rip), %rsi     # 0x13dc62
jmp 0xf29d1
cmpb $0x0, 0x60(%r14)
je 0xf29b8
leaq 0x4b1da(%rip), %rsi     # 0x13db90
jmp 0xf29d1
leaq 0x4b201(%rip), %rsi     # 0x13dbc0
jmp 0xf29d1
leaq 0x4b218(%rip), %rsi     # 0x13dbe0
jmp 0xf29d1
leaq 0x4b22f(%rip), %rsi     # 0x13dc00
leaq 0x20(%rsp), %rdi
pushq $0x64
popq %rdx
callq 0xde492
cmpq $0x0, 0xb0(%r14)
jle 0xf29f5
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xf2b34
cmpb $0x0, 0x20(%rsp)
je 0xf2a40
cmpq $0x0, 0xa8(%r14)
jle 0xf2a22
movq 0x18(%r14), %rdx
leaq 0x4b283(%rip), %rsi     # 0x13dc94
leaq 0x20(%rsp), %rcx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
jmp 0xf2a40
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
leaq 0x152ce(%rip), %rcx     # 0x107cff
leaq 0x20(%rsp), %r8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xee823
movq (%r15), %rsi
movq %rbx, %rdi
callq 0xf86b0
movq 0x8(%r15), %rsi
movq %rbx, %rdi
callq 0xf86b0
movq 0x10(%r15), %rsi
testq %rsi, %rsi
je 0xf2a68
movq %rbx, %rdi
callq 0xf86b0
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
movq 0x78(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq 0x80(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq 0x90(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x3
popq %rsi
movq %rbp, %rdi
callq 0xe6a4a
leaq 0x4b1c0(%rip), %rdx     # 0x13dc8c
leaq 0x4b12d(%rip), %rcx     # 0x13dc00
leaq 0x20(%rsp), %rdi
pushq $0x64
popq %rsi
movl %eax, %r8d
xorl %eax, %eax
callq 0xde40c
jmp 0xf29de
leaq 0x4b196(%rip), %rsi     # 0x13dc87
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdea83
jmp 0xf29de