#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
int zhuin_to_inx(char *);
int main() {
  char charbuf[100];
  char zhuinbuf[100];
  FILE *fin;
  FILE *fout;
  int count = 0;
  fin = fopen("zhuin.txt", "r");
  if (!fin)
    return -1;
  fout = fopen("zhuin_data.h", "w");
  if (!fout)
    return -1;
  fprintf(fout, "/* this file is generated from zhuin.txt. */\n");
  fprintf(fout, "static const struct entry default_data[] = {\n");
  while (fscanf(fin, "%s %s", charbuf, zhuinbuf) != EOF) {
    fprintf(fout, "\t{\"%s\", %d},\n", charbuf, zhuin_to_inx(zhuinbuf));
    ++count;
  }
  fprintf(fout, "\t{0, 0}\n");
  fprintf(fout, "};\n\n");
  fprintf(fout, "static const int default_data_len = %d;\n", count);
  fclose(fin);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xe8(%rbp)
cmpq   $0x0,-0xe8(%rbp)
jne    11a0 <main+0x50>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e7 <main+0x197>
lea    0xe65(%rip),%rdi
lea    0xe6b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xf0(%rbp)
cmpq   $0x0,-0xf0(%rbp)
jne    11d4 <main+0x84>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e7 <main+0x197>
mov    -0xf0(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xf0(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xe8(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
lea    0xe60(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2dc5(%rip),%rcx
cmp    (%rcx),%rax
je     1283 <main+0x133>
mov    -0xf0(%rbp),%rax
mov    %rax,-0x108(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x100(%rbp)
lea    -0xe0(%rbp),%rdi
call   1030 <zhuin_to_inx@plt>
mov    -0x108(%rbp),%rdi
mov    -0x100(%rbp),%rdx
mov    %eax,%ecx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11fe <main+0xae>
mov    -0xf0(%rbp),%rdi
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xf0(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xf0(%rbp),%rdi
mov    -0xf4(%rbp),%edx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xe8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xf0(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
lea    0xe88(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     12b3 <main+0x153>
mov    %rax,%r14
lea    0xe70(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12b3 <main+0x153>
mov    %rax,%r12
lea    0xe60(%rip),%rdi
mov    $0x2d,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
lea    0xe75(%rip),%rdi
mov    $0x2d,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xe8a(%rip),%rsi
lea    0x70(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1050 <fscanf@plt>
mov    0x2de4(%rip),%r13
mov    $0x0,%ebp
cmp    0x0(%r13),%rax
je     125c <main+0xfc>
mov    %rsp,%rbx
lea    0x70(%rsp),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <zhuin_to_inx@plt>
mov    %r12,%rdi
lea    0xe4b(%rip),%rsi
mov    %r15,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
add    $0x1,%ebp
mov    %r14,%rdi
lea    0xe2c(%rip),%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1050 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    1220 <main+0xc0>
lea    0xe28(%rip),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xe18(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <fwrite@plt>
lea    0xe04(%rip),%rsi
mov    %r12,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"zhuin.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"zhuin_data.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [46 x i8] c"/* this file is generated from zhuin.txt. */\0A\00"
@.str.5 = [46 x i8] c"static const struct entry default_data[] = {\0A\00"
@.str.6 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.7 = [14 x i8] c"\09{\22%s\22, %d},\0A\00"
@.str.8 = [9 x i8] c"\09{0, 0}\0A\00"
@.str.9 = [5 x i8] c"};\0A\0A\00"
@.str.10 = [41 x i8] c"static const int default_data_len = %d;\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %0
store i32 -1, i32* %1
br label %48
11: ; preds = %0
%12 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %16, label %15
15: ; preds = %11
store i32 -1, i32* %1
br label %48
16: ; preds = %11
%17 = load i32*, i32** %5
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32*, i32** %5
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %28, %16
%22 = load i32*, i32** %4
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i64 @fscanf(i32* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %23, i8* %24)
%26 = load i64, i64* @EOF
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %21
%29 = load i32*, i32** %5
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%32 = call i32 @zhuin_to_inx(i8* %31)
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %30, i32 %32)
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %21
36: ; preds = %21
%37 = load i32*, i32** %5
%38 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%39 = load i32*, i32** %5
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%41 = load i32*, i32** %5
%42 = load i32, i32* %6
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i32 %42)
%44 = load i32*, i32** %4
%45 = call i32 @fclose(i32* %44)
%46 = load i32*, i32** %5
%47 = call i32 @fclose(i32* %46)
store i32 0, i32* %1
br label %48
48: ; preds = %36, %15, %10
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [10 x i8] c"zhuin.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [13 x i8] c"zhuin_data.h\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [46 x i8] c"/* this file is generated from zhuin.txt. */\0A\00"
@.str.5 = [46 x i8] c"static const struct entry default_data[] = {\0A\00"
@.str.6 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.7 = [14 x i8] c"\09{\22%s\22, %d},\0A\00"
@.str.8 = [9 x i8] c"\09{0, 0}\0A\00"
@.str.9 = [5 x i8] c"};\0A\0A\00"
@.str.10 = [41 x i8] c"static const int default_data_len = %d;\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %31, label %7
7: ; preds = %0
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %31, label %10
10: ; preds = %7
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i64 45, i64 1, i32* %8)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i64 45, i64 1, i32* %8)
%13 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %3, i8* %4)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %24, label %16
16: ; preds = %10, %16
%17 = phi i32 [ %20, %16 ], [ 0, %10 ]
%18 = call i32 @zhuin_to_inx(i8* %4)
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %3, i32 %18)
%20 = add nuw nsw i32 %17, 1
%21 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* %3, i8* %4)
%22 = load i64, i64* @EOF
%23 = icmp eq i64 %21, %22
br i1 %23, label %24, label %16
24: ; preds = %16, %10
%25 = phi i32 [ 0, %10 ], [ %20, %16 ]
%26 = call i64 @fwrite(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i64 8, i64 1, i32* %8)
%27 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i64 4, i64 1, i32* %8)
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0), i32 %25)
%29 = call i32 @fclose(i32* %5)
%30 = call i32 @fclose(i32* %8)
br label %31
31: ; preds = %7, %0, %24
%32 = phi i32 [ 0, %24 ], [ -1, %0 ], [ -1, %7 ]
ret i32 %32
}