#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*/ free(char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ parse_main(char *);
int main(int argc, char *argv[]) {
  if (argc >= 2) {
    int len = 0;
    char *code;
    FILE *in;
    code = (char *)malloc(256 * 1024 * sizeof(char));
    in = fopen(argv[1], "r");
    while (fscanf(in, "%c", &code[len]) != EOF)
      len++;
    code[len] = '\0';
    fclose(in);
    parse_main(code);
    free(code);
  }
  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   $0x2,-0x8(%rbp)
jl     120d <main+0xad>
movl   $0x0,-0x14(%rbp)
mov    $0x40000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x14(%rbp),%rax
add    %rax,%rdx
lea    0xe3f(%rip),%rsi
call   1060 <fscanf@plt>
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%rax
je     11e6 <main+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x4d>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <parse_main@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jl     11ed <main+0x8d>
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    $0x40000,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe66(%rip),%r15
mov    0x2e45(%rip),%r13
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1060 <fscanf@plt>
add    $0x1,%rbx
cmp    0x0(%r13),%rax
jne    11b0 <main+0x50>
movb   $0x0,-0x1(%rbx)
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1040 <parse_main@plt>
mov    %r14,%rdi
call   1030 <free@plt>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %41
11: ; preds = %2
store i32 0, i32* %6
%12 = call i64 @malloc(i32 262144)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %8
br label %18
18: ; preds = %27, %11
%19 = load i32*, i32** %8
%20 = load i8*, i8** %7
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = call i64 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i64, i64* @EOF
%26 = icmp ne i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %18
30: ; preds = %18
%31 = load i8*, i8** %7
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 0, i8* %34
%35 = load i32*, i32** %8
%36 = call i32 @fclose(i32* %35)
%37 = load i8*, i8** %7
%38 = call i32 @parse_main(i8* %37)
%39 = load i8*, i8** %7
%40 = call i32 @free(i8* %39)
br label %41
41: ; preds = %30, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = tail call i64 @malloc(i32 262144)
%6 = inttoptr i64 %5 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %10, %4
%11 = phi i64 [ %16, %10 ], [ 0, %4 ]
%12 = getelementptr inbounds i8, i8* %6, i64 %11
%13 = tail call i64 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
%16 = add nuw i64 %11, 1
br i1 %15, label %17, label %10
17: ; preds = %10
store i8 0, i8* %12
%18 = tail call i32 @fclose(i32* %9)
%19 = tail call i32 @parse_main(i8* %6)
%20 = tail call i32 @free(i8* %6)
br label %21
21: ; preds = %17, %2
ret i32 0
}