#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 *getCommonDataDir();
char *getPath2(char *, char *);
char *getPath3(char *, char *, char *);
char *getScoreDir(char *level_subdir) {
  static char *score_dir = NULL;
  char *data_dir = getCommonDataDir();
  char *score_subdir = "scores";
  checked_free(score_dir);
  if (level_subdir != NULL)
    score_dir = getPath3(data_dir, score_subdir, level_subdir);
  else
    score_dir = getPath2(data_dir, score_subdir);
  return score_dir;
}


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

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

LLVM IR (-O0):
@getScoreDir.score_dir = internal global i8* null
@.str = [7 x i8] c"scores\00"
define i8* @getScoreDir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i8* (...) @getCommonDataDir()
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** @getScoreDir.score_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** @getScoreDir.score_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** @getScoreDir.score_dir
br label %19
19: ; preds = %15, %10
%20 = load i8*, i8** @getScoreDir.score_dir
ret i8* %20
}

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