#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*/ snprintf(char *, int, char *, char const *, char const *);
const char *file_generic(const char *suffix) {
  static char fname[256];
  const char *home = getenv("HOME");
  if (!home)
    home = "";
  snprintf(fname, sizeof fname, "%s/.uvi%s", home, suffix);
  return fname;
}


x86 assembly (clang, -O0):
<file_generic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1152 <file_generic+0x32>
lea    0xeb6(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0x2edf(%rip),%rdi
mov    $0x100,%esi
lea    0xe98(%rip),%rdx
call   1040 <snprintf@plt>
lea    0x2ec7(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_generic>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xec7(%rip),%rcx
cmovne %rax,%rcx
lea    0x2ef8(%rip),%r14
lea    0xeb6(%rip),%rdx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %rbx,%r8
call   1040 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@file_generic.fname = internal global [256 x i8] zeroinitializer
@.str = [5 x i8] c"HOME\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"%s/.uvi%s\00"
define i8* @file_generic(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 ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %8
8: ; preds = %7, %1
%9 = load i8*, i8** %3
%10 = load i8*, i8** %2
%11 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @file_generic.fname, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @file_generic.fname, i64 0, i64 0)
}

LLVM IR (-O2):
@file_generic.fname = internal global [256 x i8] zeroinitializer
@.str = [5 x i8] c"HOME\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"%s/.uvi%s\00"
define i8* @file_generic(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 ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %2
%5 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @file_generic.fname, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %0)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @file_generic.fname, i64 0, i64 0)
}