#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 *getUserLevelDir(char *level_subdir) {
  static char *userlevel_dir = NULL;
  char *data_dir = getUserGameDataDir();
  char *userlevel_subdir = "levels";
  checked_free(userlevel_dir);
  if (level_subdir != NULL)
    userlevel_dir = getPath3(data_dir, userlevel_subdir, level_subdir);
  else
    userlevel_dir = getPath2(data_dir, userlevel_subdir);
  return userlevel_dir;
}


x86 assembly (clang, -O0):
<getUserLevelDir>:
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 <getUserLevelDir+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <getPath3@plt>
mov    %rax,0x2eb7(%rip)
jmp    11aa <getUserLevelDir+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):
<getUserLevelDir>:
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 <getUserLevelDir+0x36>
mov    %rbx,%rdx
call   1060 <getPath3@plt>
jmp    117b <getUserLevelDir+0x3b>
call   1040 <getPath2@plt>
mov    %rax,0x2ec6(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@getUserLevelDir.userlevel_dir = internal global i8* null
@.str = [7 x i8] c"levels\00"
define i8* @getUserLevelDir(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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
%6 = load i8*, i8** @getUserLevelDir.userlevel_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** @getUserLevelDir.userlevel_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** @getUserLevelDir.userlevel_dir
br label %19
19: ; preds = %15, %10
%20 = load i8*, i8** @getUserLevelDir.userlevel_dir
ret i8* %20
}

LLVM IR (-O2):
@getUserLevelDir.userlevel_dir = internal unnamed_addr global i8* null
@.str = [7 x i8] c"levels\00"
define i8* @getUserLevelDir(i8* %0) {
%2 = tail call i8* (...) @getUserGameDataDir()
%3 = load i8*, i8** @getUserLevelDir.userlevel_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 ([7 x i8], [7 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 ([7 x i8], [7 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** @getUserLevelDir.userlevel_dir
ret i8* %11
}