#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(size_t);
size_t strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
char *join(const char *a, const char *b) {
  size_t lena;
  size_t lenb;
  char *out;
  lena = strlen(a);
  lenb = strlen(b);
  out = malloc(lena + 1 + lenb + 1);
  strncpy(out, a, lena);
  strncpy(out + lena, "/", 1);
  strncpy(out + lena + 1, b, lenb);
  out[lena + 1 + lenb] = '\0';
  return out;
}


x86 assembly (clang, -O0):
<join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
add    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rdi
add    -0x18(%rbp),%rdi
lea    0xe6d(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
add    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
lea    (%rax,%r13,1),%rbp
lea    (%rax,%r13,1),%rdi
add    $0x2,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1030 <strncpy@plt>
lea    (%rbx,%r13,1),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncpy@plt>
lea    (%rbx,%r13,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <strncpy@plt>
movb   $0x0,0x1(%rbx,%rbp,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @join(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, 1
%6 = add i64 %5, %4
%7 = add i64 %6, 1
%8 = tail call i8* @malloc(i64 %7)
%9 = tail call i32 @strncpy(i8* %8, i8* %0, i64 %3)
%10 = getelementptr inbounds i8, i8* %8, i64 %3
%11 = tail call i32 @strncpy(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64 1)
%12 = getelementptr inbounds i8, i8* %10, i64 1
%13 = tail call i32 @strncpy(i8* %12, i8* %1, i64 %4)
%14 = getelementptr inbounds i8, i8* %8, i64 %6
store i8 0, i8* %14
ret i8* %8
}