// File: /workspace/github_c_makefile_star2_O2/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 0xdebae
movl $0xa8, %esi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
movq %rax, %r14
leaq 0x747c5(%rip), %rsi     # 0x12c3ee
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x18(%rsp), %rsi
movq $0x4, (%rsi)
movq 0x18(%rbx), %rdi
callq 0xe40bf
movq %rax, (%r15)
leaq 0x74b2e(%rip), %rsi     # 0x12c78d
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r15, 0x10(%rsp)
movq (%r15), %rsi
cmpq $0x100, %rsi            # imm = 0x100
jle 0xb7cc6
movq 0x8(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x48
popq %rdx
movq %rbx, %rdi
callq 0xdf66f
movq %rax, 0x8(%r14)
pushq $0x40
popq %r12
xorl %r15d, %r15d
cmpq (%r14), %r15
jge 0xb806f
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
leaq 0x74aa9(%rip), %rsi     # 0x12c79d
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x8(%r14), %r13
movq 0x18(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0x10, %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jg 0xb7c7c
leaq 0x28(%rsp), %rsi
callq 0xe40bf
movl %eax, -0x20(%r13,%r12)
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
jbe 0xb7d72
cmpl $0x10, %eax
je 0xb7ddc
cmpl $0x20, %eax
je 0xb7df3
cmpl $0x40, %eax
je 0xb7de5
cmpl $0x80, %eax
je 0xb7dd3
cmpl $0x100, %eax            # imm = 0x100
jne 0xb7d97
leaq 0x74b26(%rip), %rcx     # 0x12c896
jmp 0xb7dec
leaq 0x749e7(%rip), %rdx     # 0x12c760
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x50c79(%rip), %rcx     # 0x108a02
movq %rcx, -0x8(%r13,%r12)
leaq 0x65b(%rip), %rdx       # 0xb83f0
jmp 0xb7e06
leaq 0x67143(%rip), %rcx     # 0x11eee1
jmp 0xb7dec
leaq 0x74ac5(%rip), %rcx     # 0x12c86c
movq %rcx, -0x8(%r13,%r12)
leaq 0x916(%rip), %rdx       # 0xb86c9
jmp 0xb7e06
leaq 0x74ade(%rip), %rcx     # 0x12c89a
jmp 0xb7dec
leaq 0x5a1c7(%rip), %rcx     # 0x111f8c
movq %rcx, -0x8(%r13,%r12)
leaq 0xc85(%rip), %rdx       # 0xb8a56
jmp 0xb7e06
leaq 0x74ab0(%rip), %rcx     # 0x12c88a
jmp 0xb7dec
leaq 0x74a85(%rip), %rcx     # 0x12c868
jmp 0xb7dec
leaq 0x74a96(%rip), %rcx     # 0x12c882
movq %rcx, -0x8(%r13,%r12)
jmp 0xb7e0b
leaq 0x74a7a(%rip), %rcx     # 0x12c874
movq %rcx, -0x8(%r13,%r12)
leaq 0xeb2(%rip), %rdx       # 0xb8cb8
movq %rdx, (%r13,%r12)
movq %r14, %rbp
movq %rbx, %rdi
leaq 0x688e4(%rip), %rsi     # 0x1206fc
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x28(%rsp), %rsi
movq 0x18(%rbx), %rdi
callq 0xe409f
movl %eax, -0x40(%r13,%r12)
movq %rbx, %rdi
leaq 0x74ac4(%rip), %rsi     # 0x12c902
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movl -0x40(%r13,%r12), %edx
leaq 0x74da6(%rip), %rcx     # 0x12cc04
movl $0xffffff00, %eax       # imm = 0xFFFFFF00
andl %eax, %edx
movl %edx, -0x3c(%r13,%r12)
je 0xb7ebe
cmpl $0x100, %edx            # imm = 0x100
jne 0xb7e9d
movl -0x20(%r13,%r12), %eax
leaq 0x74d8c(%rip), %rcx     # 0x12cc0c
cmpl $0x2, %eax
je 0xb7ebe
cmpl $0x4, %eax
je 0xb7eb7
cmpl $0x10, %eax
je 0xb7eb7
leaq 0x74d76(%rip), %rcx     # 0x12cc0c
cmpl $0x100, %eax            # imm = 0x100
je 0xb7ebe
cmpl $0x200, %edx            # imm = 0x200
leaq 0x67037(%rip), %rcx     # 0x11eee1
leaq 0x74d63(%rip), %rax     # 0x12cc14
cmoveq %rax, %rcx
jmp 0xb7ebe
leaq 0x74d60(%rip), %rcx     # 0x12cc1e
movq %rbx, %rdi
leaq 0x74d69(%rip), %rsi     # 0x12cc31
xorl %eax, %eax
callq 0xde896
movl -0x40(%r13,%r12), %ecx
andl $0x3, %ecx
movl %ecx, -0x38(%r13,%r12)
pushq $0x1
popq %r14
movl %r14d, %eax
shll %cl, %eax
movl %eax, -0x34(%r13,%r12)
movq %rbx, %rdi
leaq 0x74d57(%rip), %rsi     # 0x12cc4b
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movl -0x40(%r13,%r12), %eax
andl $0x4, %eax
movl %eax, %ecx
shrl $0x2, %ecx
xorl $0x1, %ecx
testl %eax, %eax
movl %ecx, -0x30(%r13,%r12)
leaq 0x5f6c8(%rip), %rdx     # 0x1175e5
leaq 0x57b61(%rip), %rax     # 0x10fa85
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x74d43(%rip), %rsi     # 0x12cc75
xorl %eax, %eax
callq 0xde896
movl -0x40(%r13,%r12), %eax
andl $0x8, %eax
movl %eax, %ecx
shrl $0x3, %ecx
testl %eax, %eax
movl %ecx, -0x2c(%r13,%r12)
leaq 0x74d44(%rip), %rdx     # 0x12cc98
leaq 0x52d35(%rip), %rax     # 0x10ac90
cmoveq %rax, %rdx
movq %rbx, %rdi
leaq 0x74d1b(%rip), %rsi     # 0x12cc84
xorl %eax, %eax
callq 0xde896
movl -0x40(%r13,%r12), %ecx
shrl $0x4, %ecx
andl $0x3, %ecx
movl %ecx, -0x28(%r13,%r12)
movl %r14d, %eax
shll %cl, %eax
movl %eax, -0x24(%r13,%r12)
movq %rbx, %rdi
leaq 0x74d08(%rip), %rsi     # 0x12cc9c
movl %ecx, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq $0x4, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0xe40bf
movq %rax, -0x18(%r13,%r12)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe40bf
movq %rax, -0x10(%r13,%r12)
movq -0x18(%r13,%r12), %rcx
movq %rbx, %rdi
leaq 0x7480b(%rip), %rsi     # 0x12c7f1
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq -0x18(%r13,%r12), %r8
movq -0x10(%r13,%r12), %rcx
leaq (%r8,%rcx), %rax
movq 0x18(%rbx), %rdx
cmpq 0x18(%rdx), %rax
movq %rbp, %r14
jle 0xb803f
cmpl $0x100, -0x20(%r13,%r12) # imm = 0x100
jne 0xb8029
movq %rbx, %rdi
leaq 0x747e8(%rip), %rsi     # 0x12c808
xorl %eax, %eax
callq 0xde896
jmp 0xb803f
movq -0x8(%r13,%r12), %rdx
movq %rbx, %rdi
leaq 0x747f0(%rip), %rsi     # 0x12c828
xorl %eax, %eax
callq 0xdf05a
movq -0x10(%r13,%r12), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0xb7c7c
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq $0x10, 0x18(%rsp)
incq %r15
addq $0x48, %r12
jmp 0xb7cdc
pushq $0x1
popq %r12
movq %rbx, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0xb83ac
movq 0x10(%rsp), %r15
addq $0x58, %r15
leaq 0x74723(%rip), %rsi     # 0x12c7b4
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
je 0xb80d0
leaq 0x74719(%rip), %rsi     # 0x12c7bd
movq %r15, %rdi
callq 0x181a0
testl %eax, %eax
jne 0xb80d5
movzbl 0x80(%r14), %eax
cmpl $0x32, %eax
je 0xb836a
cmpl $0x31, %eax
jne 0xb80d5
cmpb $0x0, 0x81(%r14)
jne 0xb80d5
movb $0x1, 0x51(%r14)
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb83ac
testl %eax, %eax
je 0xb81f1
pushq $0x20
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb83ac
cmpb $0x0, 0x50(%r14)
je 0xb81fa
pushq $0x8
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb83ac
testl %eax, %eax
je 0xb8229
cmpq $0x0, 0x18(%r14)
je 0xb7c7c
cmpq $0x0, 0x28(%r14)
je 0xb7c7c
movq %rbx, %rdi
callq 0xe9d18
movq 0x10(%r14), %rsi
movq %rsi, 0x18(%rax)
movb $0x1, 0x10(%rax)
cmpb $0x0, 0x51(%r14)
jne 0xb8152
cmpb $0x0, 0x52(%r14)
je 0xb8158
movw $0x101, 0x11(%rax)      # imm = 0x101
pushq $0x28
popq %rdx
movq %rbx, %rdi
movq %rax, 0x8(%rsp)
callq 0xdf66f
movq 0x8(%rsp), %rcx
movq %rax, 0x20(%rcx)
movl 0x54(%r14), %esi
leaq 0x28(%rsp), %rdi
callq 0xe11fc
movq 0x8(%rsp), %rsi
movq 0x18(%rsi), %rax
xorl %ecx, %ecx
testq %rax, %rax
movl $0x0, %edx
cmovgq %rax, %rdx
pushq $0x16
popq %r10
xorl %r11d, %r11d
subq $0x1, %rdx
jb 0xb823f
movq 0x18(%r14), %rdi
cmpl $0xfffffff, -0x12(%rdi,%r10) # imm = 0xFFFFFFF
je 0xb81eb
movswl -0x2(%rdi,%r10), %r8d
addl -0xe(%rdi,%r10), %r8d
movswl (%rdi,%r10), %r9d
addl %r8d, %r9d
cmpl %r12d, %r9d
cmovgl %r9d, %r12d
movl -0xa(%rdi,%r10), %r8d
movl -0x6(%rdi,%r10), %edi
cmpl %r11d, %edi
cmovgl %edi, %r11d
subl %edi, %r8d
cmpl %ecx, %r8d
cmovgl %r8d, %ecx
addq $0x18, %r10
jmp 0xb819d
leaq 0x745cd(%rip), %rsi     # 0x12c7c5
jmp 0xb8230
andw $0x0, 0x51(%r14)
movq 0x10(%r14), %rax
xorl %ecx, %ecx
testq %rax, %rax
cmovleq %rcx, %rax
pushq $0x4
popq %rdx
cmpq %rcx, %rax
je 0xb8104
movq 0x18(%r14), %rsi
movl %ecx, (%rsi,%rdx)
incq %rcx
addq $0x18, %rdx
jmp 0xb8210
leaq 0x745ab(%rip), %rsi     # 0x12c7db
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0xb7c7c
movl %r12d, (%rsi)
movl %r11d, 0x20(%rsp)
addl %r11d, %ecx
cmpl $0x2, %ecx
pushq $0x1
popq %rdx
cmovgel %ecx, %edx
movl %edx, 0x4(%rsi)
pushq $0x14
popq %r12
xorl %ebp, %ebp
xorl %ecx, %ecx
cmpq %rax, %rcx
jge 0xb833f
movq 0x18(%r14), %r15
movl -0x10(%r15,%r12), %eax
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
je 0xb832b
movq 0x20(%rsi), %r13
movl %eax, (%r13,%rbp)
cmpb $0x0, 0x51(%r14)
movq %rcx, 0x10(%rsp)
jne 0xb82a3
cmpb $0x0, 0x52(%r14)
je 0xb82a8
movl %eax, %edi
leaq 0x28(%rsp), %rsi
callq 0xe1679
movl %eax, 0x4(%r13,%rbp)
movl -0xc(%r15,%r12), %eax
movl %eax, 0x8(%r13,%rbp)
movl -0x8(%r15,%r12), %ecx
movl %ecx, 0xc(%r13,%rbp)
testl %eax, %eax
jns 0xb82c6
andl $0x0, 0x8(%r13,%rbp)
testl %ecx, %ecx
jns 0xb82d0
andl $0x0, 0xc(%r13,%rbp)
movl 0x20(%rsp), %ecx
subl -0x4(%r15,%r12), %ecx
movl %ecx, 0x10(%r13,%rbp)
movl (%r15,%r12), %ecx
movl %ecx, 0x14(%r13,%rbp)
addl $0x7, %eax
cltd
pushq $0x8
popq %rcx
idivl %ecx
movslq %eax, %rdi
movl 0x3c(%r14), %esi
callq 0xdfbb6
movq %rax, 0x18(%r13,%rbp)
movslq -0x8(%r15,%r12), %rcx
imulq %rax, %rcx
movl -0x14(%r15,%r12), %eax
addq %rax, %rcx
cmpq 0x20(%r14), %rcx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
jg 0xb832b
addq 0x28(%r14), %rax
movq %rax, 0x20(%r13,%rbp)
incq %rcx
movq 0x18(%rsi), %rax
addq $0x18, %r12
addq $0x28, %rbp
jmp 0xb825e
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rsi, %r15
callq 0xea0f6
movq 0x20(%r15), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9d28
jmp 0xb7c7c
cmpb $0x0, 0x81(%r14)
jne 0xb80d5
movb $0x1, 0x52(%r14)
movl $0x6, 0x54(%r14)
jmp 0xb80d5