// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/gemfont.c
// Function: de_run_gemfont
static void de_run_gemfont(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 i;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);
	d = de_malloc(c, sizeof(lctx));
	d->font = de_create_bitmap_font(c);
	d->font->has_nonunicode_codepoints = 1;

	if(!do_header(c, d)) goto done;

	d->font->nominal_width = 1; // This will be calculated later
	d->font->nominal_height = (int)d->form_height_pixels;
	if(d->font->nominal_height<1 || d->font->nominal_height>512) goto done;

	if(d->font->num_chars<1) goto done;
	d->font->char_array = de_mallocarray(c, d->font->num_chars, sizeof(struct de_bitmap_font_char));

	if(!do_characters(c, d)) goto done;

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

done:
	de_dbg_indent_restore(c, saved_indent_level);
	if(d->font) {
		if(d->font->char_array) {
			for(i=0; i<d->font->num_chars; i++) {
				de_free(c, d->font->char_array[i].bitmap);
			}
			de_free(c, d->font->char_array);
		}
		de_destroy_bitmap_font(c, d->font);
	}
	de_finfo_destroy(c, d->fi);
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
leaq 0x1c(%rsp), %rsi
callq 0xdebae
pushq $0x58
popq %rsi
movq %r15, %rdi
callq 0xdecaf
movq %rax, %r14
movq %r15, %rdi
callq 0xe9d18
movq %rax, (%r14)
movb $0x1, 0x10(%rax)
leaq 0xdf783(%rip), %rsi     # 0x12c3ee
movq %r15, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
xorl %esi, %esi
callq 0xe3fa3
leaq 0xc5316(%rip), %rsi     # 0x111fac
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x2
popq %rsi
callq 0xe3fa3
movq %rax, 0x8(%r14)
leaq 0xc52ff(%rip), %rsi     # 0x111fb8
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
callq 0xeac74
movq %rax, %r12
movq 0x18(%r15), %rdi
pushq $0x4
popq %rsi
pushq $0x20
popq %r13
movq %r13, %rdx
movq %rax, %rcx
movl %ebp, %r8d
movl %ebp, %r9d
callq 0xe4c9a
movq %r12, %rdi
callq 0xeb877
leaq 0xc51c2(%rip), %rsi     # 0x111ebd
movq %r15, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0xd0(%r15)
je 0x4cd4e
movq %r12, %rdi
callq 0xead03
movl 0x8(%r14), %ecx
leaq 0xbfd65(%rip), %rdx     # 0x10ca8a
pushq $0x5
popq %rsi
movq %r12, %rdi
xorl %eax, %eax
callq 0xeae8b
movq %r15, %rdi
callq 0xdfd1a
movq %rax, 0x50(%r14)
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xdfd55
movq %r12, %rdi
callq 0xeaf3c
movq 0x18(%r15), %rdi
pushq $0x24
popq %rsi
callq 0xe3fa3
movq %rax, 0x10(%r14)
movq 0x18(%r15), %rdi
pushq $0x26
popq %rsi
callq 0xe3fa3
movq %rax, 0x18(%r14)
movl 0x10(%r14), %edx
leaq 0xc5246(%rip), %rsi     # 0x111fc7
movq %r15, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
movq (%r14), %rcx
incq %rax
movq %rax, 0x18(%rcx)
movq 0x18(%r15), %rdi
pushq $0x32
popq %rsi
callq 0xe3fa3
movq %rax, %r12
movq 0x18(%r15), %rdi
pushq $0x34
popq %rsi
callq 0xe3fa3
movq %rax, 0x20(%r14)
leaq 0xc5220(%rip), %rsi     # 0x111fe5
movq %r15, %rdi
movl %r12d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x36
popq %rsi
callq 0xe3fa3
leaq 0xc522a(%rip), %rsi     # 0x112011
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x38
popq %rsi
callq 0xe3fa3
leaq 0xc521b(%rip), %rsi     # 0x112021
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x3e
popq %rsi
callq 0xe3fa3
leaq 0xc520d(%rip), %rsi     # 0x112032
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x42
popq %rsi
callq 0xe3fa3
movq %rax, %r12
leaq 0xcf2a6(%rip), %rsi     # 0x11c0ed
movq %r15, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
shrb $0x2, %r12b
andb $0x1, %r12b
movb %r12b, 0x48(%r14)
movzbl %r12b, %edx
leaq 0xc51d4(%rip), %rsi     # 0x11204a
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq 0x18(%r15), %rdi
pushq $0x44
popq %rsi
callq 0xe409f
leaq 0xc51bd(%rip), %rsi     # 0x11205d
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x48
popq %rsi
callq 0xe409f
movq %rax, 0x28(%r14)
movq 0x18(%r15), %rdi
pushq $0x4c
popq %rsi
callq 0xe409f
movq %rax, 0x30(%r14)
movl 0x28(%r14), %edx
leaq 0xc51a5(%rip), %rsi     # 0x11207c
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
movl 0x30(%r14), %edx
leaq 0xc51ae(%rip), %rsi     # 0x11209a
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rdi
pushq $0x50
popq %rsi
callq 0xe3fa3
movq %rax, 0x38(%r14)
movq 0x18(%r15), %rdi
pushq $0x52
popq %rsi
callq 0xe3fa3
movq %rax, 0x40(%r14)
movl 0x38(%r14), %edx
leaq 0xc518e(%rip), %rsi     # 0x1120af
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
movl 0x40(%r14), %edx
leaq 0xc518e(%rip), %rsi     # 0x1120c4
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
movl %ebp, %esi
callq 0xdeba7
movq (%r14), %rax
movl $0x1, (%rax)
movl 0x40(%r14), %ecx
movl %ecx, 0x4(%rax)
addl $0xfffffdff, %ecx       # imm = 0xFFFFFDFF
cmpl $0xfffffe00, %ecx       # imm = 0xFFFFFE00
jb 0x4d1b9
movq 0x18(%rax), %rsi
testq %rsi, %rsi
jle 0x4d1b9
pushq $0x28
popq %rdx
movq %r15, %rdi
callq 0xdf66f
movq (%r14), %rcx
movq %rax, 0x20(%rcx)
leaq 0xc5149(%rip), %rsi     # 0x1120db
movq $0x0, 0x8(%rsp)
movq %r15, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
movq 0x40(%r14), %r13
imulq 0x38(%r14), %r13
movq 0x30(%r14), %rax
addq %r13, %rax
movq 0x18(%r15), %rcx
cmpq 0x18(%rcx), %rax
jle 0x4cfd6
leaq 0xc511d(%rip), %rsi     # 0x1120ee
jmp 0x4d193
movq %r15, %rdi
movq %r13, %rsi
callq 0xdecaf
movq 0x18(%r15), %rdi
movq 0x30(%r14), %rdx
movq %rax, 0x8(%rsp)
movq %rax, %rsi
movq %r13, %rcx
callq 0xe3cb7
cmpb $0x0, 0x48(%r14)
je 0x4d024
testb $0x1, 0x38(%r14)
jne 0x4d18c
pushq $0x1
popq %rax
movq 0x8(%rsp), %rcx
cmpq %r13, %rax
jge 0x4d024
rolw $0x8, -0x1(%rcx,%rax)
addq $0x2, %rax
jmp 0x4d013
movq %r15, 0x10(%rsp)
xorl %r13d, %r13d
movq (%r14), %rax
cmpq 0x18(%rax), %r13
jge 0x4d15c
movq 0x20(%rax), %r15
imulq $0x28, %r13, %rbx
movq 0x10(%rsp), %r12
movq 0x18(%r12), %rdi
leaq (,%r13,2), %rsi
addq 0x28(%r14), %rsi
callq 0xe3fa3
movq %rax, %rbp
movq 0x18(%r12), %rdi
leaq 0x1(%r13), %rax
movq %rax, 0x20(%rsp)
leaq 0x2(,%r13,2), %rsi
addq 0x28(%r14), %rsi
callq 0xe3fa3
subl %ebp, %eax
movl %eax, 0x8(%r15,%rbx)
movq (%r14), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0xc(%r15,%rbx)
movl 0x10(%r14), %ecx
addl %r13d, %ecx
movl %ecx, (%r15,%rbx)
movq %r12, %rdi
leaq 0xc507a(%rip), %rsi     # 0x11211f
movl %r13d, %edx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0xde9f1
movq 0x20(%rsp), %rcx
movslq 0x8(%r15,%rbx), %rax
movq %rcx, %r13
testq %rax, %rax
jle 0x4d02c
movq %rcx, %r13
cmpl $0x200, %eax            # imm = 0x200
ja 0x4d02c
movq %rcx, %r13
cmpq %rax, 0x20(%r14)
jl 0x4d02c
movq %rcx, %r13
addq %rbx, %r15
addl $0x7, %eax
shrl $0x3, %eax
movq %rax, 0x18(%r15)
movslq 0xc(%r15), %rsi
imulq %rax, %rsi
movq 0x10(%rsp), %rdi
callq 0xdecaf
movq %rax, 0x20(%r15)
xorl %ebx, %ebx
movq 0x8(%rsp), %r12
movslq 0xc(%r15), %rax
cmpq %rax, %rbx
jge 0x4d146
movq 0x38(%r14), %rdi
imulq %rbx, %rdi
addq %r12, %rdi
movq 0x18(%r15), %rdx
imulq %rbx, %rdx
addq 0x20(%r15), %rdx
movslq 0x8(%r15), %r8
movq %rbp, %rsi
xorl %ecx, %ecx
callq 0xe08ed
incq %rbx
jmp 0x4d113
movl 0x8(%r15), %eax
movq (%r14), %rcx
cmpl (%rcx), %eax
jle 0x4d02c
movl %eax, (%rcx)
jmp 0x4d02c
pushq $-0x1
popq %rsi
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xdeba7
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0xded32
movq (%r14), %rsi
movq 0x50(%r14), %rdx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0xea0f6
jmp 0x4d1b5
leaq 0xc4f7d(%rip), %rsi     # 0x112110
movq %r15, %rdi
xorl %eax, %eax
callq 0xdf2a5
pushq $-0x1
popq %rsi
movq %r15, %rdi
callq 0xdeba7
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0xded32
pushq $0x20
popq %r13
movl 0x1c(%rsp), %esi
movq %r15, %rdi
callq 0xdebb7
movq (%r14), %rsi
testq %rsi, %rsi
je 0x4d20e
cmpq $0x0, 0x20(%rsi)
je 0x4d206
xorl %ebx, %ebx
movq 0x20(%rsi), %rax
cmpq 0x18(%rsi), %rbx
jge 0x4d1f8
movq (%rax,%r13), %rsi
movq %r15, %rdi
callq 0xded32
incq %rbx
movq (%r14), %rsi
addq $0x28, %r13
jmp 0x4d1d6
movq %r15, %rdi
movq %rax, %rsi
callq 0xded32
movq (%r14), %rsi
movq %r15, %rdi
callq 0xe9d28
movq 0x50(%r14), %rsi
movq %r15, %rdi
callq 0xdfd24
movq %r15, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq