#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*/ assert(char const *);
int /*<<< orphan*/ cleanup();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ parser_set_stream(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ yyparse();
int load(char const *fileName) {
  assert(fileName);
  unsigned ret = 1;
  FILE *f = fopen(fileName, "r");
  if (!f) {
    fprintf(stderr, "cannot open %s\n", fileName);
    exit(2);
  }
  cleanup();
  parser_set_stream(f);
  ret = yyparse() != 0;
  fclose(f);
  return ret;
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <assert@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11de <load+0x5e>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe33(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1080 <cleanup@plt>
mov    -0x18(%rbp),%rdi
call   1050 <parser_set_stream@plt>
mov    $0x0,%al
call   1030 <yyparse@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1060 <assert@plt>
lea    0xe6d(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11d1 <load+0x51>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <cleanup@plt>
mov    %rbx,%rdi
call   1050 <parser_set_stream@plt>
xor    %eax,%eax
call   1030 <yyparse@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"cannot open %s\0A\00"
define i32 @load(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @assert(i8* %5)
store i32 1, i32* %3
%7 = load i8*, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @exit(i32 2)
unreachable
16: ; preds = %1
%17 = call i32 (...) @cleanup()
%18 = load i32*, i32** %4
%19 = call i32 @parser_set_stream(i32* %18)
%20 = call i64 (...) @yyparse()
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i32
store i32 %22, i32* %3
%23 = load i32*, i32** %4
%24 = call i32 @fclose(i32* %23)
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"cannot open %s\0A\00"
define i32 @load(i8* %0) {
%2 = tail call i32 @assert(i8* %0)
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%8 = tail call i32 @exit(i32 2)
unreachable
9: ; preds = %1
%10 = tail call i32 (...) @cleanup()
%11 = tail call i32 @parser_set_stream(i32* %3)
%12 = tail call i64 (...) @yyparse()
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @fclose(i32* %3)
ret i32 %14
}