#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*/ assert(int);
int /*<<< orphan*/ join_paths(char *, char const *, char const *);
scalar_t__ strcmp(char *, char *);
void test_join_paths(void) {
  char result_path1[100];
  char result_path2[100];
  char result_path3[100];
  const char *path1 = ".";
  const char *path2 = "src";
  const char *path3 = "module";
  join_paths(result_path1, path1, path2);
  join_paths(result_path2, result_path1, path3);
  join_paths(result_path3, path2, path3);
  assert(0 == strcmp(result_path1, "./src"));
  assert(0 == strcmp(result_path2, "./src/module"));
  assert(0 == strcmp(result_path3, "src/module"));
}


x86 assembly (clang, -O0):
<test_join_paths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
lea    0xebe(%rip),%rax
mov    %rax,-0x158(%rbp)
lea    0xeb4(%rip),%rax
mov    %rax,-0x160(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x168(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x158(%rbp),%rsi
mov    -0x160(%rbp),%rdx
call   1050 <join_paths@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    -0x168(%rbp),%rdx
call   1050 <join_paths@plt>
lea    -0x150(%rbp),%rdi
mov    -0x160(%rbp),%rsi
mov    -0x168(%rbp),%rdx
call   1050 <join_paths@plt>
lea    -0x70(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x150(%rbp),%rdi
lea    0xe02(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_join_paths>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x150,%rsp
lea    0xeb9(%rip),%rsi
lea    0xeb6(%rip),%r12
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
call   1050 <join_paths@plt>
lea    0xea6(%rip),%r13
lea    0x70(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <join_paths@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <join_paths@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe58(%rip),%rsi
mov    %r15,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xe3d(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
add    $0x150,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [4 x i8] c"src\00"
@.str.2 = [7 x i8] c"module\00"
@.str.3 = [6 x i8] c"./src\00"
@.str.4 = [13 x i8] c"./src/module\00"
@.str.5 = [11 x i8] c"src/module\00"
define void @test_join_paths() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 @join_paths(i8* %7, i8* %8, i8* %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = call i32 @join_paths(i8* %11, i8* %12, i8* %13)
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = call i32 @join_paths(i8* %15, i8* %16, i8* %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 0, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 0, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i64 0, %30
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [4 x i8] c"src\00"
@.str.2 = [7 x i8] c"module\00"
@.str.3 = [6 x i8] c"./src\00"
@.str.4 = [13 x i8] c"./src/module\00"
@.str.5 = [11 x i8] c"src/module\00"
define void @test_join_paths() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = call i32 @join_paths(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @join_paths(i8* %5, i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @join_paths(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%10 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
ret void
}