#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*/ sprintf(char *, char *, char *, char *);
char *rcname(char *progname) {
  static char buf[256], *s;
  s = getenv("HOME");
  sprintf(buf, "%s/.%src", s ? s : "", progname);
  return buf;
}


x86 assembly (clang, -O0):
<rcname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3001(%rip)
cmpq   $0x0,0x2ff9(%rip)
je     115d <rcname+0x3d>
mov    0x2fec(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    116d <rcname+0x4d>
lea    0xea0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    116d <rcname+0x4d>
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0x2ec4(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2eb1(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rcname>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,0x3006(%rip)
test   %rax,%rax
lea    0xec0(%rip),%rdx
cmovne %rax,%rdx
lea    0x2ef1(%rip),%r14
lea    0xeaf(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rcx
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@rcname.buf = internal global [256 x i8] zeroinitializer
@rcname.s = internal global i8* null
@.str = [5 x i8] c"HOME\00"
@.str.1 = [9 x i8] c"%s/.%src\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @rcname(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** @rcname.s
%4 = load i8*, i8** @rcname.s
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i8*, i8** @rcname.s
br label %9
8: ; preds = %1
br label %9
9: ; preds = %8, %6
%10 = phi i8* [ %7, %6 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %8 ]
%11 = load i8*, i8** %2
%12 = call i32 @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @rcname.buf, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @rcname.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@rcname.buf = internal global [256 x i8] zeroinitializer
@rcname.s = internal unnamed_addr global i8* null
@.str = [5 x i8] c"HOME\00"
@.str.1 = [9 x i8] c"%s/.%src\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @rcname(i8* %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** @rcname.s
%3 = icmp eq i8* %2, null
%4 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %2
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @rcname.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %0)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @rcname.buf, i64 0, i64 0)
}