// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x157b(%rip), %rsi      # 0x31d2
callq 0x14d0
cmpl $0x0, %eax
je 0x1de5
movl $0x0, 0x434b1(%rip)     # 0x45120
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1540
movq -0x30(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jl 0x1c93
movq -0x30(%rbp), %rax
cmpl $0x10000, 0x14(%rax)    # imm = 0x10000
jl 0x1c9f
movl $0x1, -0x4(%rbp)
jmp 0x1e20
movq -0x30(%rbp), %rax
movslq 0x14(%rax), %rcx
leaq 0x3472(%rip), %rax      # 0x5120
movl (%rax,%rcx,4), %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
movb %al, -0x35(%rbp)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0x14(%rcx), %eax
movb %al, -0x36(%rbp)
cmpl $0x10000, -0x34(%rbp)   # imm = 0x10000
jae 0x1dcc
movzbl -0x35(%rbp), %eax
cmpl $0x40, %eax
jg 0x1dcc
movl $0x1, %edi
movl $0x18, %esi
callq 0x1440
movq %rax, -0x40(%rbp)
movl $0x1, %edi
movl $0x10, %esi
callq 0x1440
movq %rax, -0x48(%rbp)
movb -0x35(%rbp), %cl
movq -0x48(%rbp), %rax
movb %cl, (%rax)
movb -0x36(%rbp), %cl
movq -0x48(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x48(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x1440
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d7f
movq -0x30(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1d48
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
cmpl $0x20, -0x34(%rbp)
jne 0x1dca
movq -0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x1dcc
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x218, %edx            # imm = 0x218
callq 0x10b0
movl $0x1, -0x4(%rbp)
jmp 0x1e20
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x18, %rdx
movl 0x43329(%rip), %eax     # 0x45120
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x4331e(%rip)     # 0x45120
cltq
shlq $0x3, %rax
addq %rax, %rdx
leaq 0x12c1(%rip), %rsi      # 0x30d3
movb $0x0, %al
callq 0x1100
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)