#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 EOF;
int fasm(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  FILE *i;
  FILE *o;
  const char *onam = "a.out";
  argv++;
  if (*argv == NULL)
    return 66;
  if (strcmp(*argv, "-o") == 0)
    onam = *++argv;
  else if (strcmp(*argv, "--") == 0)
    argv++;
  if (onam == NULL)
    return 64;
  if ((o = fopen(onam, "w")) == NULL)
    return 73;
  while (*argv != NULL) {
    int ln;
    if ((i = fopen(*argv, "r")) == NULL)
      return 66;
    if ((ln = fasm(i, o)) != 0) {
      int c;
      while ((c = fgetc(i)) != EOF && c != '\n')
        fputc(c, stderr);
      fprintf(stderr, "\n^ %s:%d\n", *argv, ln);
      return 65;
    }
    fclose(i);
    argv++;
  }
  fclose(o);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11b7 <main+0x47>
movl   $0x42,-0x4(%rbp)
jmp    1364 <main+0x1f4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe41(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    121e <main+0xae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1219 <main+0xa9>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    121e <main+0xae>
cmpq   $0x0,-0x28(%rbp)
jne    1235 <main+0xc5>
movl   $0x40,-0x4(%rbp)
jmp    1364 <main+0x1f4>
mov    -0x28(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    125f <main+0xef>
movl   $0x49,-0x4(%rbp)
jmp    1364 <main+0x1f4>
jmp    1264 <main+0xf4>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1354 <main+0x1e4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    129f <main+0x12f>
movl   $0x42,-0x4(%rbp)
jmp    1364 <main+0x1f4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <fasm@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
je     133a <main+0x1ca>
jmp    12bd <main+0x14d>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x30(%rbp)
xor    %eax,%eax
mov    0x2d14(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x31(%rbp)
je     12e9 <main+0x179>
cmpl   $0xa,-0x30(%rbp)
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    12f9 <main+0x189>
jmp    130f <main+0x19f>
mov    -0x30(%rbp),%edi
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
call   1050 <fputc@plt>
jmp    12bd <main+0x14d>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x2c(%rbp),%ecx
lea    0xce7(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x41,-0x4(%rbp)
jmp    1364 <main+0x1f4>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1264 <main+0xf4>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    $0x42,%r14d
test   %rdi,%rdi
je     12bf <main+0x14f>
mov    %rsi,%rbx
lea    0xe6e(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11ca <main+0x5a>
lea    0x8(%rbx),%rbp
mov    0x8(%rbx),%rdi
lea    0xe58(%rip),%rsi
call   1060 <strcmp@plt>
add    $0x10,%rbx
test   %rax,%rax
cmovne %rbp,%rbx
lea    0xe38(%rip),%rdi
jmp    11d7 <main+0x67>
mov    0x10(%rbx),%rdi
test   %rdi,%rdi
je     124c <main+0xdc>
add    $0x10,%rbx
lea    0xe2e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1244 <main+0xd4>
mov    %rax,%r12
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1237 <main+0xc7>
add    $0x8,%rbx
lea    0xe10(%rip),%r13
xchg   %ax,%ax
mov    %r13,%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12bf <main+0x14f>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1090 <fasm@plt>
test   %eax,%eax
jne    1254 <main+0xe4>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1200 <main+0x90>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %r14d,%r14d
jmp    12bf <main+0x14f>
mov    $0x49,%r14d
jmp    12bf <main+0x14f>
mov    $0x40,%r14d
jmp    12bf <main+0x14f>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     129d <main+0x12d>
mov    0x2d7d(%rip),%r14
cmp    (%r14),%eax
je     129d <main+0x12d>
mov    0x2d61(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r12),%esi
mov    %eax,%edi
call   1050 <fputc@plt>
mov    %rbp,%rdi
call   1040 <fgetc@plt>
cmp    $0xa,%eax
je     129d <main+0x12d>
cmp    (%r14),%eax
jne    1280 <main+0x110>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbx),%rdx
lea    0xd5f(%rip),%rsi
mov    %r15d,%ecx
call   1070 <fprintf@plt>
mov    $0x41,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"a.out\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [3 x i8] c"--\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"r\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.5 = [10 x i8] c"\0A^ %s:%d\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 i8*
%9 = alloca i32
%10 = 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** %8
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %5
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 66, i32* %3
br label %89
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %5
%25 = load i8*, i8** %24
store i8* %25, i8** %8
br label %35
26: ; preds = %17
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i32 1
store i8** %33, i8*** %5
br label %34
34: ; preds = %31, %26
br label %35
35: ; preds = %34, %22
%36 = load i8*, i8** %8
%37 = icmp eq i8* %36, null
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 64, i32* %3
br label %89
39: ; preds = %35
%40 = load i8*, i8** %8
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %7
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 73, i32* %3
br label %89
44: ; preds = %39
br label %45
45: ; preds = %81, %44
%46 = load i8**, i8*** %5
%47 = load i8*, i8** %46
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %86
49: ; preds = %45
%50 = load i8**, i8*** %5
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %52, i32** %6
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %55
54: ; preds = %49
store i32 66, i32* %3
br label %89
55: ; preds = %49
%56 = load i32*, i32** %6
%57 = load i32*, i32** %7
%58 = call i32 @fasm(i32* %56, i32* %57)
store i32 %58, i32* %9
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %81
60: ; preds = %55
br label %61
61: ; preds = %71, %60
%62 = load i32*, i32** %6
%63 = call i32 @fgetc(i32* %62)
store i32 %63, i32* %10
%64 = load i32, i32* @EOF
%65 = icmp ne i32 %63, %64
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = load i32, i32* %10
%68 = icmp ne i32 %67, 10
br label %69
69: ; preds = %66, %61
%70 = phi i1 [ false, %61 ], [ %68, %66 ]
br i1 %70, label %71, label %75
71: ; preds = %69
%72 = load i32, i32* %10
%73 = load i32, i32* @stderr
%74 = call i32 @fputc(i32 %72, i32 %73)
br label %61
75: ; preds = %69
%76 = load i32, i32* @stderr
%77 = load i8**, i8*** %5
%78 = load i8*, i8** %77
%79 = load i32, i32* %9
%80 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %78, i32 %79)
store i32 65, i32* %3
br label %89
81: ; preds = %55
%82 = load i32*, i32** %6
%83 = call i32 @fclose(i32* %82)
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i32 1
store i8** %85, i8*** %5
br label %45
86: ; preds = %45
%87 = load i32*, i32** %7
%88 = call i32 @fclose(i32* %87)
store i32 0, i32* %3
br label %89
89: ; preds = %86, %75, %54, %43, %38, %16
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@.str = [6 x i8] c"a.out\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [3 x i8] c"--\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [2 x i8] c"r\00"
@EOF = global i32 0
@stderr = global i32 0
@.str.5 = [10 x i8] c"\0A^ %s:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %61, label %6
6: ; preds = %2
%7 = tail call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = select i1 %12, i8** %13, i8** %3
br label %19
15: ; preds = %6
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %61, label %19
19: ; preds = %9, %15
%20 = phi i8** [ %14, %9 ], [ %16, %15 ]
%21 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %9 ], [ %17, %15 ]
%22 = tail call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %61, label %24
24: ; preds = %19
%25 = load i8*, i8** %20
%26 = icmp eq i8* %25, null
br i1 %26, label %59, label %27
27: ; preds = %24, %54
%28 = phi i8* [ %57, %54 ], [ %25, %24 ]
%29 = phi i8** [ %56, %54 ], [ %20, %24 ]
%30 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %61, label %32
32: ; preds = %27
%33 = tail call i32 @fasm(i32* %30, i32* %22)
%34 = icmp eq i32 %33, 0
br i1 %34, label %54, label %35
35: ; preds = %32
%36 = tail call i32 @fgetc(i32* %30)
%37 = load i32, i32* @EOF
%38 = icmp ne i32 %36, %37
%39 = icmp ne i32 %36, 10
%40 = and i1 %39, %38
br i1 %40, label %41, label %50
41: ; preds = %35, %41
%42 = phi i32 [ %45, %41 ], [ %36, %35 ]
%43 = load i32, i32* @stderr
%44 = tail call i32 @fputc(i32 %42, i32 %43)
%45 = tail call i32 @fgetc(i32* %30)
%46 = load i32, i32* @EOF
%47 = icmp ne i32 %45, %46
%48 = icmp ne i32 %45, 10
%49 = and i1 %48, %47
br i1 %49, label %41, label %50
50: ; preds = %41, %35
%51 = load i32, i32* @stderr
%52 = load i8*, i8** %29
%53 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %52, i32 %33)
br label %61
54: ; preds = %32
%55 = tail call i32 @fclose(i32* %30)
%56 = getelementptr inbounds i8*, i8** %29, i64 1
%57 = load i8*, i8** %56
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %27
59: ; preds = %54, %24
%60 = tail call i32 @fclose(i32* %22)
br label %61
61: ; preds = %27, %50, %19, %15, %2, %59
%62 = phi i32 [ 0, %59 ], [ 66, %2 ], [ 64, %15 ], [ 73, %19 ], [ 65, %50 ], [ 66, %27 ]
ret i32 %62
}