#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 */
char *CopyString(void *, int /*<<< orphan*/);
int /*<<< orphan*/ DeleteString(void *, char *);
int /*<<< orphan*/ EnvGetParsingFileName(void *);
int /*<<< orphan*/ EnvSetParsingFileName(void *, char const *);
int /*<<< orphan*/ GenClose(void *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *GenOpen(void *, char const *, char *);
int LoadConstructsFromLogicalName(void *, char *);
int /*<<< orphan*/ SetFastLoad(void *, int /*<<< orphan*/ *);
int EnvLoad(void *theEnv, const char *fileName) {
  FILE *theFile;
  char *oldParsingFileName;
  int noErrorsDetected;
  if ((theFile = GenOpen(theEnv, fileName, "r")) == NULL)
    return (0);
  SetFastLoad(theEnv, theFile);
  oldParsingFileName = CopyString(theEnv, EnvGetParsingFileName(theEnv));
  EnvSetParsingFileName(theEnv, fileName);
  noErrorsDetected = LoadConstructsFromLogicalName(theEnv, (char *)theFile);
  EnvSetParsingFileName(theEnv, oldParsingFileName);
  DeleteString(theEnv, oldParsingFileName);
  SetFastLoad(theEnv, NULL);
  GenClose(theEnv, theFile);
  if (noErrorsDetected)
    return (1);
  return (-1);
}


x86 assembly (clang, -O0):
<EnvLoad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe61(%rip),%rdx
call   1080 <GenOpen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11be <EnvLoad+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    1259 <EnvLoad+0xd9>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10a0 <SetFastLoad@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <EnvGetParsingFileName@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1030 <CopyString@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <EnvSetParsingFileName@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <LoadConstructsFromLogicalName@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <EnvSetParsingFileName@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <DeleteString@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <SetFastLoad@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <GenClose@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1252 <EnvLoad+0xd2>
movl   $0x1,-0x4(%rbp)
jmp    1259 <EnvLoad+0xd9>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EnvLoad>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xe6b(%rip),%rdx
call   1080 <GenOpen@plt>
test   %rax,%rax
je     120f <EnvLoad+0x8f>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <SetFastLoad@plt>
mov    %rbx,%rdi
call   1070 <EnvGetParsingFileName@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <CopyString@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <EnvSetParsingFileName@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <LoadConstructsFromLogicalName@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <EnvSetParsingFileName@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <DeleteString@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   10a0 <SetFastLoad@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <GenClose@plt>
cmp    $0x1,%ebp
sbb    %eax,%eax
or     $0x1,%eax
jmp    1211 <EnvLoad+0x91>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @EnvLoad(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = call i32* @GenOpen(i8* %9, i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 0, i32* %3
br label %44
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = load i32*, i32** %6
%17 = call i32 @SetFastLoad(i8* %15, i32* %16)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i32 @EnvGetParsingFileName(i8* %19)
%21 = call i8* @CopyString(i8* %18, i32 %20)
store i8* %21, i8** %7
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = call i32 @EnvSetParsingFileName(i8* %22, i8* %23)
%25 = load i8*, i8** %4
%26 = load i32*, i32** %6
%27 = bitcast i32* %26 to i8*
%28 = call i32 @LoadConstructsFromLogicalName(i8* %25, i8* %27)
store i32 %28, i32* %8
%29 = load i8*, i8** %4
%30 = load i8*, i8** %7
%31 = call i32 @EnvSetParsingFileName(i8* %29, i8* %30)
%32 = load i8*, i8** %4
%33 = load i8*, i8** %7
%34 = call i32 @DeleteString(i8* %32, i8* %33)
%35 = load i8*, i8** %4
%36 = call i32 @SetFastLoad(i8* %35, i32* null)
%37 = load i8*, i8** %4
%38 = load i32*, i32** %6
%39 = call i32 @GenClose(i8* %37, i32* %38)
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %14
store i32 1, i32* %3
br label %44
43: ; preds = %14
store i32 -1, i32* %3
br label %44
44: ; preds = %43, %42, %13
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @EnvLoad(i8* %0, i8* %1) {
%3 = tail call i32* @GenOpen(i8* %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i32 @SetFastLoad(i8* %0, i32* %3)
%7 = tail call i32 @EnvGetParsingFileName(i8* %0)
%8 = tail call i8* @CopyString(i8* %0, i32 %7)
%9 = tail call i32 @EnvSetParsingFileName(i8* %0, i8* %1)
%10 = bitcast i32* %3 to i8*
%11 = tail call i32 @LoadConstructsFromLogicalName(i8* %0, i8* %10)
%12 = tail call i32 @EnvSetParsingFileName(i8* %0, i8* %8)
%13 = tail call i32 @DeleteString(i8* %0, i8* %8)
%14 = tail call i32 @SetFastLoad(i8* %0, i32* null)
%15 = tail call i32 @GenClose(i8* %0, i32* %3)
%16 = icmp eq i32 %11, 0
%17 = select i1 %16, i32 -1, i32 1
br label %18
18: ; preds = %5, %2
%19 = phi i32 [ 0, %2 ], [ %17, %5 ]
ret i32 %19
}