// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/psf.c
// Function: de_run_psf
static void de_run_psf(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	u8 b;
	const char *s;

	d = de_malloc(c, sizeof(lctx));

	s = de_get_ext_option(c, "font:noaliases");
	if(s)
		d->read_extra_codepoints = 0;
	else
		d->read_extra_codepoints = 1;

	b = de_getbyte(0);
	if(b==0x36) {
		d->version=1;
	}
	else if(b==0x72) {
		d->version=2;
	}
	else {
		de_err(c, "Not a PSF file");
		goto done;
	}

	de_dbg(c, "PSF version: %d", (int)d->version);

	if(d->version==2)
		do_psf2_header(c, d);
	else
		do_psf1_header(c, d);

	d->font_data_size = d->bytes_per_glyph * d->num_glyphs;
	if(d->has_unicode_table) {
		d->unicode_table_pos = d->headersize + d->font_data_size;
		if(d->unicode_table_pos >= c->infile->len) {
			d->has_unicode_table = 0;
		}
	}

	if((d->headersize+d->font_data_size > c->infile->len) ||
		d->bytes_per_glyph<1 ||
		d->glyph_width<1 || d->glyph_width>256 ||
		d->glyph_height<1 || d->glyph_height>256 ||
		d->num_glyphs<1 || d->num_glyphs>2000000)
	{
		de_err(c, "Invalid or unsupported PSF file");
		goto done;
	}

	do_glyphs(c, d);

done:
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
pushq $0x70
popq %rsi
callq 0xdecaf
movq %rax, %r14
leaq 0x7572a(%rip), %rsi     # 0x12c323
movq %rbx, %rdi
callq 0xdfa87
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
movl %ecx, 0x50(%r14)
movq 0x18(%rbx), %rdi
xorl %esi, %esi
callq 0xe3eb4
cmpb $0x36, %al
je 0xb6c2c
movzbl %al, %eax
cmpl $0x72, %eax
jne 0xb6edf
pushq $0x2
jmp 0xb6c2e
pushq $0x1
popq %rdx
movl %edx, (%r14)
leaq 0x75708(%rip), %rsi     # 0x12c341
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpl $0x2, (%r14)
jne 0xb6dac
leaq 0x7571d(%rip), %rsi     # 0x12c371
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
pushq $0x4
popq %rsi
callq 0xe409f
movl %eax, 0x4(%r14)
leaq 0x7570a(%rip), %rsi     # 0x12c38c
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movl 0x4(%r14), %edx
testl %edx, %edx
je 0xb6ca7
leaq 0x756e7(%rip), %rsi     # 0x12c384
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
movq 0x18(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0xe409f
movq %rax, 0x10(%r14)
leaq 0x63a68(%rip), %rsi     # 0x11a726
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0xc
popq %rsi
callq 0xe409f
movl %eax, 0x8(%r14)
leaq 0x6294d(%rip), %rsi     # 0x11962e
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movl 0x8(%r14), %eax
andl $0x1, %eax
movl %eax, 0x40(%r14)
leaq 0x6430c(%rip), %rax     # 0x11b016
leaq 0x73127(%rip), %rdx     # 0x129e38
cmoveq %rax, %rdx
leaq 0x75689(%rip), %rsi     # 0x12c3a5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
pushq $0x10
popq %rsi
callq 0xe409f
movq %rax, 0x18(%r14)
leaq 0x5c4f4(%rip), %rsi     # 0x11323c
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0x14
popq %rsi
callq 0xe409f
movq %rax, 0x30(%r14)
leaq 0x75650(%rip), %rsi     # 0x12c3bb
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
pushq $0x18
popq %rsi
callq 0xe409f
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rdi
pushq $0x1c
popq %rsi
callq 0xe409f
movq %rax, 0x20(%r14)
movl 0x28(%r14), %ecx
leaq 0x7562d(%rip), %rsi     # 0x12c3cf
movq %rbx, %rdi
movl %eax, %edx
jmp 0xb6e94
leaq 0x75635(%rip), %rsi     # 0x12c3e8
movq %rbx, %rdi
xorl %edx, %edx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0xdeba7
movq $0x4, 0x10(%r14)
movq 0x18(%rbx), %rdi
pushq $0x2
popq %rsi
callq 0xe3eb4
movb %al, 0xc(%r14)
movzbl %al, %edx
leaq 0x87a67(%rip), %rsi     # 0x13e855
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movl %ebp, %esi
callq 0xdeba7
movzbl 0xc(%r14), %edx
andl $0x1, %edx
shll $0x8, %edx
addl $0x100, %edx            # imm = 0x100
movq %rdx, 0x18(%r14)
leaq 0x5c41e(%rip), %rsi     # 0x11323c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movzbl 0xc(%r14), %eax
andl $0x2, %eax
movl %eax, %ecx
shrl %ecx
testl %eax, %eax
movl %ecx, 0x40(%r14)
leaq 0x641d5(%rip), %rax     # 0x11b016
leaq 0x72ff0(%rip), %rdx     # 0x129e38
cmoveq %rax, %rdx
leaq 0x75552(%rip), %rsi     # 0x12c3a5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
pushq $0x3
popq %rsi
callq 0xe3eb4
movzbl %al, %ecx
movq %rcx, 0x30(%r14)
movq %rcx, 0x28(%r14)
movq $0x8, 0x20(%r14)
leaq 0x75541(%rip), %rsi     # 0x12c3cf
pushq $0x8
popq %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x30(%r14), %rcx
movq 0x10(%r14), %rdx
movq 0x18(%r14), %rax
movq %rax, %rdi
imulq %rcx, %rdi
movq %rdi, 0x38(%r14)
cmpl $0x0, 0x40(%r14)
je 0xb6ee8
addq %rdi, %rdx
movq %rdx, 0x48(%r14)
movq 0x18(%rbx), %rsi
movq 0x18(%rsi), %rsi
cmpq %rsi, %rdx
jl 0xb6ef3
andl $0x0, 0x40(%r14)
jmp 0xb6ef3
leaq 0x7544c(%rip), %rsi     # 0x12c332
jmp 0xb6f44
movq 0x18(%rbx), %rsi
movq 0x18(%rsi), %rsi
addq %rdi, %rdx
cmpq %rsi, %rdx
setg %dl
testq %rcx, %rcx
setle %cl
orb %dl, %cl
jne 0xb6f3d
movq $-0x101, %rcx           # imm = 0xFEFF
movq 0x20(%r14), %rdx
addq %rcx, %rdx
cmpq $-0x100, %rdx
jb 0xb6f3d
addq 0x28(%r14), %rcx
cmpq $-0x100, %rcx
setb %cl
addq $-0x1e8481, %rax        # imm = 0xFFE17B7F
cmpq $-0x1e8480, %rax        # imm = 0xFFE17B80
setb %al
orb %cl, %al
cmpb $0x1, %al
jne 0xb6f6b
leaq 0x7540d(%rip), %rsi     # 0x12c351
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0xe9d18
movq %rax, %r15
movb $0x1, 0x10(%rax)
movq 0x20(%r14), %rax
movl %eax, (%r15)
movl 0x28(%r14), %ecx
movl %ecx, 0x4(%r15)
movq 0x18(%r14), %rcx
movq %rcx, 0x18(%r15)
addq $0x7, %rax
pushq $0x8
popq %rsi
cqto
idivq %rsi
movq %rax, %r12
movq %rcx, 0x58(%r14)
cmpl $0x0, 0x50(%r14)
movq %rcx, %rsi
je 0xb6fb9
leaq 0x7d0(%rcx), %rsi
movq %rsi, 0x58(%r14)
movq %rcx, 0x60(%r14)
andq $0x0, 0x68(%r14)
pushq $0x28
popq %rdx
movq %rbx, %rdi
callq 0xdf66f
movq %rax, 0x20(%r15)
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %rbp
movq 0x10(%r14), %rdx
movq 0x38(%r14), %rcx
leaq 0x7540c(%rip), %rsi     # 0x12c3fb
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq 0x10(%r14), %rdx
movq 0x38(%r14), %rcx
movq %rbp, %rsi
callq 0xe3cb7
movq 0x58(%r14), %rax
testq %rax, %rax
cmovleq %r13, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xb7066
movq (%r15), %rsi
movq 0x20(%r15), %rdx
movq %rsi, 0x8(%rdx,%r13)
movq %r12, 0x18(%rdx,%r13)
movl $0xfffffff, %esi        # imm = 0xFFFFFFF
cmpq 0x18(%r14), %rcx
jge 0xb7050
movq 0x30(%r14), %rsi
imulq %rcx, %rsi
addq %rbp, %rsi
movq %rsi, 0x20(%rdx,%r13)
movl %ecx, %esi
movl %esi, (%rdx,%r13)
movl $0xfffffff, 0x4(%rdx,%r13) # imm = 0xFFFFFFF
incq %rcx
addq $0x28, %r13
jmp 0xb701d
cmpl $0x0, 0x40(%r14)
movq %rbp, 0x30(%rsp)
je 0xb730a
cmpl $0x2, (%r14)
jne 0xb71d2
movl 0x48(%r14), %edx
leaq 0x753b6(%rip), %rsi     # 0x12c441
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x48(%r14), %r13
xorl %r12d, %r12d
movq %r14, 0x18(%rsp)
cmpq 0x18(%r14), %r12
jge 0xb72f8
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rcx
subq %r13, %rcx
jle 0xb72f8
movl $0xff, %esi
movq %r13, %rdx
leaq 0x20(%rsp), %r8
callq 0xe4b21
testl %eax, %eax
je 0xb72f8
movq %r15, %r14
movq 0x20(%rsp), %rbp
subq %r13, %rbp
movl $0xc8, %ecx
cmpq %rcx, %rbp
cmovgeq %rcx, %rbp
testq %rbp, %rbp
movl $0x0, %ecx
cmovleq %rcx, %rbp
movq 0x18(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xe3cb7
imulq $0x28, %r12, %rax
movq %rax, 0x8(%rsp)
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbp, %rsi
subq %r15, %rsi
jle 0xb71a1
cmpq $0x7d0, %r13            # imm = 0x7D0
ja 0xb71a1
leaq (%rsp,%r15), %rdi
addq $0x40, %rdi
leaq 0x14(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq 0xe17cb
testl %eax, %eax
je 0xb71a1
movl 0x14(%rsp), %r8d
movq %rbx, %rdi
testq %r13, %r13
je 0xb7172
movq 0x18(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xb73d8
jmp 0xb7197
leaq 0x752dc(%rip), %rsi     # 0x12c455
movl %r12d, %edx
movl %r8d, %ecx
xorl %eax, %eax
callq 0xde9f1
movl 0x14(%rsp), %eax
movq 0x20(%r14), %rcx
movq 0x8(%rsp), %rdx
movl %eax, 0x4(%rcx,%rdx)
incq %r13
addq 0x38(%rsp), %r15
jmp 0xb7127
testq %r13, %r13
jne 0xb71ba
movq %rbx, %rdi
leaq 0x752b7(%rip), %rsi     # 0x12c467
movl %r12d, %edx
xorl %eax, %eax
callq 0xdf05a
movq 0x20(%rsp), %r13
incq %r13
incq %r12
movq %r14, %r15
movq 0x18(%rsp), %r14
jmp 0xb70ac
movq %r15, 0x8(%rsp)
movl 0x48(%r14), %edx
leaq 0x7525f(%rip), %rsi     # 0x12c441
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x48(%r14), %r12
xorl %r8d, %r8d
movb $0x1, %al
movl %eax, 0x4(%rsp)
imulq $0x28, %r8, %rax
movq %rax, 0x28(%rsp)
xorl %r15d, %r15d
cmpq 0x18(%r14), %r8
jge 0xb72f3
leaq 0x1(%r12), %rax
movq 0x18(%rbx), %rdi
cmpq 0x18(%rdi), %rax
jge 0xb72f3
movq %r8, %r13
movq %r12, %rsi
callq 0xe3fa3
movq %rax, %rbp
addq $0x2, %r12
cmpl $0xfffe, %ebp           # imm = 0xFFFE
je 0xb7254
cmpl $0xffff, %ebp           # imm = 0xFFFF
pushq $0x1
popq %rax
jne 0xb725a
jmp 0xb72ca
pushq $0x1
popq %rax
movl %eax, %r15d
testl %r15d, %r15d
movl %eax, %r15d
movq %r13, %r8
jne 0xb7210
testb $0x1, 0x4(%rsp)
je 0xb72a4
movl $0x0, 0x4(%rsp)
movq %rbx, %rdi
leaq 0x751d7(%rip), %rsi     # 0x12c455
movl %r8d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xde9f1
movq %r13, %r8
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x28(%rsp), %rcx
movl %ebp, 0x4(%rax,%rcx)
jmp 0xb720d
movq %rbx, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
movq %r8, %rcx
movl %ebp, %r8d
callq 0xb73d8
movq %r13, %r8
movl $0x0, 0x4(%rsp)
jmp 0xb720d
testb $0x1, 0x4(%rsp)
movq %r13, %r8
je 0xb72eb
movq %rbx, %rdi
leaq 0x75189(%rip), %rsi     # 0x12c467
movl %r8d, %edx
xorl %eax, %eax
callq 0xdf05a
movq %r13, %r8
incq %r8
jmp 0xb71fe
movq 0x8(%rsp), %r15
movw $0x101, 0x11(%r15)      # imm = 0x101
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x68(%r14), %rdx
testq %rdx, %rdx
jle 0xb7344
movq 0x60(%r14), %rax
addq %rdx, %rax
movq %rax, 0x18(%r15)
leaq 0x750f0(%rip), %rsi     # 0x12c415
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movl 0x18(%r15), %edx
leaq 0x750f2(%rip), %rsi     # 0x12c42c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xea0f6
movq 0x20(%r15), %rsi
movq %rbx, %rdi
callq 0xded32
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9d28
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xded32
jmp 0xb6f4e