// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pff2.c
// Function: do_char
static void do_char(deark *c, lctx *d, i64 char_idx, i32 codepoint, i64 pos)
{
	struct de_bitmap_font_char *ch;
	i64 bitmap_pos;
	u8 *srcbitmap = NULL;
	i64 srcbitmapsize;
	i64 j;

	ch = &d->font->char_array[char_idx];

	ch->codepoint_unicode = codepoint;

	ch->width = (int)de_getu16be(pos);
	ch->height = (int)de_getu16be(pos+2);
	if(ch->width > d->font->nominal_width) d->font->nominal_width = ch->width;
	if(ch->height > d->font->nominal_height) d->font->nominal_height = ch->height;

	bitmap_pos = pos+10;
	de_dbg2(c, "%d"DE_CHAR_TIMES"%d, bitmap at %d", (int)ch->width, (int)ch->height, (int)bitmap_pos);
	ch->rowspan = (ch->width +7)/8;

	srcbitmapsize = (ch->width * ch->height + 7)/8;
	srcbitmap = de_malloc(c, srcbitmapsize);
	de_read(srcbitmap, bitmap_pos, srcbitmapsize);

	ch->bitmap = de_malloc(c, ch->rowspan * ch->height);
	for(j=0; j<ch->height; j++) {
		// The source bitmap's rows are not byte aligned (except the first row).
		de_copy_bits(srcbitmap, j*ch->width, ch->bitmap, j*ch->rowspan*8, ch->width);
	}

	de_free(c, srcbitmap);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x1651d0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x2, %rsi
callq 0x1651d0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jle 0x10648e
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jle 0x1064b2
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
addq $0xa, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x30(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x38(%rbp), %rax
movl %eax, %r8d
leaq 0xbbcc2(%rip), %rsi     # 0x1c21a0
movb $0x0, %al
callq 0x15b350
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x30(%rbp), %rcx
imull 0xc(%rcx), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
cltq
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x15b780
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rcx
callq 0x164d10
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
movslq 0xc(%rax), %rax
imulq %rax, %rsi
callq 0x15b780
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq 0xc(%rcx), %rcx
cmpq %rcx, %rax
jge 0x1065d5
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rax
imulq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdx
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
imulq 0x18(%rax), %rcx
shlq $0x3, %rcx
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %r8
callq 0x15e500
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x10657c
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x15b820
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)