#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 *);
int /*<<< orphan*/ getSetupDir();
char *getEditorSetupFilename() {
  static char *filename = NULL;
  checked_free(filename);
  filename = getPath2(getCurrentLevelDir(), "editorsetup.conf");
  if (fileExists(filename))
    return filename;
  checked_free(filename);
  filename = getPath2(getSetupDir(), "editorsetup.conf");
  return filename;
}


x86 assembly (clang, -O0):
<getEditorSetupFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ef1(%rip),%rdi
call   1060 <checked_free@plt>
mov    $0x0,%al
call   1070 <getCurrentLevelDir@plt>
mov    %eax,%edi
lea    0xe8c(%rip),%rsi
call   1040 <getPath2@plt>
mov    %rax,0x2ed0(%rip)
mov    0x2ec9(%rip),%rdi
call   1030 <fileExists@plt>
cmp    $0x0,%rax
je     11a6 <getEditorSetupFilename+0x56>
mov    0x2eb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <getEditorSetupFilename+0x89>
mov    0x2ea3(%rip),%rdi
call   1060 <checked_free@plt>
mov    $0x0,%al
call   1050 <getSetupDir@plt>
mov    %eax,%edi
lea    0xe3e(%rip),%rsi
call   1040 <getPath2@plt>
mov    %rax,0x2e82(%rip)
mov    0x2e7b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getEditorSetupFilename>:
push   %rax
mov    0x2ef8(%rip),%rdi
call   1060 <checked_free@plt>
xor    %eax,%eax
call   1070 <getCurrentLevelDir@plt>
lea    0xe95(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2ed7(%rip)
mov    %rax,%rdi
call   1030 <fileExists@plt>
mov    %rax,%rcx
mov    0x2ec5(%rip),%rax
test   %rcx,%rcx
je     1192 <getEditorSetupFilename+0x42>
pop    %rcx
ret
mov    %rax,%rdi
call   1060 <checked_free@plt>
xor    %eax,%eax
call   1050 <getSetupDir@plt>
lea    0xe58(%rip),%rsi
mov    %eax,%edi
call   1040 <getPath2@plt>
mov    %rax,0x2e9a(%rip)
pop    %rcx
ret

LLVM IR (-O0):
@getEditorSetupFilename.filename = internal global i8* null
@.str = [17 x i8] c"editorsetup.conf\00"
define i8* @getEditorSetupFilename() {
%1 = alloca i8*
%2 = load i8*, i8** @getEditorSetupFilename.filename
%3 = call i32 @checked_free(i8* %2)
%4 = call i32 (...) @getCurrentLevelDir()
%5 = call i8* @getPath2(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** @getEditorSetupFilename.filename
%6 = load i8*, i8** @getEditorSetupFilename.filename
%7 = call i64 @fileExists(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = load i8*, i8** @getEditorSetupFilename.filename
store i8* %10, i8** %1
br label %17
11: ; preds = %0
%12 = load i8*, i8** @getEditorSetupFilename.filename
%13 = call i32 @checked_free(i8* %12)
%14 = call i32 (...) @getSetupDir()
%15 = call i8* @getPath2(i32 %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** @getEditorSetupFilename.filename
%16 = load i8*, i8** @getEditorSetupFilename.filename
store i8* %16, i8** %1
br label %17
17: ; preds = %11, %9
%18 = load i8*, i8** %1
ret i8* %18
}

LLVM IR (-O2):
@getEditorSetupFilename.filename = internal unnamed_addr global i8* null
@.str = [17 x i8] c"editorsetup.conf\00"
define i8* @getEditorSetupFilename() {
%1 = load i8*, i8** @getEditorSetupFilename.filename
%2 = tail call i32 @checked_free(i8* %1)
%3 = tail call i32 (...) @getCurrentLevelDir()
%4 = tail call i8* @getPath2(i32 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** @getEditorSetupFilename.filename
%5 = tail call i64 @fileExists(i8* %4)
%6 = icmp eq i64 %5, 0
%7 = load i8*, i8** @getEditorSetupFilename.filename
br i1 %6, label %8, label %12
8: ; preds = %0
%9 = tail call i32 @checked_free(i8* %7)
%10 = tail call i32 (...) @getSetupDir()
%11 = tail call i8* @getPath2(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** @getEditorSetupFilename.filename
br label %12
12: ; preds = %0, %8
%13 = phi i8* [ %11, %8 ], [ %7, %0 ]
ret i8* %13
}