#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 */

/* Variables and functions */
int /*<<< orphan*/ checked_free(char *);
scalar_t__ fileExists(char *);
int /*<<< orphan*/ getCurrentLevelDir();
char *getPath2(int /*<<< orphan*/, char *);
char *getLevelSetInfoFilename() {
  static char *filename = NULL;
  char *basenames[] = {"README",     "README.TXT", "README.txt", "Readme",
                       "Readme.txt", "readme",     "readme.txt", NULL};
  int i;
  for (i = 0; basenames[i] != NULL; i++) {
    checked_free(filename);
    filename = getPath2(getCurrentLevelDir(), basenames[i]);
    if (fileExists(filename))
      return filename;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<getLevelSetInfoFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x50(%rbp),%rdi
lea    0x2c7d(%rip),%rsi
mov    $0x40,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
je     11e7 <getLevelSetInfoFilename+0x97>
mov    0x2ec5(%rip),%rdi
call   1060 <checked_free@plt>
mov    $0x0,%al
call   1070 <getCurrentLevelDir@plt>
mov    %eax,%edi
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1040 <getPath2@plt>
mov    %rax,0x2ea2(%rip)
mov    0x2e9b(%rip),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%rax
je     11d4 <getLevelSetInfoFilename+0x84>
mov    0x2e85(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ef <getLevelSetInfoFilename+0x9f>
jmp    11d9 <getLevelSetInfoFilename+0x89>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1174 <getLevelSetInfoFilename+0x24>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLevelSetInfoFilename>:
push   %rbx
mov    0x2f00(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xea5(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2edf(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2ec7(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xe73(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2ea6(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2e8e(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xe45(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2e6d(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2e55(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xe17(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2e34(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2e1c(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xde5(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2dfb(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2de7(%rip),%rdi
call   1050 <checked_free@plt>
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xdbb(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2dc6(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
jne    12c6 <getLevelSetInfoFilename+0x186>
mov    0x2db2(%rip),%rdi
call   1050 <checked_free@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <getCurrentLevelDir@plt>
lea    0xd8b(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2d8f(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
test   %rax,%rax
je     12cd <getLevelSetInfoFilename+0x18d>
mov    0x2d7b(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@getLevelSetInfoFilename.filename = internal global i8* null
@.str = [7 x i8] c"README\00"
@.str.1 = [11 x i8] c"README.TXT\00"
@.str.2 = [11 x i8] c"README.txt\00"
@.str.3 = [7 x i8] c"Readme\00"
@.str.4 = [11 x i8] c"Readme.txt\00"
@.str.5 = [7 x i8] c"readme\00"
@.str.6 = [11 x i8] c"readme.txt\00"
@__const.getLevelSetInfoFilename.basenames = [8 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i32 0, i32 0), i8* null]
define i8* @getLevelSetInfoFilename() {
%1 = alloca i8*
%2 = alloca [8 x i8*]
%3 = alloca i32
%4 = bitcast [8 x i8*]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %26, %0
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %7
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %29
11: ; preds = %5
%12 = load i8*, i8** @getLevelSetInfoFilename.filename
%13 = call i32 @checked_free(i8* %12)
%14 = call i32 (...) @getCurrentLevelDir()
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i8* @getPath2(i32 %14, i8* %18)
store i8* %19, i8** @getLevelSetInfoFilename.filename
%20 = load i8*, i8** @getLevelSetInfoFilename.filename
%21 = call i64 @fileExists(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %11
%24 = load i8*, i8** @getLevelSetInfoFilename.filename
store i8* %24, i8** %1
br label %30
25: ; preds = %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %5
29: ; preds = %5
store i8* null, i8** %1
br label %30
30: ; preds = %29, %23
%31 = load i8*, i8** %1
ret i8* %31
}

LLVM IR (-O2):
@getLevelSetInfoFilename.filename = internal unnamed_addr global i8* null
@.str = [7 x i8] c"README\00"
@.str.1 = [11 x i8] c"README.TXT\00"
@.str.2 = [11 x i8] c"README.txt\00"
@.str.3 = [7 x i8] c"Readme\00"
@.str.4 = [11 x i8] c"Readme.txt\00"
@.str.5 = [7 x i8] c"readme\00"
@.str.6 = [11 x i8] c"readme.txt\00"
define i8* @getLevelSetInfoFilename() {
%1 = load i8*, i8** @getLevelSetInfoFilename.filename
%2 = tail call i32 @checked_free(i8* %1)
%3 = tail call i32 (...) @getCurrentLevelDir()
%4 = tail call i8* @getPath2(i32 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** @getLevelSetInfoFilename.filename
%5 = tail call i64 @fileExists(i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %49
7: ; preds = %0
%8 = load i8*, i8** @getLevelSetInfoFilename.filename
%9 = tail call i32 @checked_free(i8* %8)
%10 = tail call i32 (...) @getCurrentLevelDir()
%11 = tail call i8* @getPath2(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** @getLevelSetInfoFilename.filename
%12 = tail call i64 @fileExists(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %7
%15 = load i8*, i8** @getLevelSetInfoFilename.filename
%16 = tail call i32 @checked_free(i8* %15)
%17 = tail call i32 (...) @getCurrentLevelDir()
%18 = tail call i8* @getPath2(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i8* %18, i8** @getLevelSetInfoFilename.filename
%19 = tail call i64 @fileExists(i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %49
21: ; preds = %14
%22 = load i8*, i8** @getLevelSetInfoFilename.filename
%23 = tail call i32 @checked_free(i8* %22)
%24 = tail call i32 (...) @getCurrentLevelDir()
%25 = tail call i8* @getPath2(i32 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i8* %25, i8** @getLevelSetInfoFilename.filename
%26 = tail call i64 @fileExists(i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %49
28: ; preds = %21
%29 = load i8*, i8** @getLevelSetInfoFilename.filename
%30 = tail call i32 @checked_free(i8* %29)
%31 = tail call i32 (...) @getCurrentLevelDir()
%32 = tail call i8* @getPath2(i32 %31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i8* %32, i8** @getLevelSetInfoFilename.filename
%33 = tail call i64 @fileExists(i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %49
35: ; preds = %28
%36 = load i8*, i8** @getLevelSetInfoFilename.filename
%37 = tail call i32 @checked_free(i8* %36)
%38 = tail call i32 (...) @getCurrentLevelDir()
%39 = tail call i8* @getPath2(i32 %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i8* %39, i8** @getLevelSetInfoFilename.filename
%40 = tail call i64 @fileExists(i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %35
%43 = load i8*, i8** @getLevelSetInfoFilename.filename
%44 = tail call i32 @checked_free(i8* %43)
%45 = tail call i32 (...) @getCurrentLevelDir()
%46 = tail call i8* @getPath2(i32 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
store i8* %46, i8** @getLevelSetInfoFilename.filename
%47 = tail call i64 @fileExists(i8* %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %42, %35, %28, %21, %14, %7, %0
%50 = load i8*, i8** @getLevelSetInfoFilename.filename
br label %51
51: ; preds = %42, %49
%52 = phi i8* [ %50, %49 ], [ null, %42 ]
ret i8* %52
}