// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/tools/mkfont_bdf.c
// Function: dump_font
bool dump_font(struct glyph_t *font[])
{
	int i, j, width, int_type;
	uint8_t cell_width, cell_height;

	cell_width  = font[DEFAULT_CHAR]->width;
	cell_height = font[DEFAULT_CHAR]->height;

	int_type = my_ceil(cell_width, BITS_PER_BYTE) /* minimum byte for containing half glyph */
		 * 2                                      /* minimum byte for containing wide glyph */
		 * BITS_PER_BYTE;                         /* minimum bits for containing wide glyph */

	/* int_type: 16, 32, 48, 64, 80... */
	if (int_type == 48) { /* uint48_t does not exist */
		int_type = 64;
	} else if (int_type >= 80) {
		logging(ERROR, "BDF width too large (uint%d_t does not exist)\n", int_type);
		return false;
	}

	fprintf(stdout,
		"struct glyph_t {\n"
		"\tuint32_t code;\n"
		"\tuint8_t width;\n"
		"\tuint%d_t bitmap[%d];\n"
		"};\n\n", int_type, cell_height);

	fprintf(stdout, "enum {\n\tCELL_WIDTH = %d,\n\tCELL_HEIGHT = %d\n};\n\n",
		cell_width, cell_height);

	fprintf(stdout, "static const struct glyph_t glyphs[] = {\n");
	for (i = 0; i < UCS2_CHARS; i++) {
		width = wcwidth(i);

		if (font[i] == NULL) /* glyph not found */
			continue;

		fprintf(stdout, "\t{%d, %d, {", i, width);
		for (j = 0; j < cell_height; j++)
			fprintf(stdout, "0x%X%s", (unsigned int) font[i]->bitmap[j], (j == (cell_height - 1)) ? "": ", ");
		fprintf(stdout, "}},\n");
	}
	fprintf(stdout, "};\n");
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movb (%rax), %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movb 0x1(%rax), %al
movb %al, -0x22(%rbp)
movzbl -0x21(%rbp), %edi
movl $0x8, %esi
callq 0x14a0
shll %eax
shll $0x3, %eax
movl %eax, -0x20(%rbp)
cmpl $0x30, -0x20(%rbp)
jne 0x23a2
movl $0x40, -0x20(%rbp)
jmp 0x23c9
cmpl $0x50, -0x20(%rbp)
jl 0x23c7
movl -0x20(%rbp), %edx
movl $0x2, %edi
leaq 0xf3e(%rip), %rsi       # 0x32f5
movb $0x0, %al
callq 0x1280
movb $0x0, -0x1(%rbp)
jmp 0x2523
jmp 0x23c9
movq 0x2c08(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movl -0x20(%rbp), %edx
movzbl -0x22(%rbp), %ecx
leaq 0xf43(%rip), %rsi       # 0x3324
movb $0x0, %al
callq 0x10e0
movq 0x2be9(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movzbl -0x21(%rbp), %edx
movzbl -0x22(%rbp), %ecx
leaq 0xf6f(%rip), %rsi       # 0x3370
movb $0x0, %al
callq 0x10e0
movq 0x2bc9(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0xf87(%rip), %rsi       # 0x33a0
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x14(%rbp)
cmpl $0x10000, -0x14(%rbp)   # imm = 0x10000
jge 0x2507
movl -0x14(%rbp), %edi
callq 0x10f0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x2453
jmp 0x24f9
movq 0x2b7e(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0xf60(%rip), %rsi       # 0x33ca
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movzbl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x24e1
movq 0x2b4e(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %edx
movl -0x18(%rbp), %esi
movzbl -0x22(%rbp), %r8d
subl $0x1, %r8d
leaq 0xf23(%rip), %rcx       # 0x33dd
leaq 0xb82(%rip), %rax       # 0x3043
cmpl %r8d, %esi
cmoveq %rax, %rcx
leaq 0xf07(%rip), %rsi       # 0x33d6
movb $0x0, %al
callq 0x10e0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2478
movq 0x2af0(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0xeee(%rip), %rsi       # 0x33e0
movb $0x0, %al
callq 0x10e0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2427
movq 0x2aca(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
leaq 0xecd(%rip), %rsi       # 0x33e5
movb $0x0, %al
callq 0x10e0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop