#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*/ puts(char *);
int main(int argc, char **argv) {
  FILE *fp0, *fp1;
  if (argc < 3) {
    puts("usage>makefont source.txt font.bin");
    return 1;
  }
  fp0 = fopen(argv[1], "rb");
  fp1 = fopen(argv[2], "wb");
  if (fp0 == NULL) {
    puts("can't open input file.");
    return 2;
  }
  if (fp1 == NULL) {
    puts("can't open output file.");
    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)
jge    1198 <main+0x38>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1353 <main+0x1f3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11eb <main+0x8b>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x2,-0x4(%rbp)
jmp    1353 <main+0x1f3>
cmpq   $0x0,-0x20(%rbp)
jne    120e <main+0xae>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
movl   $0x3,-0x4(%rbp)
jmp    1353 <main+0x1f3>
jmp    1213 <main+0xb3>
lea    -0x2c(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xc,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     131c <main+0x1bc>
movsbl -0x2c(%rbp),%eax
cmp    $0x20,%eax
je     1256 <main+0xf6>
movsbl -0x2c(%rbp),%eax
cmp    $0x2a,%eax
je     1256 <main+0xf6>
movsbl -0x2c(%rbp),%eax
cmp    $0x2e,%eax
jne    131c <main+0x1bc>
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    1321 <main+0x1c1>
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1213 <main+0xb3>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <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    $0x2,%edi
jg     1186 <main+0x26>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    12c6 <main+0x166>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe8f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rbx,%rbx
je     12a2 <main+0x142>
mov    %rax,%r14
test   %rax,%rax
je     12b5 <main+0x155>
lea    0xc(%rsp),%r15
movabs $0x440100000000,%r12
jmp    11f0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    128e <main+0x12e>
mov    %r15,%rdi
mov    $0xc,%esi
mov    %rbx,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e0 <main+0x80>
movzbl 0xc(%rsp),%eax
cmp    $0x2e,%rax
ja     11e0 <main+0x80>
bt     %rax,%r12
jae    11e0 <main+0x80>
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    11e0 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12c6 <main+0x166>
lea    0xd80(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%eax
jmp    12c6 <main+0x166>
lea    0xd84(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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