// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r15
leaq 0x17ee(%rip), %rsi      # 0x31fe
movl $0x7, %edx
movq %r13, %rdi
callq 0x1060
testl %eax, %eax
je 0x1a54
movslq 0x436e8(%rip), %rax     # 0x45110
leal 0x1(%rax), %ecx
movl %ecx, 0x436df(%rip)     # 0x45110
leaq (%rbx,%rax,8), %rdx
addq $0x18, %rdx
leaq 0x16bf(%rip), %rsi      # 0x30ff
movq %r13, %rdi
xorl %eax, %eax
callq 0x1110
movl $0x2, %ebp
jmp 0x1b5c
movl $0x0, 0x436b2(%rip)     # 0x45110
movq %r12, %rdi
movq %rbx, %rsi
callq 0x14bb
movl 0x14(%rbx), %eax
movl $0x1, %ebp
cmpq $0xffff, %rax           # imm = 0xFFFF
ja 0x1b5c
leaq 0x368c(%rip), %rcx      # 0x5110
movl (%rcx,%rax,4), %edx
movl 0x10(%rbx), %esi
movzbl %sil, %eax
cmpl $0x10000, %edx          # imm = 0x10000
setb %cl
cmpl $0x41, %eax
setb %al
andb %cl, %al
cmpb $0x1, %al
jne 0x1b4d
movl %edx, 0x14(%rsp)
movl 0x14(%r12), %r13d
addl 0x10(%r12), %r13d
movl $0x1, %edi
movl %esi, 0x8(%rsp)
movl $0x18, %esi
callq 0x1418
movq %rax, 0x20(%rsp)
movl $0x1, %edi
movl $0x10, %esi
callq 0x1418
movq %rax, %r12
movl 0x8(%rsp), %eax
movb %al, (%r12)
movb %r13b, 0x1(%r12)
movzbl %r13b, %edi
movq %rdi, 0x18(%rsp)
movl $0x8, %esi
callq 0x1418
movq %r12, 0x8(%rsp)
movq %rax, 0x8(%r12)
cmpb $0x0, 0x18(%rsp)
je 0x1b23
leaq 0x18(%rbx), %rsi
movzbl %r13b, %edx
shll $0x3, %edx
movq %rax, %rdi
callq 0x10f0
movl 0x14(%rsp), %ecx
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x8(%rsp), %rsi
movq %rsi, 0x8(%rdx)
movq (%r15), %rax
movq %rax, 0x10(%rdx)
movq %rdx, (%r15)
cmpl $0x20, %ecx
jne 0x1b4d
movups (%rsi), %xmm0
movups %xmm0, (%r14)
movl $0x218, %edx            # imm = 0x218
movq %rbx, %rdi
xorl %esi, %esi
callq 0x10b0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq