// File: /workspace/github_c_makefile_star2_O1/uobikiemukot[P]yaft/tools/bdf.h
// Function: read_header
int read_header(char *buf, struct bdf_header_t *bdf_header)
{
	char *cp;

	if (pre_match(buf, "FONTBOUNDINGBOX "))
		sscanf(buf + strlen("FONTBOUNDINGBOX "), "%d %d %d %d",
			&bdf_header->bbw, &bdf_header->bbh, &bdf_header->bbx, &bdf_header->bby);
	else if (pre_match(buf, "FONT_ASCENT "))
		bdf_header->ascent = atoi(buf + strlen("FONT_ASCENT "));
	else if (pre_match(buf, "FONT_DESCENT "))
		bdf_header->descent = atoi(buf + strlen("FONT_DESCENT "));
	else if (pre_match(buf, "DEFAULT_CHAR "))
		bdf_header->default_char = atoi(buf + strlen("DEFAULT_CHAR "));
	else if (pre_match(buf, "PIXEL_SIZE "))
		bdf_header->pixel_size = atoi(buf + strlen("PIXEL_SIZE "));
	else if (pre_match(buf, "CHARSET_REGISTRY ")) {
		strncpy(bdf_header->charset, buf + strlen("CHARSET_REGISTRY "), BUFSIZE - 1);
		logging(DEBUG, "%s\n", bdf_header->charset);

		for (cp = bdf_header->charset; *cp != '\0'; cp++)
			*cp = (char) toupper((int) *cp);

		if (strstr(bdf_header->charset, "X68000") != NULL
			|| strstr(bdf_header->charset, "x68000") != NULL)
			load_table("./table/X68000", X68000);
		else if (strstr(bdf_header->charset, "JISX0201") != NULL
			|| strstr(bdf_header->charset, "jisx0201") != NULL)
			load_table("./table/JISX0201", JISX0201);
		else if (strstr(bdf_header->charset, "JISX0208") != NULL
			|| strstr(bdf_header->charset, "jisx0208") != NULL)
			load_table("./table/JISX0208", JISX0208);
		else if (strstr(bdf_header->charset, "ISO8859") != NULL
			|| strstr(bdf_header->charset, "iso8859") != NULL)
			load_table("./table/ISO8859", ISO8859);
		else /* assume "ISO10646" */
			load_table("./table/ISO10646", ISO10646);
	}
	else if (pre_match(buf, "CHARS ")) {
		bdf_header->chars =  atoi(buf + strlen("CHARS "));
		return BDF_CHAR;
	}

	return BDF_HEADER;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1a12(%rip), %rsi      # 0x30d6
movl $0x10, %edx
callq 0x1060
testl %eax, %eax
je 0x173e
leaq 0x1a1a(%rip), %rsi      # 0x30f3
movl $0xc, %edx
movq %r14, %rdi
callq 0x1060
testl %eax, %eax
je 0x1766
leaq 0x1a0f(%rip), %rsi      # 0x3100
movl $0xd, %edx
movq %r14, %rdi
callq 0x1060
testl %eax, %eax
je 0x1777
leaq 0x1a05(%rip), %rsi      # 0x310e
movl $0xd, %edx
movq %r14, %rdi
callq 0x1060
testl %eax, %eax
je 0x1788
leaq 0x19fb(%rip), %rsi      # 0x311c
movq %r14, %rdi
callq 0x147b
testl %eax, %eax
je 0x17a6
addq $0xb, %r14
movq %r14, %rdi
callq 0x1160
movl %eax, 0x20(%rbx)
jmp 0x1797
addq $0x10, %r14
leaq 0x4(%rbx), %rcx
leaq 0x8(%rbx), %r8
leaq 0xc(%rbx), %r9
leaq 0x1992(%rip), %rsi      # 0x30e7
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
jmp 0x1799
addq $0xc, %r14
movq %r14, %rdi
callq 0x1160
movl %eax, 0x10(%rbx)
jmp 0x1797
addq $0xd, %r14
movq %r14, %rdi
callq 0x1160
movl %eax, 0x14(%rbx)
jmp 0x1797
addq $0xd, %r14
movq %r14, %rdi
callq 0x1160
movl %eax, 0x18(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x197b(%rip), %rsi      # 0x3128
movq %r14, %rdi
callq 0x147b
testl %eax, %eax
je 0x182d
leaq 0x24(%rbx), %r15
addq $0x11, %r14
movl $0x3ff, %edx            # imm = 0x3FF
movq %r15, %rdi
movq %r14, %rsi
callq 0x1050
movb 0x24(%rbx), %al
testb %al, %al
je 0x17f0
addq $0x25, %rbx
movsbl %al, %edi
callq 0x1070
movb %al, -0x1(%rbx)
movb (%rbx), %al
incq %rbx
testb %al, %al
jne 0x17dc
leaq 0x1952(%rip), %rsi      # 0x3149
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
jne 0x1818
leaq 0x192f(%rip), %rsi      # 0x313a
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
je 0x185d
leaq 0x1922(%rip), %rdi      # 0x3141
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x15cb
jmp 0x1799
leaq 0x1979(%rip), %rsi      # 0x31ad
movq %r14, %rdi
callq 0x147b
testl %eax, %eax
je 0x1797
addq $0x6, %r14
movq %r14, %rdi
callq 0x1160
movl %eax, 0x1c(%rbx)
movl $0x1, %ebp
jmp 0x1799
leaq 0x18fd(%rip), %rsi      # 0x3161
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
jne 0x1885
leaq 0x18d8(%rip), %rsi      # 0x3150
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
je 0x189b
leaq 0x18cd(%rip), %rdi      # 0x3159
movl $0x2, %esi
callq 0x15cb
jmp 0x1797
leaq 0x18d9(%rip), %rsi      # 0x317b
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
jne 0x18c3
leaq 0x18b4(%rip), %rsi      # 0x316a
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
je 0x18d1
leaq 0x18a9(%rip), %rdi      # 0x3173
movl $0x1, %esi
jmp 0x1891
leaq 0x18bc(%rip), %rsi      # 0x3194
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
jne 0x18f9
leaq 0x1898(%rip), %rsi      # 0x3184
movq %r15, %rdi
callq 0x1190
testq %rax, %rax
je 0x1907
leaq 0x188c(%rip), %rdi      # 0x318c
movl $0x3, %esi
jmp 0x1891
leaq 0x188e(%rip), %rdi      # 0x319c
movl $0x4, %esi
jmp 0x1891