// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/pcf.c
// Function: de_run_pcf
static void de_run_pcf(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	i64 k;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(lctx));

	pos = 0;
	de_dbg(c, "header at %d", (int)pos);
	de_dbg_indent(c, 1);

	pos += 4; // signature

	d->table_count = de_getu32le_p(&pos);
	de_dbg(c, "table count: %u", (unsigned int)d->table_count);
	if(d->table_count>256) goto done;

	// We don't necessarily want to process the tables in the order they are
	// listed in the index, so first read the tables index into memory.
	d->tables = de_mallocarray(c, d->table_count, sizeof(struct table_entry));

	for(k=0; k<d->table_count; k++) {
		de_dbg(c, "table entry[%d] at %"I64_FMT, (int)k, pos);
		de_dbg_indent(c, 1);
		if(!do_read_table_entry(c, d, &d->tables[k], pos)) goto done;
		de_dbg_indent(c, -1);
		pos += 16;
	}

	// Now process the tables in the order we choose.

	process_table_by_type(c, d, TBLTYPE_PROPERTIES);

	if(!de_strcmp(d->charset_registry, "ISO10646")) {
		d->is_unicode = 1;
	}
	else if(!de_strcmp(d->charset_registry, "ISO8859")) {
		if(!de_strcmp(d->charset_encoding, "1")) {
			d->is_unicode = 1;
		}
		else if(!de_strcmp(d->charset_encoding, "2")) {
			d->can_translate_to_unicode = 1;
			d->src_encoding = DE_ENCODING_LATIN2;
		}
	}

	if(!process_table_by_type(c, d, TBLTYPE_METRICS)) {
		de_err(c, "Missing metrics table");
		goto done;
	}

	process_table_by_type(c, d, TBLTYPE_BDF_ENCODINGS);

	if(!d->has_encodings_table) {
		d->is_unicode = 0;
		d->can_translate_to_unicode = 0;
		for(k=0; k<d->num_chars; k++) {
			d->chars[k].codepoint = (i32)k;
		}
	}

	if(!process_table_by_type(c, d, TBLTYPE_BITMAPS)) {
		de_err(c, "Missing bitmaps table");
		goto done;
	}

	do_make_font_image(c, d);

done:
	if(d) {
		de_free(c, d->tables);
		de_free(c, d->chars);
		de_free(c, d->bitmaps_data);
		de_free(c, d);
	}
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x24(%rsp), %rsi
callq 0xe958c
movl $0xa8, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r15
movq %rax, %r14
leaq 0x18(%rsp), %r12
movq $0x0, (%r12)
leaq 0x79350(%rip), %rsi     # 0x13935e
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
addq $0x4, (%r12)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, (%r15)
leaq 0x796bb(%rip), %rsi     # 0x1396fd
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %r15, 0x10(%rsp)
movq (%r15), %rsi
cmpq $0x100, %rsi            # imm = 0x100
jg 0xc0586
movl $0x48, %edx
movq %rbx, %rdi
callq 0xea259
movq %rax, 0x8(%r14)
movq (%r14), %rax
testq %rax, %rax
jle 0xc042d
movl $0x40, %r12d
leaq 0x28(%rsp), %r13
xorl %ebp, %ebp
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
leaq 0x79671(%rip), %rsi     # 0x13970d
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x8(%r14), %r15
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0x10, %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0xc0586
movq %r13, %rsi
callq 0xef3a0
movl %eax, -0x20(%r15,%r12)
cmpl $0x1f, %eax
jg 0xc0114
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0xc0146
leaq 0x795dd(%rip), %rdx     # 0x1396d0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x558df(%rip), %rcx     # 0x1159e2
movq %rcx, -0x8(%r15,%r12)
leaq 0x733(%rip), %rcx       # 0xc0842
jmp 0xc01a3
cmpl $0x7f, %eax
jg 0xc012f
cmpl $0x20, %eax
je 0xc0190
cmpl $0x40, %eax
jne 0xc0154
leaq 0x796c8(%rip), %rcx     # 0x1397f2
jmp 0xc01b0
cmpl $0x80, %eax
je 0xc01a9
cmpl $0x100, %eax            # imm = 0x100
jne 0xc0154
leaq 0x796c2(%rip), %rcx     # 0x139806
jmp 0xc01b0
cmpl $0x10, %eax
jne 0xc0154
leaq 0x79686(%rip), %rcx     # 0x1397d8
jmp 0xc01b0
leaq 0x6bd0e(%rip), %rcx     # 0x12be69
jmp 0xc01b0
leaq 0x5edf0(%rip), %rcx     # 0x11ef54
movq %rcx, -0x8(%r15,%r12)
leaq 0xd31(%rip), %rcx       # 0xc0ea1
jmp 0xc01a3
leaq 0x79691(%rip), %rcx     # 0x13980a
jmp 0xc01b0
leaq 0x7965a(%rip), %rcx     # 0x1397dc
movq %rcx, -0x8(%r15,%r12)
leaq 0x9cf(%rip), %rcx       # 0xc0b5d
jmp 0xc01a3
leaq 0x7964d(%rip), %rcx     # 0x1397e4
movq %rcx, -0x8(%r15,%r12)
leaq 0xf6d(%rip), %rcx       # 0xc1110
movq %rcx, (%r15,%r12)
jmp 0xc01b5
leaq 0x7964a(%rip), %rcx     # 0x1397fa
movq %rcx, -0x8(%r15,%r12)
movq -0x8(%r15,%r12), %rcx
movq %rbx, %rdi
leaq 0x6d4c0(%rip), %rsi     # 0x12d684
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x28(%rsp), %rsi
movq 0x18(%rbx), %rdi
callq 0xef37e
movl %eax, -0x40(%r15,%r12)
movq %rbx, %rdi
leaq 0x79688(%rip), %rsi     # 0x139872
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl -0x40(%r15,%r12), %edx
leaq 0x79968(%rip), %rcx     # 0x139b74
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl %eax, %edx
movl %edx, -0x3c(%r15,%r12)
je 0xc0279
cmpl $0x100, %edx            # imm = 0x100
jne 0xc0261
movl -0x20(%r15,%r12), %eax
leaq 0x7994e(%rip), %rcx     # 0x139b7c
cmpl $0x2, %eax
je 0xc0279
leaq 0x79942(%rip), %rcx     # 0x139b7c
cmpl $0x100, %eax            # imm = 0x100
je 0xc0279
cmpl $0x100, %edx            # imm = 0x100
jne 0xc0261
leaq 0x7993e(%rip), %rcx     # 0x139b8e
cmpl $0x4, %eax
je 0xc0279
leaq 0x79932(%rip), %rcx     # 0x139b8e
cmpl $0x10, %eax
je 0xc0279
cmpl $0x200, %edx            # imm = 0x200
leaq 0x6bbfb(%rip), %rcx     # 0x12be69
leaq 0x7990f(%rip), %rax     # 0x139b84
cmoveq %rax, %rcx
movq %rbx, %rdi
leaq 0x7991e(%rip), %rsi     # 0x139ba1
xorl %eax, %eax
callq 0xe9226
movl -0x40(%r15,%r12), %ecx
andl $0x3, %ecx
movl %ecx, -0x38(%r15,%r12)
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x34(%r15,%r12)
movq %rbx, %rdi
leaq 0x7990e(%rip), %rsi     # 0x139bbb
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movl -0x40(%r15,%r12), %eax
andl $0x4, %eax
movl %eax, %ecx
shrl $0x2, %ecx
xorl $0x1, %ecx
testl %eax, %eax
movl %ecx, -0x30(%r15,%r12)
leaq 0x642ef(%rip), %rdx     # 0x1245c5
leaq 0x5c788(%rip), %rax     # 0x11ca65
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x798fa(%rip), %rsi     # 0x139be5
xorl %eax, %eax
callq 0xe9226
movl -0x40(%r15,%r12), %eax
andl $0x8, %eax
movl %eax, %ecx
shrl $0x3, %ecx
testl %eax, %eax
movl %ecx, -0x2c(%r15,%r12)
leaq 0x798fb(%rip), %rdx     # 0x139c08
leaq 0x57934(%rip), %rax     # 0x117c48
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x798d2(%rip), %rsi     # 0x139bf4
xorl %eax, %eax
callq 0xe9226
movl -0x40(%r15,%r12), %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
movl %ecx, -0x28(%r15,%r12)
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x24(%r15,%r12)
movq %rbx, %rdi
leaq 0x798bd(%rip), %rsi     # 0x139c0c
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq $0x4, 0x28(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, -0x18(%r15,%r12)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, -0x10(%r15,%r12)
movq -0x18(%r15,%r12), %rcx
movq %rbx, %rdi
leaq 0x793c3(%rip), %rsi     # 0x139761
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq -0x18(%r15,%r12), %r8
movq -0x10(%r15,%r12), %rcx
leaq (%r8,%rcx), %rax
movq 0x18(%rbx), %rdx
cmpq 0x18(%rdx), %rax
jle 0xc03f4
cmpl $0x100, -0x20(%r15,%r12) # imm = 0x100
jne 0xc03de
movq %rbx, %rdi
leaq 0x793a3(%rip), %rsi     # 0x139778
xorl %eax, %eax
callq 0xe9226
jmp 0xc03f4
movq -0x8(%r15,%r12), %rdx
movq %rbx, %rdi
leaq 0x793ab(%rip), %rsi     # 0x139798
xorl %eax, %eax
callq 0xe9b27
movq -0x10(%r15,%r12), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0xc0586
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq $0x10, 0x18(%rsp)
incq %rbp
movq (%r14), %rax
addq $0x48, %r12
cmpq %rax, %rbp
jl 0xc008d
testq %rax, %rax
movq 0x10(%rsp), %r15
jle 0xc045d
movq 0x8(%r14), %rdx
cmpl $0x1, 0x20(%rdx)
je 0xc044c
addq $0x48, %rdx
decq %rax
jne 0xc043b
jmp 0xc045d
movq 0x40(%rdx), %rax
testq %rax, %rax
je 0xc045d
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
leaq 0x58(%r15), %r12
leaq 0x792bc(%rip), %rsi     # 0x139724
movq %r12, %rdi
callq 0x181a0
testl %eax, %eax
je 0xc04c0
leaq 0x792b2(%rip), %rsi     # 0x13972d
movq %r12, %rdi
callq 0x181a0
testl %eax, %eax
jne 0xc04c5
subq $-0x80, %r15
leaq 0x72bab(%rip), %rsi     # 0x13303d
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
je 0xc04c0
leaq 0x80ba2(%rip), %rsi     # 0x141047
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
jne 0xc04c5
movb $0x1, 0x52(%r14)
movl $0x6, 0x54(%r14)
jmp 0xc04c5
movb $0x1, 0x51(%r14)
movq (%r14), %rax
testq %rax, %rax
jle 0xc04e0
movq 0x8(%r14), %rdx
cmpl $0x4, 0x20(%rdx)
je 0xc04ec
addq $0x48, %rdx
decq %rax
jne 0xc04d1
leaq 0x7924e(%rip), %rsi     # 0x139735
jmp 0xc057c
movq 0x40(%rdx), %rax
testq %rax, %rax
je 0xc04fd
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
movq (%r14), %rax
testq %rax, %rax
jle 0xc052b
movq 0x8(%r14), %rdx
cmpl $0x20, 0x20(%rdx)
je 0xc051a
addq $0x48, %rdx
decq %rax
jne 0xc0509
jmp 0xc052b
movq 0x40(%rdx), %rax
testq %rax, %rax
je 0xc052b
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
cmpb $0x0, 0x50(%r14)
jne 0xc055a
movw $0x0, 0x51(%r14)
movq 0x10(%r14), %rax
testq %rax, %rax
jle 0xc055a
movq 0x18(%r14), %rcx
addq $0x4, %rcx
xorl %edx, %edx
movl %edx, (%rcx)
incq %rdx
addq $0x18, %rcx
cmpq %rdx, %rax
jne 0xc054c
movq (%r14), %rax
testq %rax, %rax
jle 0xc0575
movq 0x8(%r14), %rdx
cmpl $0x8, 0x20(%rdx)
je 0xc05d0
addq $0x48, %rdx
decq %rax
jne 0xc0566
leaq 0x791cf(%rip), %rsi     # 0x13974b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0xe9752
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40(%rdx), %rax
testq %rax, %rax
je 0xc05e1
movq %rbx, %rdi
movq %r14, %rsi
callq *%rax
cmpq $0x0, 0x18(%r14)
je 0xc06b4
cmpq $0x0, 0x28(%r14)
je 0xc06b4
movq %rbx, %rdi
callq 0xf57ec
movq 0x10(%r14), %rsi
movq %rsi, 0x18(%rax)
movb $0x1, 0x10(%rax)
cmpb $0x0, 0x51(%r14)
jne 0xc0619
cmpb $0x0, 0x52(%r14)
je 0xc061f
movw $0x101, 0x11(%rax)      # imm = 0x101
movl $0x28, %edx
movq %rbx, %rdi
movq %rax, 0x8(%rsp)
callq 0xea259
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
movl 0x54(%r14), %esi
leaq 0x28(%rsp), %rdi
callq 0xec207
movq 0x8(%rsp), %rsi
movq 0x18(%rsi), %rax
movl $0x1, %ecx
testq %rax, %rax
jle 0xc06bc
movq 0x18(%r14), %rdi
addq $0x16, %rdi
xorl %ebp, %ebp
movl $0x1, %edx
movq %rax, %r8
xorl %r11d, %r11d
cmpl $0xfffffff, -0x12(%rdi) # imm = 0xFFFFFFF
je 0xc06a9
movswl -0x2(%rdi), %r9d
addl -0xe(%rdi), %r9d
movswl (%rdi), %r10d
addl %r9d, %r10d
cmpl %edx, %r10d
cmovgl %r10d, %edx
movl -0xa(%rdi), %r9d
movl -0x6(%rdi), %r10d
cmpl %ebp, %r10d
cmovgl %r10d, %ebp
subl %r10d, %r9d
cmpl %r11d, %r9d
cmovgl %r9d, %r11d
addq $0x18, %rdi
decq %r8
jne 0xc0670
jmp 0xc06c6
xorl %r15d, %r15d
jmp 0xc07f7
xorl %r11d, %r11d
xorl %ebp, %ebp
movl $0x1, %edx
movl %ebp, 0x20(%rsp)
addl %ebp, %r11d
cmpl $0x2, %r11d
cmovgel %r11d, %ecx
movl %edx, (%rsi)
movl %ecx, 0x4(%rsi)
testq %rax, %rax
jle 0xc07e6
movl $0x16, %r13d
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%r14), %rbp
movl -0x12(%rbp,%r13), %eax
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
je 0xc07d1
movq 0x20(%rsi), %rdx
movl %eax, (%rdx,%r12)
cmpb $0x0, 0x51(%r14)
movq %rdx, 0x10(%rsp)
jne 0xc072f
cmpb $0x0, 0x52(%r14)
je 0xc0734
movl %eax, %edi
leaq 0x28(%rsp), %rsi
callq 0xec6fd
movq 0x10(%rsp), %rdx
movl %eax, 0x4(%rdx,%r12)
movl -0xe(%rbp,%r13), %eax
movl %eax, 0x8(%rdx,%r12)
movl -0xa(%rbp,%r13), %ecx
movl %ecx, 0xc(%rdx,%r12)
testl %eax, %eax
jns 0xc0755
movl $0x0, 0x8(%rdx,%r12)
testl %ecx, %ecx
jns 0xc0762
movl $0x0, 0xc(%rdx,%r12)
movl 0x20(%rsp), %ecx
subl -0x6(%rbp,%r13), %ecx
movl %ecx, 0x10(%rdx,%r12)
movzwl -0x2(%rbp,%r13), %ecx
movw %cx, 0x14(%rdx,%r12)
leal 0x7(%rax), %ecx
addl $0xe, %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
movzwl (%rbp,%r13), %ecx
movw %cx, 0x16(%rdx,%r12)
sarl $0x3, %eax
movslq %eax, %rdi
movl 0x3c(%r14), %esi
callq 0xea80b
movq 0x10(%rsp), %rdx
movq %rax, 0x18(%rdx,%r12)
movslq -0xa(%rbp,%r13), %rcx
imulq %rax, %rcx
movl -0x16(%rbp,%r13), %eax
addq %rax, %rcx
cmpq 0x20(%r14), %rcx
movq 0x8(%rsp), %rsi
jg 0xc07d1
addq 0x28(%r14), %rax
movq %rax, 0x20(%rdx,%r12)
incq %r15
addq $0x18, %r13
addq $0x28, %r12
cmpq 0x18(%rsi), %r15
jl 0xc06ef
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xf5c29
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0xc0586
movq 0x20(%r15), %rsi
movq %rbx, %rdi
callq 0xe9752
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf5801
jmp 0xc0586