#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*/ test_join(char *, char *, char *);
void test_path_join(void) {
  test_join("/a/b", "c/d", "/a/b/c/d");
  test_join("/a/b/", "c/d", "/a/b/c/d");
  test_join("/a/b/", "/c/d", "/a/b/c/d");
  test_join("", "foo", "foo");
  test_join("", "", "");
}


x86 assembly (clang, -O0):
<test_path_join>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee8(%rip),%rsi
lea    0xedc(%rip),%rdx
call   1030 <test_join@plt>
lea    0xed9(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xec2(%rip),%rdx
call   1030 <test_join@plt>
lea    0xebf(%rip),%rdi
lea    0xeb3(%rip),%rsi
lea    0xea8(%rip),%rdx
call   1030 <test_join@plt>
lea    0xeaa(%rip),%rdi
lea    0xea4(%rip),%rdx
mov    %rdx,%rsi
call   1030 <test_join@plt>
lea    0xe94(%rip),%rdx
mov    %rdx,%rdi
mov    %rdx,%rsi
call   1030 <test_join@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_path_join>:
push   %r15
push   %r14
push   %rbx
lea    0xee4(%rip),%rdi
lea    0xee7(%rip),%r14
lea    0xedb(%rip),%rbx
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <test_join@plt>
lea    0xed2(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <test_join@plt>
lea    0xeb8(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1030 <test_join@plt>
lea    0xeb0(%rip),%rbx
lea    0xeaa(%rip),%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
call   1030 <test_join@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <test_join@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"/a/b\00"
@.str.1 = [4 x i8] c"c/d\00"
@.str.2 = [9 x i8] c"/a/b/c/d\00"
@.str.3 = [6 x i8] c"/a/b/\00"
@.str.4 = [5 x i8] c"/c/d\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [4 x i8] c"foo\00"
define void @test_path_join() {
%1 = call i32 @test_join(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%2 = call i32 @test_join(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%3 = call i32 @test_join(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 @test_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = call i32 @test_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"/a/b\00"
@.str.1 = [4 x i8] c"c/d\00"
@.str.2 = [9 x i8] c"/a/b/c/d\00"
@.str.3 = [6 x i8] c"/a/b/\00"
@.str.4 = [5 x i8] c"/c/d\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [4 x i8] c"foo\00"
define void @test_path_join() {
%1 = tail call i32 @test_join(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @test_join(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @test_join(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @test_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%5 = tail call i32 @test_join(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
ret void
}