#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*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ parse_file(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, const char *argv[]) {
  FILE *file = stdin;
  int i = 1;
  if (argc > 1) {
    for (; i < argc; ++i) {
      file = fopen(argv[i], "rt");
      if (file) {
        parse_file(file);
        fclose(file);
      } else
        fprintf(stderr, "Unable to open file %s\n", argv[i]);
    }
  } else {
    parse_file(file);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11fd <main+0xbd>
jmp    117a <main+0x3a>
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f8 <main+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe67(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c4 <main+0x84>
mov    -0x18(%rbp),%rdi
call   1060 <parse_file@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11e5 <main+0xa5>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11ea <main+0xaa>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <main+0x3a>
jmp    1206 <main+0xc6>
mov    -0x18(%rbp),%rdi
call   1060 <parse_file@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11b4 <main+0x74>
mov    %rsi,%r12
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe9e(%rip),%r14
lea    0xe9a(%rip),%r15
jmp    118e <main+0x4e>
nopl   0x0(%rax,%rax,1)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    (%r12,%rbp,8),%rdx
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11c3 <main+0x83>
mov    (%r12,%rbp,8),%rdi
mov    %r14,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <parse_file@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    1185 <main+0x45>
mov    0x2e2d(%rip),%rax
mov    (%rax),%rdi
call   1060 <parse_file@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [3 x i8] c"rt\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Unable to open file %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32*, i32** @stdin
store i32* %8, i32** %6
store i32 1, i32* %7
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %43
11: ; preds = %2
br label %12
12: ; preds = %39, %11
%13 = load i32, i32* %7
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %42
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i32*, i32** %6
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %16
%26 = load i32*, i32** %6
%27 = call i32 @parse_file(i32* %26)
%28 = load i32*, i32** %6
%29 = call i32 @fclose(i32* %28)
br label %38
30: ; preds = %16
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %30, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %12
42: ; preds = %12
br label %46
43: ; preds = %2
%44 = load i32*, i32** %6
%45 = call i32 @parse_file(i32* %44)
br label %46
46: ; preds = %43, %42
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [3 x i8] c"rt\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Unable to open file %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %19
%7 = phi i64 [ 1, %4 ], [ %20, %19 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = tail call i32 @parse_file(i32* %10)
%14 = tail call i32 @fclose(i32* %10)
br label %19
15: ; preds = %6
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %8
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %12, %15
%20 = add nuw nsw i64 %7, 1
%21 = icmp eq i64 %20, %5
br i1 %21, label %25, label %6
22: ; preds = %2
%23 = load i32*, i32** @stdin
%24 = tail call i32 @parse_file(i32* %23)
br label %25
25: ; preds = %19, %22
ret i32 0
}