// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x100(%rdi), %rax
movzbl (%rax), %r12d
movzbl 0x1(%rax), %r14d
leal 0x7(%r12), %edx
shrl $0x3, %edx
cmpl $0x3, %edx
jne 0x1e15
pushq $0x40
popq %rdx
jmp 0x1e36
shll $0x4, %edx
cmpb $0x21, %r12b
jb 0x1e36
leaq 0x1446(%rip), %rsi      # 0x326b
xorl %ebx, %ebx
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x128c
jmp 0x1f47
movq 0x319b(%rip), %r15      # 0x4fd8
movq (%r15), %rdi
leaq 0x1453(%rip), %rsi      # 0x329a
movl %r14d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r15), %rdi
leaq 0x148b(%rip), %rsi      # 0x32e6
movl %r12d, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r15), %rcx
leaq 0x14a4(%rip), %rdi      # 0x3316
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
leal -0x1(%r14), %r12d
movl %r14d, %r13d
leaq 0x14c1(%rip), %rbp      # 0x334c
xorl %r14d, %r14d
cmpq $0x10000, %r14          # imm = 0x10000
je 0x1f29
movl %r14d, %edi
callq 0x10f0
cmpq $0x0, (%rbx,%r14,8)
je 0x1f21
movq 0x3127(%rip), %rcx      # 0x4fd8
movq (%rcx), %rdi
leaq 0x1485(%rip), %rsi      # 0x3340
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x10e0
xorl %r15d, %r15d
movq 0x3107(%rip), %rax      # 0x4fd8
movq (%rax), %rax
cmpq %r15, %r13
je 0x1f0c
movq (%rbx,%r14,8), %rcx
movq 0x8(%rcx), %rcx
movl (%rcx,%r15,8), %edx
cmpq %r15, %r12
leaq 0x1464(%rip), %rcx      # 0x3353
leaq 0x114d(%rip), %rsi      # 0x3043
cmoveq %rsi, %rcx
movq %rax, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10e0
incq %r15
jmp 0x1eca
leaq 0x1443(%rip), %rdi      # 0x3356
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x1160
incq %r14
jmp 0x1e8e
movq 0x30a8(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1421(%rip), %rdi      # 0x335b
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
movb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq