// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/tools/mkfont_bdf.c
// Function: main
int main(int argc, char *argv[])
{
	struct glyph_list_t *glist_head = NULL;
	struct glyph_t *font[UCS2_CHARS], default_glyph, empty_wide, empty_half;

	if (!setlocale(LC_ALL, "")) /* set current locale for wcwidth() */
		logging(WARN, "setlocale() failed\n");

	if (argc < 3) {
		logging(FATAL, "usage: ./mkfont ALIAS BDF1 [BDF2] [BDF3] ...\n");
		return EXIT_FAILURE;
	}

	for (int i = 0; i < UCS2_CHARS; i++)
		font[i] = NULL;

	for (int i = 2; i < argc; i++)
		load_bdf_glyph(&glist_head, &default_glyph, argv[i]);

	if (!map_glyph(font, glist_head, &default_glyph)) {
		logging(FATAL, "map_glyph() failed\n");
		goto err_occurred;
	}

	if (!load_alias(font, argv[1]))
		logging(WARN, "font alias does not work\n");

	if (!check_font(font, &empty_half, &empty_wide)) {
		logging(FATAL, "check_font() failed\n");
		goto err_occurred;
	}

	if (!dump_font(font)) {
		logging(FATAL, "dump_font() failed\n");
		goto err_occurred;
	}

	cleanup(glist_head, &empty_half, &empty_wide);
	return EXIT_SUCCESS;

err_occurred:
	cleanup(glist_head, &empty_half, &empty_wide);
	return EXIT_FAILURE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80060, %rsp          # imm = 0x80060
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl $0x6, %edi
leaq 0xa66(%rip), %rsi       # 0x3043
callq 0x1110
cmpq $0x0, %rax
jne 0x25fb
movl $0x1, %edi
leaq 0xdf5(%rip), %rsi       # 0x33e9
movb $0x0, %al
callq 0x1280
cmpl $0x3, -0x8(%rbp)
jge 0x2620
movl $0x3, %edi
leaq 0xdf0(%rip), %rsi       # 0x33fd
movb $0x0, %al
callq 0x1280
movl $0x1, -0x4(%rbp)
jmp 0x2793
movl $0x0, -0x80054(%rbp)
cmpl $0x10000, -0x80054(%rbp) # imm = 0x10000
jge 0x265a
movslq -0x80054(%rbp), %rax
movq $0x0, -0x80020(%rbp,%rax,8)
movl -0x80054(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80054(%rbp)
jmp 0x262a
movl $0x2, -0x80058(%rbp)
movl -0x80058(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x269f
movq -0x10(%rbp), %rax
movslq -0x80058(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq -0x18(%rbp), %rdi
leaq -0x80030(%rbp), %rsi
callq 0x1e30
movl -0x80058(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80058(%rbp)
jmp 0x2664
leaq -0x80020(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x80030(%rbp), %rdx
callq 0x1f90
testb $0x1, %al
jne 0x26d2
movl $0x3, %edi
leaq 0xd65(%rip), %rsi       # 0x342b
movb $0x0, %al
callq 0x1280
jmp 0x2775
leaq -0x80020(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x20b0
testb $0x1, %al
jne 0x26fd
movl $0x1, %edi
leaq 0xd49(%rip), %rsi       # 0x343f
movb $0x0, %al
callq 0x1280
leaq -0x80020(%rbp), %rdi
leaq -0x80050(%rbp), %rsi
leaq -0x80040(%rbp), %rdx
callq 0x21c0
testb $0x1, %al
jne 0x2730
movl $0x3, %edi
leaq 0xd32(%rip), %rsi       # 0x3459
movb $0x0, %al
callq 0x1280
jmp 0x2775
leaq -0x80020(%rbp), %rdi
callq 0x2350
testb $0x1, %al
jne 0x2755
movl $0x3, %edi
leaq 0xd22(%rip), %rsi       # 0x346e
movb $0x0, %al
callq 0x1280
jmp 0x2775
movq -0x18(%rbp), %rdi
leaq -0x80050(%rbp), %rsi
leaq -0x80040(%rbp), %rdx
callq 0x2530
movl $0x0, -0x4(%rbp)
jmp 0x2793
movq -0x18(%rbp), %rdi
leaq -0x80050(%rbp), %rsi
leaq -0x80040(%rbp), %rdx
callq 0x2530
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80060, %rsp          # imm = 0x80060
popq %rbp
retq