#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 *);
char *getPath2(char *, char *);
char *getPath3(char *, char *, char *);
char *getUserGameDataDir();
char *getLevelSetupDir(char *level_subdir) {
  static char *levelsetup_dir = NULL;
  char *data_dir = getUserGameDataDir();
  char *levelsetup_subdir = "levelsetup";
  checked_free(levelsetup_dir);
  if (level_subdir != NULL)
    levelsetup_dir = getPath3(data_dir, levelsetup_subdir, level_subdir);
  else
    levelsetup_dir = getPath2(data_dir, levelsetup_subdir);
  return levelsetup_dir;
}


x86 assembly (clang, -O0):
<getLevelSetupDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getUserGameDataDir@plt>
mov    %rax,-0x10(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2edf(%rip),%rdi
call   1050 <checked_free@plt>
cmpq   $0x0,-0x8(%rbp)
je     1196 <getLevelSetupDir+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <getPath3@plt>
mov    %rax,0x2eb7(%rip)
jmp    11aa <getLevelSetupDir+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <getPath2@plt>
mov    %rax,0x2e9e(%rip)
mov    0x2e97(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLevelSetupDir>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getUserGameDataDir@plt>
mov    %rax,%r14
mov    0x2ef0(%rip),%rdi
call   1050 <checked_free@plt>
lea    0xe9c(%rip),%rsi
mov    %r14,%rdi
test   %rbx,%rbx
je     1176 <getLevelSetupDir+0x36>
mov    %rbx,%rdx
call   1060 <getPath3@plt>
jmp    117b <getLevelSetupDir+0x3b>
call   1040 <getPath2@plt>
mov    %rax,0x2ec6(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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