#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 /*<<< orphan*/ strcat(char *, char const *);
char *strdup(char *);
scalar_t__ strlen(char const *);
char *append_file_to_loc(const char *location, const char *path) {
  char buf[strlen(location) + strlen(path) + 2];
  buf[0] = '\0';
  strcat(buf, location);
  strcat(buf, "/");
  strcat(buf, path);
  return strdup(buf);
}


x86 assembly (clang, -O0):
<append_file_to_loc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,%rdx
lea    0x2(%rcx,%rdx,1),%rax
mov    %rsp,%rsi
mov    %rsi,-0x18(%rbp)
lea    0x11(%rcx,%rdx,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
movb   $0x0,(%rdi)
mov    -0x8(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1050 <strdup@plt>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_file_to_loc>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %rbx,%rax
add    $0x11,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rcx
mov    %rcx,%rbx
sub    %rax,%rbx
neg    %rax
mov    %rbx,%rsp
movb   $0x0,(%rcx,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strdup@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @append_file_to_loc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %8, %10
%12 = add nsw i64 %11, 2
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = alloca i8, i64 %12
store i64 %12, i64* %6
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 0, i8* %15
%16 = load i8*, i8** %3
%17 = call i32 @strcat(i8* %14, i8* %16)
%18 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = call i32 @strcat(i8* %14, i8* %19)
%21 = call i8* @strdup(i8* %14)
%22 = load i8*, i8** %5
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define noalias i8* @append_file_to_loc(i8* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 2
%6 = add i64 %5, %4
%7 = alloca i8, i64 %6
store i8 0, i8* %7
%8 = call i32 @strcat(i8* %7, i8* %0)
%9 = call i32 @strcat(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strcat(i8* %7, i8* %1)
%11 = call i8* @strdup(i8* %7)
ret i8* %11
}