#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 event_format_file_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int header_info_format_read(int /*<<< orphan*/ *);
int initial_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  FILE *f;
  int res;
  f = fopen(argv[1], "r");
  if (f == NULL) {
    perror("FOpen");
    return -1;
  }
  res = initial_read(f);
  printf("Initial Header Read: %d\n", res);
  res = header_info_format_read(f);
  printf("Header Info Format Read: %d\n", res);
  res = event_format_file_read(f);
  printf("Event Format File Read: %d\n", res);
  return res;
}


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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b1 <main+0x51>
lea    0xe62(%rip),%rdi
call   1080 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1208 <main+0xa8>
mov    -0x18(%rbp),%rdi
call   1040 <initial_read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <header_info_format_read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe3f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <event_format_file_read@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x8(%rsi),%rdi
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11c1 <main+0x61>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <initial_read@plt>
lea    0xe80(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <header_info_format_read@plt>
lea    0xe83(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <event_format_file_read@plt>
mov    %eax,%ebx
lea    0xe88(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe3a(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%ebx
jmp    11bd <main+0x5d>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"FOpen\00"
@.str.2 = [25 x i8] c"Initial Header Read: %d\0A\00"
@.str.3 = [29 x i8] c"Header Info Format Read: %d\0A\00"
@.str.4 = [28 x i8] c"Event Format File Read: %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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %30
16: ; preds = %2
%17 = load i32*, i32** %6
%18 = call i32 @initial_read(i32* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %6
%22 = call i32 @header_info_format_read(i32* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %6
%26 = call i32 @event_format_file_read(i32* %25)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %7
store i32 %29, i32* %3
br label %30
30: ; preds = %16, %14
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [6 x i8] c"FOpen\00"
@.str.2 = [25 x i8] c"Initial Header Read: %d\0A\00"
@.str.3 = [29 x i8] c"Header Info Format Read: %d\0A\00"
@.str.4 = [28 x i8] c"Event Format File Read: %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 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %16
9: ; preds = %2
%10 = tail call i32 @initial_read(i32* %5)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 @header_info_format_read(i32* %5)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = tail call i32 @event_format_file_read(i32* %5)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %9, %7
%17 = phi i32 [ -1, %7 ], [ %14, %9 ]
ret i32 %17
}