void test_slashes(void) {
  const char *buf;
  buf = make_rel_path("/home/a", "/home");
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 32);
  } while (0);
  buf = make_rel_path("/home/a", "/home/");
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 35);
  } while (0);
  buf = make_rel_path("/home/a/", "/home");
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 38);
  } while (0);
  buf = make_rel_path("/home/a/", "/home/");
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 41);
  } while (0);
}


x86 assembly (clang, -O0):
<test_slashes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb8(%rip),%rdi
lea    0xeb9(%rip),%rdx
mov    $0x20,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe98(%rip),%rdi
lea    0xeac(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7f(%rip),%rdi
lea    0xe80(%rip),%rdx
mov    $0x23,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe81(%rip),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe46(%rip),%rdi
lea    0xe47(%rip),%rdx
mov    $0x26,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe48(%rip),%rdi
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe0d(%rip),%rdi
lea    0xe0e(%rip),%rdx
mov    $0x29,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_slashes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%r13
lea    0xecf(%rip),%r15
mov    %r13,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
lea    0xeb6(%rip),%rbp
lea    0xeb7(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rdx
mov    $0x20,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
lea    0xeab(%rip),%r12
mov    %r13,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
mov    $0x23,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
lea    0xe89(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
mov    $0x26,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %rbp,%rdi
mov    %r14,%rdx
mov    $0x29,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <seatest_assert_string_equal@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/home/a\00"
@.str.1 = [6 x i8] c"/home\00"
@.str.2 = [2 x i8] c"a\00"
@__FUNCTION__.test_slashes = [13 x i8] c"test_slashes\00"
@.str.3 = [7 x i8] c"/home/\00"
@.str.4 = [9 x i8] c"/home/a/\00"
define void @test_slashes() {
%1 = alloca i8*
%2 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = sext i32 %2 to i64
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %1
br label %5
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 32)
br label %8
8: ; preds = %5
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %1
br label %12
12: ; preds = %8
%13 = load i8*, i8** %1
%14 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 35)
br label %15
15: ; preds = %12
%16 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %1
br label %19
19: ; preds = %15
%20 = load i8*, i8** %1
%21 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 38)
br label %22
22: ; preds = %19
%23 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %1
br label %26
26: ; preds = %22
%27 = load i8*, i8** %1
%28 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 41)
br label %29
29: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/home/a\00"
@.str.1 = [6 x i8] c"/home\00"
@.str.2 = [2 x i8] c"a\00"
@__FUNCTION__.test_slashes = [13 x i8] c"test_slashes\00"
@.str.3 = [7 x i8] c"/home/\00"
@.str.4 = [9 x i8] c"/home/a/\00"
define void @test_slashes() {
%1 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 32)
%5 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 35)
%9 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 38)
%13 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_slashes, i64 0, i64 0), i32 41)
ret void
}