// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdi, %rbx
leaq 0x4(%rsp), %rsi
callq 0xe8a1c
movl $0x58, %esi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r14
movq %rbx, %rdi
callq 0xf5358
movq %rax, (%r14)
movb $0x1, 0x10(%rax)
leaq 0xea3e1(%rip), %rsi     # 0x1396ee
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xeebc8
leaq 0xcfd44(%rip), %rsi     # 0x11f07c
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xeebc8
movq %rax, 0x8(%r14)
leaq 0xcfd2b(%rip), %rsi     # 0x11f088
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r15
movq 0x18(%rbx), %rdi
movl $0x4, %esi
movl $0x20, %edx
movq %rax, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0xefbd7
movq %r15, %rdi
callq 0xf70f6
leaq 0xcfbe8(%rip), %rsi     # 0x11ef8d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0xd0(%rbx)
je 0x4f3f9
movq %r15, %rdi
callq 0xf64a0
movl 0x8(%r14), %ecx
leaq 0xca7ac(%rip), %rdx     # 0x119b7a
movq %r15, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0xf6653
movq %rbx, %rdi
callq 0xea504
movq %rax, 0x50(%r14)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xea53f
movq %r15, %rdi
callq 0xf6753
movq 0x18(%rbx), %rdi
movl $0x24, %esi
callq 0xeebc8
movq %rax, 0x10(%r14)
movq 0x18(%rbx), %rdi
movl $0x26, %esi
callq 0xeebc8
movq %rax, 0x18(%r14)
movl 0x10(%r14), %edx
leaq 0xcfc67(%rip), %rsi     # 0x11f097
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
movq (%r14), %rcx
incq %rax
movq %rax, 0x18(%rcx)
movq 0x18(%rbx), %rdi
movl $0x32, %esi
callq 0xeebc8
movq %rax, %r15
movq 0x18(%rbx), %rdi
movl $0x34, %esi
callq 0xeebc8
movq %rax, 0x20(%r14)
leaq 0xcfc3d(%rip), %rsi     # 0x11f0b5
movq %rbx, %rdi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x36, %esi
callq 0xeebc8
leaq 0xcfc45(%rip), %rsi     # 0x11f0e1
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x38, %esi
callq 0xeebc8
leaq 0xcfc34(%rip), %rsi     # 0x11f0f1
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x3e, %esi
callq 0xeebc8
leaq 0xcfc24(%rip), %rsi     # 0x11f102
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x42, %esi
callq 0xeebc8
movq %rax, %r15
leaq 0xd9e2b(%rip), %rsi     # 0x12932d
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
shrb $0x2, %r15b
andb $0x1, %r15b
movb %r15b, 0x48(%r14)
movzbl %r15b, %edx
leaq 0xcfbe7(%rip), %rsi     # 0x11f11a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0x18(%rbx), %rdi
movl $0x44, %esi
callq 0xeed61
leaq 0xcfbce(%rip), %rsi     # 0x11f12d
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x48, %esi
callq 0xeed61
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
movl $0x4c, %esi
callq 0xeed61
movq %rax, 0x30(%r14)
movl 0x28(%r14), %edx
leaq 0xcfbb2(%rip), %rsi     # 0x11f14c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl 0x30(%r14), %edx
leaq 0xcfbbb(%rip), %rsi     # 0x11f16a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x50, %esi
callq 0xeebc8
movq %rax, 0x38(%r14)
movq 0x18(%rbx), %rdi
movl $0x52, %esi
callq 0xeebc8
movq %rax, 0x40(%r14)
movl 0x38(%r14), %edx
leaq 0xcfb97(%rip), %rsi     # 0x11f17f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl 0x40(%r14), %edx
leaq 0xcfb97(%rip), %rsi     # 0x11f194
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
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 0x4f86f
movq 0x18(%rax), %rsi
testq %rsi, %rsi
jle 0x4f86f
movl $0x28, %edx
movq %rbx, %rdi
callq 0xe96f7
movq (%r14), %rcx
movq %rax, 0x20(%rcx)
leaq 0xcfb4d(%rip), %rsi     # 0x11f1ab
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x40(%r14), %r12
imulq 0x38(%r14), %r12
movq 0x30(%r14), %rax
addq %r12, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x4f69e
leaq 0xcfb25(%rip), %rsi     # 0x11f1be
jmp 0x4f84d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8b2b
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq 0x30(%r14), %rdx
movq %rax, %rsi
movq %r12, %rcx
callq 0xee8d4
cmpb $0x0, 0x48(%r14)
je 0x4f6ec
testb $0x1, 0x38(%r14)
jne 0x4f846
cmpq $0x2, %r12
jl 0x4f6ec
movl $0x1, %eax
rolw $0x8, -0x1(%r15,%rax)
addq $0x2, %rax
cmpq %r12, %rax
jl 0x4f6dc
movq %r15, 0x8(%rsp)
movq (%r14), %rax
cmpq $0x0, 0x18(%rax)
jle 0x4f819
xorl %r13d, %r13d
movq %rbx, 0x10(%rsp)
movq 0x20(%rax), %r12
leaq (,%r13,4), %r15
addq %r13, %r15
movq 0x18(%rbx), %rdi
leaq (,%r13,2), %rsi
addq 0x28(%r14), %rsi
callq 0xeebc8
movq %rax, %rbp
movq 0x18(%rbx), %rdi
leaq 0x2(,%r13,2), %rsi
addq 0x28(%r14), %rsi
callq 0xeebc8
subl %ebp, %eax
movl %eax, 0x8(%r12,%r15,8)
movq (%r14), %rcx
movl 0x4(%rcx), %ecx
movl %ecx, 0xc(%r12,%r15,8)
movl 0x10(%r14), %ecx
addl %r13d, %ecx
movl %ecx, (%r12,%r15,8)
movq %rbx, %rdi
leaq 0xcfa85(%rip), %rsi     # 0x11f1ef
movl %r13d, %edx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0xe87e4
movslq 0x8(%r12,%r15,8), %rax
testq %rax, %rax
jle 0x4f809
cmpl $0x200, %eax            # imm = 0x200
ja 0x4f809
cmpq %rax, 0x20(%r14)
jl 0x4f809
leaq (%r12,%r15,8), %r15
addl $0x7, %eax
shrl $0x3, %eax
movq %rax, 0x18(%r15)
movslq 0xc(%r15), %rsi
imulq %rax, %rsi
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, 0x20(%r15)
cmpl $0x0, 0xc(%r15)
movq 0x8(%rsp), %rbx
jle 0x4f7f7
xorl %r12d, %r12d
movq 0x38(%r14), %rdi
imulq %r12, %rdi
addq %rbx, %rdi
movq 0x18(%r15), %rdx
imulq %r12, %rdx
addq 0x20(%r15), %rdx
movslq 0x8(%r15), %r8
movq %rbp, %rsi
xorl %ecx, %ecx
callq 0xeb23b
incq %r12
movslq 0xc(%r15), %rax
cmpq %rax, %r12
jl 0x4f7c6
movl 0x8(%r15), %eax
movq (%r14), %rcx
cmpl (%rcx), %eax
movq 0x10(%rsp), %rbx
jle 0x4f809
movl %eax, (%rcx)
incq %r13
movq (%r14), %rax
cmpq 0x18(%rax), %r13
jl 0x4f707
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xe8be2
movq (%r14), %rsi
movq 0x50(%r14), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0xf576f
jmp 0x4f86f
leaq 0xcf993(%rip), %rsi     # 0x11f1e0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq (%r14), %rsi
testq %rsi, %rsi
je 0x4f8d6
movq 0x20(%rsi), %rax
testq %rax, %rax
je 0x4f8ce
cmpq $0x0, 0x18(%rsi)
jle 0x4f8c0
movl $0x20, %r15d
xorl %r12d, %r12d
movq 0x20(%rsi), %rax
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0xe8be2
incq %r12
movq (%r14), %rsi
addq $0x28, %r15
cmpq 0x18(%rsi), %r12
jl 0x4f89c
movq 0x20(%rsi), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0xe8be2
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xf536d
movq 0x50(%r14), %rsi
movq %rbx, %rdi
callq 0xea50e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq