// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/pff2.c
// Function: do_code_chix
static void do_code_chix(deark *c, lctx *d, const struct pff2_sectiontype_info *si,
	i64 pos1, i64 len)
{
	i64 i;
	i64 pos;
	i64 defpos;
	i32 codepoint;
	unsigned int storage_flags;

	if(d->found_CHIX_chunk) goto done;
	d->found_CHIX_chunk = 1;

	d->font->num_chars = len/9;
	de_dbg(c, "number of characters: %d", (int)d->font->num_chars);

	d->font->char_array = de_mallocarray(c, d->font->num_chars, sizeof(struct de_bitmap_font_char));

	for(i=0; i<d->font->num_chars; i++) {
		pos = pos1 + 9*i;
		codepoint = (i32)de_getu32be(pos);
		storage_flags = (unsigned int)de_getbyte(pos+4);
		defpos = de_getu32be(pos+5);
		de_dbg2(c, "code point U+%04X, index at %d, definition at %d",
			(unsigned int)codepoint, (int)pos, (int)defpos);
		if((storage_flags&0x07)!=0) {
			de_err(c, "Compressed PFF2 format is not supported");
			goto done;
		}
		de_dbg_indent(c, 1);
		do_char(c, d, i, codepoint, defpos);
		de_dbg_indent(c, -1);
	}

	de_font_bitmap_font_to_image(c, d->font, NULL, 0);

done: ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpb $0x0, 0x8(%rsi)
je 0xab152
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r15
movq %rdi, %rbx
movq %rcx, 0x20(%rsp)
movb $0x1, 0x8(%rsi)
pushq $0x9
popq %rcx
movq %r8, %rax
cqto
idivq %rcx
movq (%rsi), %rcx
movq %rax, 0x18(%rcx)
leaq 0x66d53(%rip), %rsi     # 0x111ecd
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq (%r15), %rax
movq 0x18(%rax), %rsi
pushq $0x28
popq %rdx
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
callq 0xdf66f
movq (%r15), %rsi
movq %rax, 0x20(%rsi)
xorl %r14d, %r14d
cmpq 0x18(%rsi), %r14
jge 0xab35f
movq %r15, %r12
leaq (%r14,%r14,8), %r13
movq 0x20(%rsp), %r15
leaq (%r15,%r13), %rsi
movq %rsi, 0x10(%rsp)
movq 0x18(%rsp), %rbp
movq 0x18(%rbp), %rdi
callq 0xe404f
movq %rax, %rbx
movq 0x18(%rbp), %rdi
leaq (%r15,%r13), %rsi
addq $0x4, %rsi
callq 0xe3eb4
movb %al, 0xf(%rsp)
movq 0x18(%rbp), %rdi
leaq (%r15,%r13), %rsi
addq $0x5, %rsi
callq 0xe404f
movq %rax, %r13
movq %rbp, %rdi
leaq 0x7e33e(%rip), %rsi     # 0x129545
movl %ebx, %edx
movq 0x10(%rsp), %rcx
movl %r13d, %r8d
xorl %eax, %eax
callq 0xde9f1
testb $0x7, 0xf(%rsp)
jne 0xab37b
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %r12, %r15
movq (%r12), %rax
movq 0x20(%rax), %r12
movq %r14, 0x10(%rsp)
imulq $0x28, %r14, %r14
movl %ebx, 0x4(%r12,%r14)
movq 0x18(%rbp), %rdi
movq %r13, %rsi
callq 0xe3f46
movl %eax, 0x8(%r12,%r14)
movq 0x18(%rbp), %rdi
leaq 0x2(%r13), %rsi
callq 0xe3f46
movl %eax, 0xc(%r12,%r14)
movl 0x8(%r12,%r14), %edx
movq (%r15), %rcx
cmpl (%rcx), %edx
movq %rbp, %rbx
jle 0xab27b
movl %edx, (%rcx)
cmpl %eax, 0x4(%rcx)
jge 0xab283
movl %eax, 0x4(%rcx)
addq %r14, %r12
addq $0xa, %r13
movq %rbx, %rdi
leaq 0x7e30a(%rip), %rsi     # 0x12959e
movl %eax, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0xde9f1
movl 0x8(%r12), %ecx
leal 0x7(%rcx), %eax
cltd
pushq $0x8
popq %rsi
idivl %esi
cltq
movq %rax, 0x18(%r12)
imull 0xc(%r12), %ecx
addl $0x7, %ecx
movl %ecx, %eax
cltd
idivl %esi
movslq %eax, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xdecaf
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0xe3cb7
movslq 0xc(%r12), %rsi
imulq 0x18(%r12), %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, 0x20(%r12)
xorl %r14d, %r14d
xorl %r13d, %r13d
movslq 0xc(%r12), %rax
cmpq %rax, %r13
jge 0xab339
movslq 0x8(%r12), %r8
movq %r13, %rsi
imulq %r8, %rsi
movq 0x20(%r12), %rdx
movq 0x18(%r12), %rcx
imulq %r14, %rcx
movq %rbp, %rdi
callq 0xe08ed
incq %r13
addq $0x8, %r14
jmp 0xab304
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xded32
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x10(%rsp), %r14
incq %r14
movq (%r15), %rsi
jmp 0xab1a4
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xea0f6
leaq 0x7e1f4(%rip), %rsi     # 0x129576
movq %rbp, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdf2a5
nop