#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 */
int PATH_MAX;
int /*<<< orphan*/ getenv(char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strjoin(char *, char, char *, int const);
char *xstrdup(char *);
char *makefullpath(char *left, char *right) {
  char joinbuf[PATH_MAX];
  const int max = PATH_MAX;
  strcpy(joinbuf, getenv("HOME"));
  strjoin(joinbuf, '/', left, max);
  strjoin(joinbuf, '/', right, max);
  return xstrdup(joinbuf);
}


x86 assembly (clang, -O0):
<makefullpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
lea    0xe71(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x2f,%esi
call   1060 <strjoin@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    $0x2f,%esi
call   1060 <strjoin@plt>
mov    -0x30(%rbp),%rdi
call   1050 <xstrdup@plt>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makefullpath>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e98(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe8a(%rip),%rdi
call   1030 <getenv@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    %r12,%rdx
mov    %r15d,%ecx
call   1060 <strjoin@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
call   1060 <strjoin@plt>
mov    %rbx,%rdi
call   1050 <xstrdup@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"HOME\00"
define i8* @makefullpath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i32, i32* @PATH_MAX
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i8, i64 %9
store i64 %9, i64* %6
%12 = load i32, i32* @PATH_MAX
store i32 %12, i32* %7
%13 = call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @strcpy(i8* %11, i32 %13)
%15 = load i8*, i8** %3
%16 = load i32, i32* %7
%17 = call i32 @strjoin(i8* %11, i8 signext 47, i8* %15, i32 %16)
%18 = load i8*, i8** %4
%19 = load i32, i32* %7
%20 = call i32 @strjoin(i8* %11, i8 signext 47, i8* %18, i32 %19)
%21 = call i8* @xstrdup(i8* %11)
%22 = load i8*, i8** %5
ret i8* %21
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"HOME\00"
define i8* @makefullpath(i8* %0, i8* %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strcpy(i8* %5, i32 %6)
%8 = call i32 @strjoin(i8* %5, i8 signext 47, i8* %0, i32 %3)
%9 = call i32 @strjoin(i8* %5, i8 signext 47, i8* %1, i32 %3)
%10 = call i8* @xstrdup(i8* %5)
ret i8* %10
}