#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 compile_file(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                 unsigned int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
int usage();
int main(int argc, char **argv) {
  char *outputfile = "b.out";
  char *inputfile = "";
  unsigned int options = 0;
  int i;
  if (argc <= 1) {
    return usage();
  }
  for (i = 1; i < argc; ++i) {
    char *arg = argv[i];
    if (arg[0] == '-') {
      switch (arg[1]) {
      case 'o':
        outputfile = argv[++i];
        break;
      case 'v': {
        int maj = (0x05 & 0xF0) >> 4;
        int min = 0x05 & 0x0F;
        printf("Version %X.%X\n", maj, min);
        exit(0);
      }
      case 'p':
        options |= (1 << 0);
        break;
      case 'd':
        options |= (1 << 1);
        break;
      case 'h':
        return usage();
      default:
        fprintf(stderr, "Unrecognized switch -%c\n", arg[1]);
        return usage();
      }
    } else {
      if (strlen(inputfile))
        return usage();
      inputfile = argv[i];
    }
  }
  if (strlen(inputfile) == 0) {
    return usage();
  }
  FILE *in = NULL;
  FILE *out = NULL;
  in = fopen(inputfile, "rb");
  if (!(options & (1 << 0)))
    out = fopen(outputfile, "wb");
  if (in == NULL) {
    fprintf(stderr, "%s: no such file\n", inputfile);
    exit(1);
  }
  int value = compile_file(in, out, inputfile, options);
  fclose(in);
  if (!(options & (1 << 0)))
    fclose(out);
  return value;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb8(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     11cc <main+0x4c>
mov    $0x0,%al
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    13eb <main+0x26b>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1314 <main+0x194>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    12cf <main+0x14f>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0x12,%eax
ja     129c <main+0x11c>
mov    -0x58(%rbp),%rax
lea    0xddc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
jmp    12ca <main+0x14a>
movl   $0x0,-0x34(%rbp)
movl   $0x5,-0x38(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xded(%rip),%rdi
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x24(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ca <main+0x14a>
mov    -0x24(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    12ca <main+0x14a>
mov    $0x0,%al
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    13eb <main+0x26b>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%edx
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    13eb <main+0x26b>
jmp    1301 <main+0x181>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
je     12f1 <main+0x171>
mov    $0x0,%al
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    13eb <main+0x26b>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    1306 <main+0x186>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d3 <main+0x53>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    1336 <main+0x1b6>
mov    $0x0,%al
call   1080 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    13eb <main+0x26b>
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    137d <main+0x1fd>
mov    -0x18(%rbp),%rdi
lea    0xd09(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13ad <main+0x22d>
mov    0x2c51(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <compile_file@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    13e5 <main+0x265>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jge    118c <main+0x1c>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <usage@plt>
mov    $0x1,%eax
xor    %r12d,%r12d
lea    0xec5(%rip),%rbx
lea    0xeaa(%rip),%r14
lea    0xe57(%rip),%r8
jmp    11bf <main+0x4f>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
mov    %rdx,%rbx
jne    117d <main+0xd>
add    $0x1,%eax
cmp    %edi,%eax
jge    11fa <main+0x8a>
movslq %eax,%rbp
mov    (%rsi,%rbp,8),%rdx
cmpb   $0x2d,(%rdx)
jne    11b0 <main+0x40>
movsbl 0x1(%rdx),%edx
lea    -0x64(%rdx),%ecx
cmp    $0x12,%ecx
ja     126b <main+0xfb>
movslq (%r8,%rcx,4),%rcx
add    %r8,%rcx
jmp    *%rcx
or     $0x2,%r12d
jmp    11b8 <main+0x48>
lea    0x1(%rbp),%eax
mov    0x8(%rsi,%rbp,8),%r14
jmp    11b8 <main+0x48>
or     $0x1,%r12d
jmp    11b8 <main+0x48>
cmpb   $0x0,(%rbx)
je     117d <main+0xd>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
mov    %rax,%r15
test   $0x1,%r12b
jne    122f <main+0xbf>
lea    0xe5b(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%r14
jmp    1232 <main+0xc2>
xor    %r14d,%r14d
test   %r15,%r15
je     12a1 <main+0x131>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12d,%ecx
call   1030 <compile_file@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1040 <fclose@plt>
test   $0x1,%r12b
jne    1260 <main+0xf0>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    117d <main+0xd>
lea    0xdc4(%rip),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"b.out\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [15 x i8] c"Version %X.%X\0A\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"Unrecognized switch -%c\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [18 x i8] c"%s: no such file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i32 0, i32* %8
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @usage()
store i32 %19, i32* %3
br label %125
20: ; preds = %2
store i32 1, i32* %9
br label %21
21: ; preds = %83, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %86
25: ; preds = %21
%26 = load i8**, i8*** %5
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 45
br i1 %35, label %36, label %70
36: ; preds = %25
%37 = load i8*, i8** %10
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
switch i32 %40, label %61 [
i32 111, label %41
i32 118, label %48
i32 112, label %53
i32 100, label %56
i32 104, label %59
]
41: ; preds = %36
%42 = load i8**, i8*** %5
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %42, i64 %45
%47 = load i8*, i8** %46
store i8* %47, i8** %6
br label %69
48: ; preds = %36
store i32 0, i32* %11
store i32 5, i32* %12
%49 = load i32, i32* %11
%50 = load i32, i32* %12
%51 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %49, i32 %50)
%52 = call i32 @exit(i32 0)
unreachable
53: ; preds = %36
%54 = load i32, i32* %8
%55 = or i32 %54, 1
store i32 %55, i32* %8
br label %69
56: ; preds = %36
%57 = load i32, i32* %8
%58 = or i32 %57, 2
store i32 %58, i32* %8
br label %69
59: ; preds = %36
%60 = call i32 (...) @usage()
store i32 %60, i32* %3
br label %125
61: ; preds = %36
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %10
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %66)
%68 = call i32 (...) @usage()
store i32 %68, i32* %3
br label %125
69: ; preds = %56, %53, %41
br label %82
70: ; preds = %25
%71 = load i8*, i8** %7
%72 = call i64 @strlen(i8* %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 (...) @usage()
store i32 %75, i32* %3
br label %125
76: ; preds = %70
%77 = load i8**, i8*** %5
%78 = load i32, i32* %9
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
store i8* %81, i8** %7
br label %82
82: ; preds = %76, %69
br label %83
83: ; preds = %82
%84 = load i32, i32* %9
%85 = add nsw i32 %84, 1
store i32 %85, i32* %9
br label %21
86: ; preds = %21
%87 = load i8*, i8** %7
%88 = call i64 @strlen(i8* %87)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = call i32 (...) @usage()
store i32 %91, i32* %3
br label %125
92: ; preds = %86
store i32* null, i32** %13
store i32* null, i32** %14
%93 = load i8*, i8** %7
%94 = call i32* @fopen(i8* %93, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %94, i32** %13
%95 = load i32, i32* %8
%96 = and i32 %95, 1
%97 = icmp ne i32 %96, 0
br i1 %97, label %101, label %98
98: ; preds = %92
%99 = load i8*, i8** %6
%100 = call i32* @fopen(i8* %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %100, i32** %14
br label %101
101: ; preds = %98, %92
%102 = load i32*, i32** %13
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %109
104: ; preds = %101
%105 = load i32, i32* @stderr
%106 = load i8*, i8** %7
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %106)
%108 = call i32 @exit(i32 1)
unreachable
109: ; preds = %101
%110 = load i32*, i32** %13
%111 = load i32*, i32** %14
%112 = load i8*, i8** %7
%113 = load i32, i32* %8
%114 = call i32 @compile_file(i32* %110, i32* %111, i8* %112, i32 %113)
store i32 %114, i32* %15
%115 = load i32*, i32** %13
%116 = call i32 @fclose(i32* %115)
%117 = load i32, i32* %8
%118 = and i32 %117, 1
%119 = icmp ne i32 %118, 0
br i1 %119, label %123, label %120
120: ; preds = %109
%121 = load i32*, i32** %14
%122 = call i32 @fclose(i32* %121)
br label %123
123: ; preds = %120, %109
%124 = load i32, i32* %15
store i32 %124, i32* %3
br label %125
125: ; preds = %123, %90, %74, %61, %59, %18
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
@.str = [6 x i8] c"b.out\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [15 x i8] c"Version %X.%X\0A\00"
@stderr = global i32 0
@.str.3 = [25 x i8] c"Unrecognized switch -%c\0A\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [3 x i8] c"wb\00"
@.str.6 = [18 x i8] c"%s: no such file\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %74
6: ; preds = %2, %44
%7 = phi i8* [ %48, %44 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %2 ]
%8 = phi i8* [ %47, %44 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %2 ]
%9 = phi i32 [ %46, %44 ], [ 0, %2 ]
%10 = phi i32 [ %49, %44 ], [ 1, %2 ]
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %39
16: ; preds = %6
%17 = getelementptr inbounds i8, i8* %13, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %34 [
i32 111, label %20
i32 118, label %25
i32 112, label %28
i32 100, label %30
i32 104, label %32
]
20: ; preds = %16
%21 = add nsw i32 %10, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %1, i64 %22
%24 = load i8*, i8** %23
br label %44
25: ; preds = %16
%26 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 5)
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %16
%29 = or i32 %9, 1
br label %44
30: ; preds = %16
%31 = or i32 %9, 2
br label %44
32: ; preds = %16
%33 = tail call i32 (...) @usage()
br label %74
34: ; preds = %16
%35 = sext i8 %18 to i32
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%38 = tail call i32 (...) @usage()
br label %74
39: ; preds = %6
%40 = load i8, i8* %8
%41 = icmp eq i8 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = tail call i32 (...) @usage()
br label %74
44: ; preds = %39, %20, %28, %30
%45 = phi i32 [ %10, %39 ], [ %21, %20 ], [ %10, %28 ], [ %10, %30 ]
%46 = phi i32 [ %9, %39 ], [ %9, %20 ], [ %29, %28 ], [ %31, %30 ]
%47 = phi i8* [ %13, %39 ], [ %8, %20 ], [ %8, %28 ], [ %8, %30 ]
%48 = phi i8* [ %7, %39 ], [ %24, %20 ], [ %7, %28 ], [ %7, %30 ]
%49 = add nsw i32 %45, 1
%50 = icmp slt i32 %49, %0
br i1 %50, label %6, label %51
51: ; preds = %44
%52 = load i8, i8* %47
%53 = icmp eq i8 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = tail call i32 (...) @usage()
br label %74
56: ; preds = %51
%57 = tail call i32* @fopen(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%58 = and i32 %46, 1
%59 = icmp eq i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = tail call i32* @fopen(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %56
%63 = phi i32* [ null, %56 ], [ %61, %60 ]
%64 = icmp eq i32* %57, null
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = tail call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %47)
%68 = tail call i32 @exit(i32 1)
unreachable
69: ; preds = %62
%70 = tail call i32 @compile_file(i32* %57, i32* %63, i8* %47, i32 %46)
%71 = tail call i32 @fclose(i32* %57)
br i1 %59, label %72, label %74
72: ; preds = %69
%73 = tail call i32 @fclose(i32* %63)
br label %74
74: ; preds = %32, %34, %42, %69, %72, %54, %4
%75 = phi i32 [ %5, %4 ], [ %55, %54 ], [ %70, %72 ], [ %70, %69 ], [ %38, %34 ], [ %33, %32 ], [ %43, %42 ]
ret i32 %75
}