#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 *calloc(int, int);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
void concatenation(char **temp, char source[], char file[]) {
  int length = 0;
  int length2 = 0;
  while (source[length] != '\0')
    length++;
  while (file[length2] != '\0')
    length2++;
  if (source[length] != '/') {
    *temp = calloc((length + length2 + 1), sizeof(char));
    strncat(*temp, source, strlen(source));
    strncat(*temp, "/", 1);
  } else {
    *temp = calloc((length + length2), sizeof(char));
    strncat(*temp, source, strlen(source));
  }
  strncat(*temp, file, strlen(file));
}


x86 assembly (clang, -O0):
<concatenation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1175 <concatenation+0x45>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1152 <concatenation+0x22>
jmp    117a <concatenation+0x4a>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     119d <concatenation+0x6d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117a <concatenation+0x4a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     1217 <concatenation+0xe7>
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncat@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xdf8(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
jmp    125c <concatenation+0x12c>
mov    -0x1c(%rbp),%edi
add    -0x20(%rbp),%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncat@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncat@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<concatenation>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,(%rbx,%rdi,1)
lea    0x1(%rdi),%rdi
jne    1150 <concatenation+0x20>
add    $0xffffffff,%edi
mov    %r14,%rax
add    $0x1,%edi
cmpb   $0x0,(%rax)
lea    0x1(%rax),%rax
jne    1160 <concatenation+0x30>
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%r12
mov    %rax,(%r15)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <strncat@plt>
mov    (%r15),%rdi
lea    0xe65(%rip),%rsi
mov    $0x1,%edx
call   1040 <strncat@plt>
mov    (%r15),%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <strncat@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @concatenation(i8** %0, i8* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %17, %3
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
br label %9
20: ; preds = %9
br label %21
21: ; preds = %29, %20
%22 = load i8*, i8** %6
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %21
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %21
32: ; preds = %21
%33 = load i8*, i8** %5
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 47
br i1 %39, label %40, label %56
40: ; preds = %32
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = add nsw i32 %41, %42
%44 = add nsw i32 %43, 1
%45 = call i8* @calloc(i32 %44, i32 1)
%46 = load i8**, i8*** %4
store i8* %45, i8** %46
%47 = load i8**, i8*** %4
%48 = load i8*, i8** %47
%49 = load i8*, i8** %5
%50 = load i8*, i8** %5
%51 = call i32 @strlen(i8* %50)
%52 = call i32 @strncat(i8* %48, i8* %49, i32 %51)
%53 = load i8**, i8*** %4
%54 = load i8*, i8** %53
%55 = call i32 @strncat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %68
56: ; preds = %32
%57 = load i32, i32* %7
%58 = load i32, i32* %8
%59 = add nsw i32 %57, %58
%60 = call i8* @calloc(i32 %59, i32 1)
%61 = load i8**, i8*** %4
store i8* %60, i8** %61
%62 = load i8**, i8*** %4
%63 = load i8*, i8** %62
%64 = load i8*, i8** %5
%65 = load i8*, i8** %5
%66 = call i32 @strlen(i8* %65)
%67 = call i32 @strncat(i8* %63, i8* %64, i32 %66)
br label %68
68: ; preds = %56, %40
%69 = load i8**, i8*** %4
%70 = load i8*, i8** %69
%71 = load i8*, i8** %6
%72 = load i8*, i8** %6
%73 = call i32 @strlen(i8* %72)
%74 = call i32 @strncat(i8* %70, i8* %71, i32 %73)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @concatenation(i8** nocapture %0, i8* %1, i8* %2) {
br label %4
4: ; preds = %4, %3
%5 = phi i64 [ %9, %4 ], [ 0, %3 ]
%6 = getelementptr inbounds i8, i8* %1, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = add nuw i64 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4, %10
%11 = phi i64 [ %15, %10 ], [ 0, %4 ]
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
%15 = add nuw i64 %11, 1
br i1 %14, label %16, label %10
16: ; preds = %10
%17 = trunc i64 %11 to i32
%18 = trunc i64 %5 to i32
%19 = add nuw i32 %18, 1
%20 = add i32 %19, %17
%21 = tail call i8* @calloc(i32 %20, i32 1)
store i8* %21, i8** %0
%22 = tail call i32 @strlen(i8* %1)
%23 = tail call i32 @strncat(i8* %21, i8* %1, i32 %22)
%24 = load i8*, i8** %0
%25 = tail call i32 @strncat(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%26 = load i8*, i8** %0
%27 = tail call i32 @strlen(i8* %2)
%28 = tail call i32 @strncat(i8* %26, i8* %2, i32 %27)
ret void
}