#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
const int main(int argc, char **argv) {
  FILE *fp0, *fp1;
  if (argc != 3) {
    fputs("\"txt2bin\"  copyright (C) 2001 H.Kawai\n"
          "usage : >txt2bin source.txt font.bin\n",
          stdout);
    return 1;
  }
  fp0 = fopen(argv[1], "r");
  fp1 = fopen(argv[2], "wb");
  if (fp0 == NULL) {
    fputs("can't open input file.\n", stderr);
    return 2;
  }
  if (fp1 == NULL) {
    fputs("can't open output file.\n", stderr);
    return 3;
  }
  do {
    char s[12];
    int i;
    if (fgets(s, 12, fp0) != NULL &&
        (s[0] == ' ' || s[0] == '*' || s[0] == '.')) {
      i = (s[0] == '*') << 7;
      i |= (s[1] == '*') << 6;
      i |= (s[2] == '*') << 5;
      i |= (s[3] == '*') << 4;
      i |= (s[4] == '*') << 3;
      i |= (s[5] == '*') << 2;
      i |= (s[6] == '*') << 1;
      i |= (s[7] == '*');
      fputc(i, fp1);
    }
  } while (!feof(fp0));
  fclose(fp0);
  fclose(fp1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a1 <main+0x41>
mov    0x2e51(%rip),%rax
mov    (%rax),%esi
lea    0xe70(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    136e <main+0x20e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe9c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11fd <main+0x9d>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    0xe65(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x2,-0x4(%rbp)
jmp    136e <main+0x20e>
cmpq   $0x0,-0x20(%rbp)
jne    1229 <main+0xc9>
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
lea    0xe51(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x3,-0x4(%rbp)
jmp    136e <main+0x20e>
jmp    122e <main+0xce>
lea    -0x2c(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xc,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1337 <main+0x1d7>
movsbl -0x2c(%rbp),%eax
cmp    $0x20,%eax
je     1271 <main+0x111>
movsbl -0x2c(%rbp),%eax
cmp    $0x2a,%eax
je     1271 <main+0x111>
movsbl -0x2c(%rbp),%eax
cmp    $0x2e,%eax
jne    1337 <main+0x1d7>
movsbl -0x2c(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x7,%eax
mov    %eax,-0x30(%rbp)
movsbl -0x2b(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x6,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x2a(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x5,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x29(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x4,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x28(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x3,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x27(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x2,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x26(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
shl    $0x1,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsbl -0x25(%rbp),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <fputc@plt>
jmp    133c <main+0x1dc>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    122e <main+0xce>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    126e <main+0x10e>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xeca(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
lea    0xeb9(%rip),%rsi
call   1080 <fopen@plt>
test   %rbx,%rbx
je     129e <main+0x13e>
mov    %rax,%r14
test   %rax,%rax
je     12ba <main+0x15a>
lea    0xc(%rsp),%r15
movabs $0x440100000000,%r12
jmp    11d0 <main+0x70>
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    128a <main+0x12a>
mov    %r15,%rdi
mov    $0xc,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11c0 <main+0x60>
movzbl 0xc(%rsp),%eax
cmp    $0x2e,%rax
ja     11c0 <main+0x60>
bt     %rax,%r12
jae    11c0 <main+0x60>
xor    %ecx,%ecx
cmp    $0x2a,%al
sete   %cl
shl    $0x7,%ecx
xor    %eax,%eax
cmpb   $0x2a,0xd(%rsp)
sete   %al
shl    $0x6,%eax
or     %ecx,%eax
xor    %ecx,%ecx
cmpb   $0x2a,0xe(%rsp)
sete   %cl
shl    $0x5,%ecx
or     %eax,%ecx
xor    %eax,%eax
cmpb   $0x2a,0xf(%rsp)
sete   %al
shl    $0x4,%eax
or     %ecx,%eax
xor    %ecx,%ecx
cmpb   $0x2a,0x10(%rsp)
sete   %cl
lea    (%rax,%rcx,8),%eax
xor    %ecx,%ecx
cmpb   $0x2a,0x11(%rsp)
sete   %cl
xor    %edx,%edx
cmpb   $0x2a,0x12(%rsp)
lea    (%rax,%rcx,4),%eax
sete   %dl
lea    (%rax,%rdx,2),%eax
xor    %edi,%edi
cmpb   $0x2a,0x13(%rsp)
sete   %dil
or     %eax,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    11c0 <main+0x60>
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
lea    0xd82(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%eax
jmp    12d4 <main+0x174>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12d4 <main+0x174>
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
lea    0xda3(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x2,%eax
jmp    12d4 <main+0x174>
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
lea    0xd9f(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x3,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [76 x i8] c"\22txt2bin\22 copyright (C) 2001 H.Kawai\0Ausage : >txt2bin source.txt font.bin\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [24 x i8] c"can't open input file.\0A\00"
@stderr = global i32 0
@.str.4 = [25 x i8] c"can't open output file.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [12 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stdout
%14 = call i32 @fputs(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %13)
store i32 1, i32* %3
br label %132
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %7
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %27)
store i32 2, i32* %3
br label %132
29: ; preds = %15
%30 = load i32*, i32** %7
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %33)
store i32 3, i32* %3
br label %132
35: ; preds = %29
br label %36
36: ; preds = %122, %35
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%38 = load i32*, i32** %6
%39 = call i32* @fgets(i8* %37, i32 12, i32* %38)
%40 = icmp ne i32* %39, null
br i1 %40, label %41, label %121
41: ; preds = %36
%42 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 32
br i1 %45, label %56, label %46
46: ; preds = %41
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 42
br i1 %50, label %56, label %51
51: ; preds = %46
%52 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 46
br i1 %55, label %56, label %121
56: ; preds = %51, %46, %41
%57 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 42
%61 = zext i1 %60 to i32
%62 = shl i32 %61, 7
store i32 %62, i32* %9
%63 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 1
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 42
%67 = zext i1 %66 to i32
%68 = shl i32 %67, 6
%69 = load i32, i32* %9
%70 = or i32 %69, %68
store i32 %70, i32* %9
%71 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 2
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 42
%75 = zext i1 %74 to i32
%76 = shl i32 %75, 5
%77 = load i32, i32* %9
%78 = or i32 %77, %76
store i32 %78, i32* %9
%79 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 3
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 42
%83 = zext i1 %82 to i32
%84 = shl i32 %83, 4
%85 = load i32, i32* %9
%86 = or i32 %85, %84
store i32 %86, i32* %9
%87 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 4
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 42
%91 = zext i1 %90 to i32
%92 = shl i32 %91, 3
%93 = load i32, i32* %9
%94 = or i32 %93, %92
store i32 %94, i32* %9
%95 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 5
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp eq i32 %97, 42
%99 = zext i1 %98 to i32
%100 = shl i32 %99, 2
%101 = load i32, i32* %9
%102 = or i32 %101, %100
store i32 %102, i32* %9
%103 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 6
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 42
%107 = zext i1 %106 to i32
%108 = shl i32 %107, 1
%109 = load i32, i32* %9
%110 = or i32 %109, %108
store i32 %110, i32* %9
%111 = getelementptr inbounds [12 x i8], [12 x i8]* %8, i64 0, i64 7
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 42
%115 = zext i1 %114 to i32
%116 = load i32, i32* %9
%117 = or i32 %116, %115
store i32 %117, i32* %9
%118 = load i32, i32* %9
%119 = load i32*, i32** %7
%120 = call i32 @fputc(i32 %118, i32* %119)
br label %121
121: ; preds = %56, %51, %36
br label %122
122: ; preds = %121
%123 = load i32*, i32** %6
%124 = call i32 @feof(i32* %123)
%125 = icmp ne i32 %124, 0
%126 = xor i1 %125, true
br i1 %126, label %36, label %127
127: ; preds = %122
%128 = load i32*, i32** %6
%129 = call i32 @fclose(i32* %128)
%130 = load i32*, i32** %7
%131 = call i32 @fclose(i32* %130)
store i32 0, i32* %3
br label %132
132: ; preds = %127, %32, %26, %12
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
@.str = [76 x i8] c"\22txt2bin\22 copyright (C) 2001 H.Kawai\0Ausage : >txt2bin source.txt font.bin\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [24 x i8] c"can't open input file.\0A\00"
@stderr = global i32 0
@.str.4 = [25 x i8] c"can't open output file.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = icmp eq i32 %0, 3
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stdout
%7 = tail call i32 @fputs(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %76
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32* %11, null
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i32, i32* @stderr
%18 = tail call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %76
19: ; preds = %8
%20 = icmp eq i32* %14, null
br i1 %20, label %30, label %21
21: ; preds = %19
%22 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 1
%24 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 2
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 3
%26 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 4
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 5
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 6
%29 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 7
br label %33
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = tail call i32 @fputs(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %31)
br label %76
33: ; preds = %21, %70
%34 = call i32* @fgets(i8* %22, i32 12, i32* %11)
%35 = icmp eq i32* %34, null
br i1 %35, label %70, label %36
36: ; preds = %33
%37 = load i8, i8* %22
switch i8 %37, label %70 [
i8 46, label %38
i8 42, label %38
i8 32, label %38
]
38: ; preds = %36, %36, %36
%39 = icmp eq i8 %37, 42
%40 = select i1 %39, i32 128, i32 0
%41 = load i8, i8* %23
%42 = icmp eq i8 %41, 42
%43 = select i1 %42, i32 64, i32 0
%44 = or i32 %43, %40
%45 = load i8, i8* %24
%46 = icmp eq i8 %45, 42
%47 = select i1 %46, i32 32, i32 0
%48 = or i32 %44, %47
%49 = load i8, i8* %25
%50 = icmp eq i8 %49, 42
%51 = select i1 %50, i32 16, i32 0
%52 = or i32 %48, %51
%53 = load i8, i8* %26
%54 = icmp eq i8 %53, 42
%55 = select i1 %54, i32 8, i32 0
%56 = or i32 %52, %55
%57 = load i8, i8* %27
%58 = icmp eq i8 %57, 42
%59 = select i1 %58, i32 4, i32 0
%60 = or i32 %56, %59
%61 = load i8, i8* %28
%62 = icmp eq i8 %61, 42
%63 = select i1 %62, i32 2, i32 0
%64 = or i32 %60, %63
%65 = load i8, i8* %29
%66 = icmp eq i8 %65, 42
%67 = zext i1 %66 to i32
%68 = or i32 %64, %67
%69 = call i32 @fputc(i32 %68, i32* %14)
br label %70
70: ; preds = %36, %38, %33
%71 = call i32 @feof(i32* %11)
%72 = icmp eq i32 %71, 0
br i1 %72, label %33, label %73
73: ; preds = %70
%74 = call i32 @fclose(i32* %11)
%75 = call i32 @fclose(i32* %14)
br label %76
76: ; preds = %73, %30, %16, %5
%77 = phi i32 [ 1, %5 ], [ 2, %16 ], [ 3, %30 ], [ 0, %73 ]
ret i32 %77
}