#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();
char *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 = 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 %15
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 i8* @malloc(i64 %8)
store i8* %9, i8** @get_ini_path.path
%10 = load i8*, i8** @get_ini_path.path
%11 = call i8* (...) @get_currentpath()
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = load i8*, i8** @get_ini_path.path
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %3, %0
%16 = load i8*, i8** @get_ini_path.path
ret i8* %16
}

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 %13
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 i8* @malloc(i64 %6)
store i8* %7, i8** @get_ini_path.path
%8 = tail call i8* (...) @get_currentpath()
%9 = tail call i32 @strcpy(i8* %7, i8* %8)
%10 = load i8*, i8** @get_ini_path.path
%11 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** @get_ini_path.path
br label %13
13: ; preds = %3, %0
%14 = phi i8* [ %12, %3 ], [ %1, %0 ]
ret i8* %14
}