// File: /workspace/github_c_makefile_star2_O1/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 0xe958c
movl $0x58, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r14
movq %rbx, %rdi
callq 0xf57ec
movq %rax, (%r14)
movb $0x1, 0x10(%rax)
leaq 0xe9f31(%rip), %rsi     # 0x13935e
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xef1ca
leaq 0xcfb1c(%rip), %rsi     # 0x11ef74
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xef1ca
movq %rax, 0x8(%r14)
leaq 0xcfb03(%rip), %rsi     # 0x11ef80
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r15
movq 0x18(%rbx), %rdi
movl $0x4, %esi
movl $0x20, %edx
movq %rax, %rcx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0xf01b0
movq %r15, %rdi
callq 0xf7557
leaq 0xcf9c0(%rip), %rsi     # 0x11ee85
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0xd0(%rbx)
je 0x4f519
movq %r15, %rdi
callq 0xf6900
movl 0x8(%r14), %ecx
leaq 0xca56c(%rip), %rdx     # 0x119a5a
movq %r15, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0xf6ab0
movq %rbx, %rdi
callq 0xea9a9
movq %rax, 0x50(%r14)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xea9e4
movq %r15, %rdi
callq 0xf6bb0
movq 0x18(%rbx), %rdi
movl $0x24, %esi
callq 0xef1ca
movq %rax, 0x10(%r14)
movq 0x18(%rbx), %rdi
movl $0x26, %esi
callq 0xef1ca
movq %rax, 0x18(%r14)
movl 0x10(%r14), %edx
leaq 0xcfa3f(%rip), %rsi     # 0x11ef8f
movq %rbx, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
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 0xef1ca
movq %rax, %r15
movq 0x18(%rbx), %rdi
movl $0x34, %esi
callq 0xef1ca
movq %rax, 0x20(%r14)
leaq 0xcfa15(%rip), %rsi     # 0x11efad
movq %rbx, %rdi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x36, %esi
callq 0xef1ca
leaq 0xcfa1d(%rip), %rsi     # 0x11efd9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x38, %esi
callq 0xef1ca
leaq 0xcfa0c(%rip), %rsi     # 0x11efe9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x3e, %esi
callq 0xef1ca
leaq 0xcf9fc(%rip), %rsi     # 0x11effa
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x42, %esi
callq 0xef1ca
movq %rax, %r15
leaq 0xd9adb(%rip), %rsi     # 0x1290fd
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
shrb $0x2, %r15b
andb $0x1, %r15b
movb %r15b, 0x48(%r14)
movzbl %r15b, %edx
leaq 0xcf9bf(%rip), %rsi     # 0x11f012
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x18(%rbx), %rdi
movl $0x44, %esi
callq 0xef37e
leaq 0xcf9a6(%rip), %rsi     # 0x11f025
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x48, %esi
callq 0xef37e
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
movl $0x4c, %esi
callq 0xef37e
movq %rax, 0x30(%r14)
movl 0x28(%r14), %edx
leaq 0xcf98a(%rip), %rsi     # 0x11f044
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl 0x30(%r14), %edx
leaq 0xcf993(%rip), %rsi     # 0x11f062
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movl $0x50, %esi
callq 0xef1ca
movq %rax, 0x38(%r14)
movq 0x18(%rbx), %rdi
movl $0x52, %esi
callq 0xef1ca
movq %rax, 0x40(%r14)
movl 0x38(%r14), %edx
leaq 0xcf96f(%rip), %rsi     # 0x11f077
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movl 0x40(%r14), %edx
leaq 0xcf96f(%rip), %rsi     # 0x11f08c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
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 0x4f9a4
movq 0x18(%rax), %rsi
testq %rsi, %rsi
jle 0x4f9a4
movl $0x28, %edx
movq %rbx, %rdi
callq 0xea259
movq (%r14), %rcx
movq %rax, 0x20(%rcx)
leaq 0xcf925(%rip), %rsi     # 0x11f0a3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x40(%r14), %r12
imulq 0x38(%r14), %r12
movq 0x30(%r14), %rax
addq %r12, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x4f7c8
leaq 0xcf900(%rip), %rsi     # 0x11f0b6
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x4f98c
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe969b
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq 0x30(%r14), %rdx
movq %rax, %rsi
movq %r12, %rcx
callq 0xeeee8
cmpb $0x0, 0x48(%r14)
je 0x4f832
movq 0x38(%r14), %r15
testb $0x1, %r15b
jne 0x4f817
cmpq $0x2, %r12
jl 0x4f828
movl $0x1, %eax
rolw $0x8, -0x1(%r13,%rax)
addq $0x2, %rax
cmpq %r12, %rax
jl 0x4f805
jmp 0x4f828
leaq 0xcf8ba(%rip), %rsi     # 0x11f0d8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
testb $0x1, %r15b
jne 0x4f98c
movq %r13, 0x8(%rsp)
movq (%r14), %rax
cmpq $0x0, 0x18(%rax)
jle 0x4f95f
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 0xef1ca
movq %rax, %rbp
movq 0x18(%rbx), %rdi
leaq 0x2(,%r13,2), %rsi
addq 0x28(%r14), %rsi
callq 0xef1ca
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 0xcf837(%rip), %rsi     # 0x11f0e7
movl %r13d, %edx
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0xe93cf
movslq 0x8(%r12,%r15,8), %rax
testq %rax, %rax
jle 0x4f94f
cmpl $0x200, %eax            # imm = 0x200
jg 0x4f94f
cmpq %rax, 0x20(%r14)
jl 0x4f94f
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 0xe969b
movq %rax, 0x20(%r15)
cmpl $0x0, 0xc(%r15)
movq 0x8(%rsp), %rbx
jle 0x4f93d
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 0xeb7ec
incq %r12
movslq 0xc(%r15), %rax
cmpq %rax, %r12
jl 0x4f90c
movl 0x8(%r15), %eax
movq (%r14), %rcx
cmpl (%rcx), %eax
movq 0x10(%rsp), %rbx
jle 0x4f94f
movl %eax, (%rcx)
incq %r13
movq (%r14), %rax
cmpq 0x18(%rax), %r13
jl 0x4f84d
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0xe9752
movq (%r14), %rsi
movq 0x50(%r14), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0xf5c29
jmp 0x4f9a4
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq (%r14), %rax
testq %rax, %rax
je 0x4fa09
cmpq $0x0, 0x20(%rax)
je 0x4f9fe
movq (%r14), %rax
cmpq $0x0, 0x18(%rax)
jle 0x4f9f2
movl $0x20, %r15d
xorl %r12d, %r12d
movq 0x20(%rax), %rax
movq (%rax,%r15), %rsi
movq %rbx, %rdi
callq 0xe9752
incq %r12
movq (%r14), %rax
addq $0x28, %r15
cmpq 0x18(%rax), %r12
jl 0x4f9d2
movq 0x20(%rax), %rsi
movq %rbx, %rdi
callq 0xe9752
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xf5801
movq 0x50(%r14), %rsi
movq %rbx, %rdi
callq 0xea9b3
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq