#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 */
char *get_currentpath();
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *get_ini_path() {
  static char *path = NULL;
  if (path == NULL) {
    path =
        (char *)malloc(strlen(get_currentpath()) + 1 + strlen("mupen64.ini"));
    strcpy(path, get_currentpath());
    strcat(path, "mupen64.ini");
  }
  return path;
}


x86 assembly (clang, -O0):
<get_ini_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpq   $0x0,0x2ef0(%rip)
jne    11cd <get_ini_path+0x7d>
mov    $0x0,%al
call   1060 <get_currentpath@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
lea    0xe7c(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x10(%rbp),%rdi
add    %rax,%rdi
call   1050 <malloc@plt>
mov    %rax,0x2eb4(%rip)
mov    0x2ead(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <get_currentpath@plt>
mov    -0x8(%rbp),%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    0x2e8f(%rip),%rdi
lea    0xe38(%rip),%rsi
call   1070 <strcat@plt>
mov    0x2e7c(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ini_path>:
push   %rbx
mov    0x2ef8(%rip),%rax
test   %rax,%rax
je     115f <get_ini_path+0xf>
pop    %rbx
ret
xor    %eax,%eax
call   1060 <get_currentpath@plt>
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0xc(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,0x2ecf(%rip)
xor    %eax,%eax
call   1060 <get_currentpath@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    0x2eb6(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   1070 <strcat@plt>
mov    0x2ea3(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_ini_path.path = internal global i8* null
@.str = [12 x i8] c"mupen64.ini\00"
define i8* @get_ini_path() {
%1 = load i8*, i8** @get_ini_path.path
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %16
3: ; preds = %0
%4 = call i8* (...) @get_currentpath()
%5 = call i64 @strlen(i8* %4)
%6 = add nsw i64 %5, 1
%7 = call i64 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = add nsw i64 %6, %7
%9 = call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** @get_ini_path.path
%11 = load i8*, i8** @get_ini_path.path
%12 = call i8* (...) @get_currentpath()
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = load i8*, i8** @get_ini_path.path
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %3, %0
%17 = load i8*, i8** @get_ini_path.path
ret i8* %17
}

LLVM IR (-O2):
@get_ini_path.path = internal unnamed_addr global i8* null
@.str = [12 x i8] c"mupen64.ini\00"
define i8* @get_ini_path() {
%1 = load i8*, i8** @get_ini_path.path
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %14
3: ; preds = %0
%4 = tail call i8* (...) @get_currentpath()
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = add nsw i64 %5, 12
%7 = tail call i64 @malloc(i64 %6)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** @get_ini_path.path
%9 = tail call i8* (...) @get_currentpath()
%10 = tail call i32 @strcpy(i8* %8, i8* %9)
%11 = load i8*, i8** @get_ini_path.path
%12 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** @get_ini_path.path
br label %14
14: ; preds = %3, %0
%15 = phi i8* [ %13, %3 ], [ %1, %0 ]
ret i8* %15
}