#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ parse_file(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <datafile>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  FILE *f = NULL;
  do {
    const char *filename = argv[1];
    f = fopen(filename, "rt");
    if (f == NULL) {
      fprintf(stderr, "%s: %s\n", filename, strerror(errno));
      break;
    }
    parse_file(f, filename);
    if (ferror(f)) {
      fprintf(stderr, "%s: %s\n", filename, strerror(errno));
      break;
    }
  } while (0);
  if (f != NULL) {
    fclose(f);
    f = NULL;
  }
  exit(EXIT_SUCCESS);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    11bc <main+0x4c>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    122e <main+0xbe>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1292 <main+0x122>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <parse_file@plt>
mov    -0x18(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     128d <main+0x11d>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xd98(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1292 <main+0x122>
jmp    1292 <main+0x122>
cmpq   $0x0,-0x18(%rbp)
je     12ae <main+0x13e>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x18(%rbp)
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     11a1 <main+0x31>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe74(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x8(%rsi),%r14
lea    0xe6a(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
jne    11e8 <main+0x78>
mov    0x2e20(%rip),%rax
mov    (%rax),%ebx
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe42(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    1238 <main+0xc8>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <parse_file@plt>
mov    %rbx,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     1230 <main+0xc0>
mov    0x2dd6(%rip),%rax
mov    (%rax),%ebp
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdf8(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <datafile>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
store i32* null, i32** %6
br label %19
19: ; preds = %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %33
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %7
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %31)
br label %47
33: ; preds = %19
%34 = load i32*, i32** %6
%35 = load i8*, i8** %7
%36 = call i32 @parse_file(i32* %34, i8* %35)
%37 = load i32*, i32** %6
%38 = call i64 @ferror(i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %7
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %44)
br label %47
46: ; preds = %33
br label %47
47: ; preds = %46, %40, %27
%48 = load i32*, i32** %6
%49 = icmp ne i32* %48, null
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i32*, i32** %6
%52 = call i32 @fclose(i32* %51)
store i32* null, i32** %6
br label %53
53: ; preds = %50, %47
%54 = load i32, i32* @EXIT_SUCCESS
%55 = call i32 @exit(i32 %54)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <datafile>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [8 x i8] c"%s: %s\0A\00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %24, label %15
15: ; preds = %10
%16 = tail call i32 @parse_file(i32* %13, i8* %12)
%17 = tail call i64 @ferror(i32* %13)
%18 = icmp eq i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %22)
br label %29
24: ; preds = %10
%25 = load i32, i32* @stderr
%26 = load i32, i32* @errno
%27 = tail call i8* @strerror(i32 %26)
%28 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %27)
br label %31
29: ; preds = %15, %19
%30 = tail call i32 @fclose(i32* %13)
br label %31
31: ; preds = %24, %29
%32 = load i32, i32* @EXIT_SUCCESS
%33 = tail call i32 @exit(i32 %32)
unreachable
}