#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__ getenv(char *);
char *s_asprintf(char *, scalar_t__);
char *sosc_get_config_directory() {
  char *dir;
  if (getenv("XDG_CONFIG_HOME"))
    dir = s_asprintf("%s/serialosc", getenv("XDG_CONFIG_HOME"));
  else
    dir = s_asprintf("%s/.config/serialosc", getenv("HOME"));
  return dir;
}


x86 assembly (clang, -O0):
<sosc_get_config_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     1162 <sosc_get_config_directory+0x42>
lea    0xebb(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xebc(%rip),%rdi
call   1040 <s_asprintf@plt>
mov    %rax,-0x8(%rbp)
jmp    1181 <sosc_get_config_directory+0x61>
lea    0xea2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rsi
lea    0xea5(%rip),%rdi
call   1040 <s_asprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sosc_get_config_directory>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     113b <sosc_get_config_directory+0x1b>
lea    0xed7(%rip),%rdi
jmp    114e <sosc_get_config_directory+0x2e>
lea    0xec9(%rip),%rdi
call   1030 <getenv@plt>
lea    0xecf(%rip),%rdi
mov    %rax,%rsi
pop    %rax
jmp    1040 <s_asprintf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.1 = [13 x i8] c"%s/serialosc\00"
@.str.2 = [21 x i8] c"%s/.config/serialosc\00"
@.str.3 = [5 x i8] c"HOME\00"
define i8* @sosc_get_config_directory() {
%1 = alloca i8*
%2 = call i64 @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i64 @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @s_asprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %5)
store i8* %6, i8** %1
br label %10
7: ; preds = %0
%8 = call i64 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%9 = call i8* @s_asprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %8)
store i8* %9, i8** %1
br label %10
10: ; preds = %7, %4
%11 = load i8*, i8** %1
ret i8* %11
}

LLVM IR (-O2):
@.str = [16 x i8] c"XDG_CONFIG_HOME\00"
@.str.1 = [13 x i8] c"%s/serialosc\00"
@.str.2 = [21 x i8] c"%s/.config/serialosc\00"
@.str.3 = [5 x i8] c"HOME\00"
define i8* @sosc_get_config_directory() {
%1 = tail call i64 @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i8* @s_asprintf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %1)
br label %8
5: ; preds = %0
%6 = tail call i64 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i8* @s_asprintf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 %6)
br label %8
8: ; preds = %5, %3
%9 = phi i8* [ %4, %3 ], [ %7, %5 ]
ret i8* %9
}