#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 */
scalar_t__ asprintf(char **, char *, char const *, char const *);
char *getenv(char *);
char *get_config_name(const char *part) {
  char *name;
  const char *home = getenv("HOME");
  if (home == NULL)
    return NULL;
  if (asprintf(&name, "%s/.japlay/%s", home, part) < 0)
    return NULL;
  return name;
}


x86 assembly (clang, -O0):
<get_config_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1154 <get_config_name+0x34>
movq   $0x0,-0x8(%rbp)
jmp    118b <get_config_name+0x6b>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x18(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <asprintf@plt>
cmp    $0x0,%rax
jge    1183 <get_config_name+0x63>
movq   $0x0,-0x8(%rbp)
jmp    118b <get_config_name+0x6b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_config_name>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     115c <get_config_name+0x3c>
lea    0xec5(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %rax,%rdx
mov    %rbx,%rcx
call   1040 <asprintf@plt>
test   %rax,%rax
js     115c <get_config_name+0x3c>
mov    0x8(%rsp),%rax
jmp    115e <get_config_name+0x3e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [14 x i8] c"%s/.japlay/%s\00"
define i8* @get_config_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* null, i8** %2
br label %18
10: ; preds = %1
%11 = load i8*, i8** %5
%12 = load i8*, i8** %3
%13 = call i64 @asprintf(i8** %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i8* null, i8** %2
br label %18
16: ; preds = %10
%17 = load i8*, i8** %4
store i8* %17, i8** %2
br label %18
18: ; preds = %16, %15, %9
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [14 x i8] c"%s/.japlay/%s\00"
define i8* @get_config_name(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = call i64 @asprintf(i8** %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %0)
%8 = icmp slt i64 %7, 0
%9 = load i8*, i8** %2
%10 = select i1 %8, i8* null, i8* %9
br label %11
11: ; preds = %6, %1
%12 = phi i8* [ null, %1 ], [ %10, %6 ]
ret i8* %12
}