// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
movl $0xa8, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq 0xa9f0e(%rip), %rsi     # 0x1c4f8e
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x165580
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %edx
leaq 0xaa22d(%rip), %rsi     # 0x1c52fd
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpq $0x100, (%rax)          # imm = 0x100
jle 0x11b0e9
jmp 0x11b31c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x48, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x11b1a2
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0xaa1d6(%rip), %rsi     # 0x1c530d
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
imulq $0x48, -0x28(%rbp), %rax
addq %rax, %rdx
movq -0x20(%rbp), %rcx
callq 0x11b3d0
cmpl $0x0, %eax
jne 0x11b177
jmp 0x11b31c
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x11b111
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x11b570
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
leaq 0xaa161(%rip), %rsi     # 0x1c5324
callq 0x191a0
cmpl $0x0, %eax
jne 0x11b1d7
movq -0x18(%rbp), %rax
movb $0x1, 0x51(%rax)
jmp 0x11b24b
movq -0x18(%rbp), %rdi
addq $0x58, %rdi
leaq 0xaa147(%rip), %rsi     # 0x1c532d
callq 0x191a0
cmpl $0x0, %eax
jne 0x11b249
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
leaq 0xa3c7a(%rip), %rsi     # 0x1bee7c
callq 0x191a0
cmpl $0x0, %eax
jne 0x11b216
movq -0x18(%rbp), %rax
movb $0x1, 0x51(%rax)
jmp 0x11b247
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
leaq 0xb1e4a(%rip), %rsi     # 0x1cd072
callq 0x191a0
cmpl $0x0, %eax
jne 0x11b245
movq -0x18(%rbp), %rax
movb $0x1, 0x52(%rax)
movq -0x18(%rbp), %rax
movl $0x6, 0x54(%rax)
jmp 0x11b247
jmp 0x11b249
jmp 0x11b24b
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x4, %edx
callq 0x11b570
cmpl $0x0, %eax
jne 0x11b279
movq -0x8(%rbp), %rdi
leaq 0xaa0c8(%rip), %rsi     # 0x1c5335
movb $0x0, %al
callq 0x15bfb0
jmp 0x11b31c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x20, %edx
callq 0x11b570
movq -0x18(%rbp), %rax
cmpb $0x0, 0x50(%rax)
jne 0x11b2e4
movq -0x18(%rbp), %rax
movb $0x0, 0x51(%rax)
movq -0x18(%rbp), %rax
movb $0x0, 0x52(%rax)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x11b2e2
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
imulq $0x18, -0x28(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x11b2ad
jmp 0x11b2e4
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x8, %edx
callq 0x11b570
cmpl $0x0, %eax
jne 0x11b30f
movq -0x8(%rbp), %rdi
leaq 0xaa045(%rip), %rsi     # 0x1c534b
movb $0x0, %al
callq 0x15bfb0
jmp 0x11b31c
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11b610
cmpq $0x0, -0x18(%rbp)
je 0x11b363
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)