#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 *);
char *malloc(scalar_t__);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *confUserFilename(char *name) {
  static char *filename;
  char *home = getenv("HOME");
  if (home == NULL) {
    home = ".";
  }
  filename = malloc(strlen(home) + 2 + strlen(name) + 1);
  strcpy(filename, home);
  strcat(filename, "/.");
  strcat(filename, name);
  return (filename);
}


x86 assembly (clang, -O0):
<confUserFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <confUserFilename+0x32>
lea    0xe88(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <malloc@plt>
mov    %rax,0x2e9d(%rip)
mov    0x2e96(%rip),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
mov    0x2e86(%rip),%rdi
lea    0xe34(%rip),%rsi
call   1070 <strcat@plt>
mov    0x2e73(%rip),%rdi
mov    -0x8(%rbp),%rsi
call   1070 <strcat@plt>
mov    0x2e63(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<confUserFilename>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xe98(%rip),%rbx
cmovne %rax,%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%r15,%rax,1),%rdi
add    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,0x2eb7(%rip)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    0x2ea5(%rip),%rdi
lea    0xe53(%rip),%rsi
call   1070 <strcat@plt>
mov    0x2e92(%rip),%rdi
mov    %r14,%rsi
call   1070 <strcat@plt>
mov    0x2e83(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@confUserFilename.filename = internal global i8* null
@.str = [5 x i8] c"HOME\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"/.\00"
define i8* @confUserFilename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %8
8: ; preds = %7, %1
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 2
%12 = load i8*, i8** %2
%13 = call i64 @strlen(i8* %12)
%14 = add nsw i64 %11, %13
%15 = add nsw i64 %14, 1
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** @confUserFilename.filename
%17 = load i8*, i8** @confUserFilename.filename
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** @confUserFilename.filename
%21 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%22 = load i8*, i8** @confUserFilename.filename
%23 = load i8*, i8** %2
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** @confUserFilename.filename
ret i8* %25
}

LLVM IR (-O2):
@confUserFilename.filename = internal unnamed_addr global i8* null
@.str = [5 x i8] c"HOME\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [3 x i8] c"/.\00"
define i8* @confUserFilename(i8* %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %2
%5 = tail call i64 @strlen(i8* dereferenceable(1) %4)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add i64 %5, 3
%8 = add i64 %7, %6
%9 = tail call i8* @malloc(i64 %8)
store i8* %9, i8** @confUserFilename.filename
%10 = tail call i32 @strcpy(i8* %9, i8* %4)
%11 = load i8*, i8** @confUserFilename.filename
%12 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** @confUserFilename.filename
%14 = tail call i32 @strcat(i8* %13, i8* %0)
%15 = load i8*, i8** @confUserFilename.filename
ret i8* %15
}