// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1a39(%rip), %rsi      # 0x30d6
callq 0x1460
testl %eax, %eax
je 0x16d1
addq $0x10, %r14
leaq 0x4(%rbx), %rcx
leaq 0x8(%rbx), %r8
leaq 0xc(%rbx), %r9
leaq 0x1a2a(%rip), %rsi      # 0x30e7
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x1761
leaq 0x1a1b(%rip), %rsi      # 0x30f3
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x16f5
addq $0xc, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x10(%rbx)
jmp 0x175f
leaq 0x1a04(%rip), %rsi      # 0x3100
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x1719
addq $0xd, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x14(%rbx)
jmp 0x175f
leaq 0x19ee(%rip), %rsi      # 0x310e
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x173d
addq $0xd, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x18(%rbx)
jmp 0x175f
leaq 0x19d8(%rip), %rsi      # 0x311c
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x1768
addq $0xb, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x20(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x19b9(%rip), %rsi      # 0x3128
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x17e8
addq $0x24, %rbx
addq $0x11, %r14
movl $0x3ff, %edx            # imm = 0x3FF
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1050
movq %rbx, %r14
movsbl (%r14), %edi
testl %edi, %edi
je 0x17ab
callq 0x1070
movb %al, (%r14)
incq %r14
jmp 0x1796
leaq 0x1997(%rip), %rsi      # 0x3149
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
jne 0x17d3
leaq 0x1974(%rip), %rsi      # 0x313a
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
je 0x1816
leaq 0x1967(%rip), %rdi      # 0x3141
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x15bc
jmp 0x1761
leaq 0x19be(%rip), %rsi      # 0x31ad
movq %r14, %rdi
callq 0x1460
testl %eax, %eax
je 0x175f
addq $0x6, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x1c(%rbx)
pushq $0x1
popq %rbp
jmp 0x1761
leaq 0x1944(%rip), %rsi      # 0x3161
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
jne 0x183e
leaq 0x191f(%rip), %rsi      # 0x3150
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
je 0x1852
leaq 0x1914(%rip), %rdi      # 0x3159
pushq $0x2
popq %rsi
callq 0x15bc
jmp 0x175f
leaq 0x1922(%rip), %rsi      # 0x317b
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
jne 0x187a
leaq 0x18fd(%rip), %rsi      # 0x316a
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
je 0x1885
leaq 0x18f2(%rip), %rdi      # 0x3173
pushq $0x1
jmp 0x1847
leaq 0x1908(%rip), %rsi      # 0x3194
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
jne 0x18ad
leaq 0x18e4(%rip), %rsi      # 0x3184
movq %rbx, %rdi
callq 0x1180
testq %rax, %rax
je 0x18b8
leaq 0x18d8(%rip), %rdi      # 0x318c
pushq $0x3
jmp 0x1847
leaq 0x18dd(%rip), %rdi      # 0x319c
pushq $0x4
jmp 0x1847