// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/tools/bdf.h
// Function: read_bitmap
int read_bitmap(struct glyph_list_t **glist_head, struct glyph_t *default_glyph,
	char *buf, struct bdf_header_t *bdf_header, struct bdf_char_t *bdf_char)
{
	static int count = 0;
	uint32_t code;
	uint8_t width, height;
	struct glyph_list_t *listp;
	struct glyph_t *glyph;

	if (pre_match(buf, "ENDCHAR")) {
		count = 0;

		shift_glyph(bdf_header, bdf_char);

		if (bdf_char->encoding < 0 || bdf_char->encoding >= UCS2_CHARS)
			return BDF_CHAR;

		code   = convert_table[bdf_char->encoding];
		width  = bdf_char->dwidth;
		height = bdf_header->ascent + bdf_header->descent;

		//logging(DEBUG, "code:%d width:%d height:%d\n", code, width, height);

		if (code < UCS2_CHARS && width <= 64) {
			listp = ecalloc(1, sizeof(struct glyph_list_t));
			glyph = ecalloc(1, sizeof(struct glyph_t));

			glyph->width  = width;
			glyph->height = height;
			/* XXX: max width 64 pixels (wide char)  */
			glyph->bitmap = (bitmap_width_t *) ecalloc(glyph->height, sizeof(bitmap_width_t));

			for (int i = 0; i < glyph->height; i++)
				glyph->bitmap[i] = bdf_char->bitmap[i];

			/* add new element to glyph list */
			listp->code  = code;
			listp->glyph = glyph;
			listp->next  = *glist_head;
			*glist_head  = listp;

			if (code == DEFAULT_CHAR)
				*default_glyph = *glyph;
		}
		memset(bdf_char, 0, sizeof(struct bdf_char_t));
		return BDF_CHAR;
	}
	else
		sscanf(buf, "%X", (unsigned int *) &bdf_char->bitmap[count++]);

	return BDF_BITMAP;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
leaq 0x1843(%rip), %rsi      # 0x31d2
movq %rdx, %rdi
callq 0x1460
testl %eax, %eax
je 0x1a55
andl $0x0, 0x4375a(%rip)     # 0x45100
movq %r12, %rdi
movq %rbx, %rsi
callq 0x149b
movl 0x14(%rbx), %eax
pushq $0x1
popq %rbp
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x1ac1
leaq 0x3736(%rip), %rcx      # 0x5100
movl (%rcx,%rax,4), %edx
movl 0x10(%rbx), %r14d
movzbl %r14b, %eax
cmpl $0x10000, %edx          # imm = 0x10000
setb %cl
cmpl $0x41, %eax
setb %al
andb %cl, %al
cmpb $0x1, %al
jne 0x1ab2
movl %edx, 0x4(%rsp)
movq %r13, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movl 0x14(%r12), %r15d
addl 0x10(%r12), %r15d
pushq $0x1
popq %r13
pushq $0x18
popq %rsi
movq %r13, %rdi
callq 0x1404
movq %rax, %r12
pushq $0x10
popq %rsi
movq %r13, %rdi
callq 0x1404
movq %rax, %r13
movb %r14b, (%rax)
movb %r15b, 0x1(%rax)
movzbl %r15b, %r14d
pushq $0x8
popq %rsi
movq %r14, %rdi
callq 0x1404
movq %rax, 0x8(%r13)
xorl %ecx, %ecx
cmpq %r14, %rcx
jae 0x1a83
movq 0x18(%rbx,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x1a42
movslq 0x436a4(%rip), %rax     # 0x45100
leal 0x1(%rax), %ecx
movl %ecx, 0x4369b(%rip)     # 0x45100
leaq (%rbx,%rax,8), %rdx
addq $0x18, %rdx
leaq 0x165f(%rip), %rsi      # 0x30d3
movq %r14, %rdi
xorl %eax, %eax
callq 0x1100
pushq $0x2
popq %rbp
jmp 0x1ac1
movl 0x4(%rsp), %edx
movl %edx, (%r12)
movq %r13, 0x8(%r12)
movq 0x8(%rsp), %rcx
movq (%rcx), %rax
movq %rax, 0x10(%r12)
movq %r12, (%rcx)
cmpl $0x20, %edx
movq 0x10(%rsp), %rax
jne 0x1ab2
movups (%r13), %xmm0
movups %xmm0, (%rax)
movl $0x218, %edx            # imm = 0x218
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10b0
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq