#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 *getenv(char *);
int /*<<< orphan*/ strcat(char *, char *);
void conf_dir(char *buffer) {
  char *dir;
  char *subdir = "/";
  dir = getenv("XDG_CONFIG_HOME");
  if (dir != NULL) {
    subdir = "/terminibbles/";
  } else {
    dir = getenv("HOME");
    if (dir != NULL) {
      subdir = "/.config/terminibbles/";
    } else {
      dir = "./scores/";
    }
  }
  strcat(buffer, dir);
  strcat(buffer, subdir);
}


x86 assembly (clang, -O0):
<conf_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xef2(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1162 <conf_dir+0x42>
lea    0xebf(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    119d <conf_dir+0x7d>
lea    0xea2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118d <conf_dir+0x6d>
lea    0xe8c(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1198 <conf_dir+0x78>
lea    0xe93(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119d <conf_dir+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_dir>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xed2(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1141 <conf_dir+0x21>
lea    0xed9(%rip),%rbx
jmp    1170 <conf_dir+0x50>
lea    0xec3(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
test   %rax,%rax
lea    0xecd(%rip),%rax
cmovne %rcx,%rax
lea    0xec0(%rip),%rcx
lea    0xea4(%rip),%rbx
cmove  %rcx,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strcat@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.2 = [15 x i8] c"/terminibbles/\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [23 x i8] c"/.config/terminibbles/\00"
@.str.5 = [10 x i8] c"./scores/\00"
define void @conf_dir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %16
9: ; preds = %1
%10 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %9
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %15
14: ; preds = %9
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %15
15: ; preds = %14, %13
br label %16
16: ; preds = %15, %8
%17 = load i8*, i8** %2
%18 = load i8*, i8** %3
%19 = call i32 @strcat(i8* %17, i8* %18)
%20 = load i8*, i8** %2
%21 = load i8*, i8** %4
%22 = call i32 @strcat(i8* %20, i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.2 = [15 x i8] c"/terminibbles/\00"
@.str.3 = [5 x i8] c"HOME\00"
@.str.4 = [23 x i8] c"/.config/terminibbles/\00"
@.str.5 = [10 x i8] c"./scores/\00"
define void @conf_dir(i8* %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %5
%8 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0)
br label %9
9: ; preds = %4, %1
%10 = phi i8* [ %2, %1 ], [ %7, %4 ]
%11 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %1 ], [ %8, %4 ]
%12 = tail call i32 @strcat(i8* %0, i8* %10)
%13 = tail call i32 @strcat(i8* %0, i8* %11)
ret void
}