#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 */
scalar_t__ malloc(int);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *makePath(const char *base, const char *name) {
  int baseLen = strlen(base);
  int nameLen = strlen(name);
  char *res = (char *)malloc(baseLen + nameLen + 2);
  strncpy(res, base, baseLen);
  res[baseLen] = '/';
  strncpy(res + baseLen + 1, name, nameLen);
  res[baseLen + 1 + nameLen] = 0;
  return res;
}


x86 assembly (clang, -O0):
<makePath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
add    -0x18(%rbp),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makePath>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    (%r12,%r13,1),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1030 <strncpy@plt>
movslq %r13d,%rax
movb   $0x2f,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1030 <strncpy@plt>
lea    (%r12,%r13,1),%eax
add    $0x1,%eax
cltq
movb   $0x0,(%rbx,%rax,1)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @makePath(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
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* %5
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = add nsw i32 %12, %13
%15 = add nsw i32 %14, 2
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = load i8*, i8** %3
%20 = load i32, i32* %5
%21 = call i32 @strncpy(i8* %18, i8* %19, i32 %20)
%22 = load i8*, i8** %7
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 47, i8* %25
%26 = load i8*, i8** %7
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8*, i8** %4
%32 = load i32, i32* %6
%33 = call i32 @strncpy(i8* %30, i8* %31, i32 %32)
%34 = load i8*, i8** %7
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = load i32, i32* %6
%38 = add nsw i32 %36, %37
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %34, i64 %39
store i8 0, i8* %40
%41 = load i8*, i8** %7
ret i8* %41
}

LLVM IR (-O2):
define i8* @makePath(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add i32 %4, %3
%6 = add nsw i32 %5, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strncpy(i8* %8, i8* %0, i32 %3)
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8 47, i8* %11
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = tail call i32 @strncpy(i8* %12, i8* %1, i32 %4)
%14 = add i32 %5, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %8, i64 %15
store i8 0, i8* %16
ret i8* %8
}