// File: /workspace/github_c_makefile_star2_O3/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 0x1f0b
shll $0x4, %edx
cmpb $0x21, %r12b
jb 0x1f09
leaq 0x13a1(%rip), %rsi      # 0x3297
xorl %ebx, %ebx
movl $0x2, %edi
xorl %eax, %eax
callq 0x129c
jmp 0x2051
movl %edx, %eax
movq 0x30c6(%rip), %r14      # 0x4fd8
movq (%r14), %rdi
leaq 0x13aa(%rip), %rsi      # 0x32c6
movl %eax, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rdi
leaq 0x13e0(%rip), %rsi      # 0x3312
movl %r12d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rcx
leaq 0x13f9(%rip), %rdi      # 0x3342
movl $0x29, %esi
movl $0x1, %edx
callq 0x1170
leal -0x1(%r15), %r14d
movl %r15d, %r12d
leaq 0x1109(%rip), %rbx      # 0x306f
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 0x201f
movq %r13, %r14
movq 0x3045(%rip), %r13      # 0x4fd8
movq (%r13), %rdi
leaq 0x13ce(%rip), %rsi      # 0x336c
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x10e0
testl %r15d, %r15d
leaq 0x13cc(%rip), %rcx      # 0x337f
leaq 0x13be(%rip), %r12      # 0x3378
je 0x1ff8
xorl %r15d, %r15d
movq 0x3012(%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 0x1fbf
movq 0x2fd9(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
movl $0x4, %esi
movl $0x1, %edx
leaq 0x136f(%rip), %rdi      # 0x3382
callq 0x1170
movq (%rsp), %r15
movq %r14, %r13
incq %rbp
cmpq $0x10000, %rbp          # imm = 0x10000
jne 0x1f76
movq 0x2fa2(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1347(%rip), %rdi      # 0x3387
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