#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 *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *getPath(char *root, char *ep) {
  char *newRoot;
  int rootSize, fileNameSize;
  rootSize = strlen(root);
  fileNameSize = strlen(ep);
  newRoot = malloc(rootSize + fileNameSize + 2);
  memset(newRoot, '\0', rootSize + fileNameSize + 2);
  strcat(newRoot, root);
  strcat(newRoot, ep);
  strcat(newRoot, "/");
  return newRoot;
}


x86 assembly (clang, -O0):
<getPath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
add    -0x20(%rbp),%edx
add    $0x2,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPath>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x2,%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @getPath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = add nsw i32 %12, %13
%15 = add nsw i32 %14, 2
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** %5
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = add nsw i32 %18, %19
%21 = add nsw i32 %20, 2
%22 = call i32 @memset(i8* %17, i8 signext 0, i32 %21)
%23 = load i8*, i8** %5
%24 = load i8*, i8** %3
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = load i8*, i8** %4
%28 = call i32 @strcat(i8* %26, i8* %27)
%29 = load i8*, i8** %5
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%31 = load i8*, i8** %5
ret i8* %31
}

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