// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq %rdi, %r13
movq 0x100(%rdi), %rax
movzbl (%rax), %r12d
movzbl 0x1(%rax), %r15d
leal 0x7(%r12), %edx
shrl $0x3, %edx
movl $0x40, %eax
cmpl $0x3, %edx
je 0x1ef3
shll $0x4, %edx
cmpb $0x21, %r12b
jb 0x1ef1
leaq 0x138d(%rip), %rsi      # 0x326b
xorl %ebx, %ebx
movl $0x2, %edi
xorl %eax, %eax
callq 0x129c
jmp 0x2039
movl %edx, %eax
movq 0x30de(%rip), %r14      # 0x4fd8
movq (%r14), %rdi
leaq 0x1396(%rip), %rsi      # 0x329a
movl %eax, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rdi
leaq 0x13cc(%rip), %rsi      # 0x32e6
movl %r12d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rcx
leaq 0x13e5(%rip), %rdi      # 0x3316
movl $0x29, %esi
movl $0x1, %edx
callq 0x1170
leal -0x1(%r15), %r14d
movl %r15d, %r12d
leaq 0x10f5(%rip), %rbx      # 0x3043
xorl %ebp, %ebp
movq %r15, (%rsp)
movq %r12, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movl %ebp, %edi
callq 0x1100
cmpq $0x0, (%r13,%rbp,8)
je 0x2007
movq %r13, %r14
movq 0x305d(%rip), %r13      # 0x4fd8
movq (%r13), %rdi
leaq 0x13ba(%rip), %rsi      # 0x3340
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x10e0
testl %r15d, %r15d
leaq 0x13b8(%rip), %rcx      # 0x3353
leaq 0x13aa(%rip), %r12      # 0x334c
je 0x1fe0
xorl %r15d, %r15d
movq 0x302a(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movq (%r14,%rbp,8), %rax
movq 0x8(%rax), %rax
movl (%rax,%r15,8), %edx
cmpq %r15, 0x8(%rsp)
movq %rcx, %r13
cmoveq %rbx, %rcx
movq %r12, %rsi
xorl %eax, %eax
callq 0x10e0
movq %r13, %rcx
incq %r15
cmpq %r15, 0x10(%rsp)
jne 0x1fa7
movq 0x2ff1(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
movl $0x4, %esi
movl $0x1, %edx
leaq 0x135b(%rip), %rdi      # 0x3356
callq 0x1170
movq (%rsp), %r15
movq %r14, %r13
incq %rbp
cmpq $0x10000, %rbp          # imm = 0x10000
jne 0x1f5e
movq 0x2fba(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1333(%rip), %rdi      # 0x335b
movl $0x3, %esi
movl $0x1, %edx
callq 0x1170
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq