void test_in_one_dir(void) {
  const char *buf;
  buf = make_rel_path("/home/a", "/home/");
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 11);
  } while (0);
  buf = make_rel_path("/home/", "/home/");
  do {
    seatest_assert_string_equal(".", buf, __FUNCTION__, 14);
  } while (0);
  buf = make_rel_path("/home", "/home/");
  do {
    seatest_assert_string_equal(".", buf, __FUNCTION__, 17);
  } while (0);
  buf = make_rel_path("/home/", "/home");
  do {
    seatest_assert_string_equal(".", buf, __FUNCTION__, 20);
  } while (0);
  buf = make_rel_path("/home", "/home");
  do {
    seatest_assert_string_equal(".", buf, __FUNCTION__, 23);
  } while (0);
}


x86 assembly (clang, -O0):
<test_in_one_dir>:
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    0xeba(%rip),%rdx
mov    $0xb,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xea0(%rip),%rsi
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe9c(%rip),%rdi
lea    0xe85(%rip),%rdx
mov    $0xe,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe84(%rip),%rdi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe63(%rip),%rdi
lea    0xe4c(%rip),%rdx
mov    $0x11,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe32(%rip),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe2a(%rip),%rdi
lea    0xe13(%rip),%rdx
mov    $0x14,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xe12(%rip),%rsi
mov    %rsi,%rdi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xdf5(%rip),%rdi
lea    0xdde(%rip),%rdx
mov    $0x17,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_in_one_dir>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xed1(%rip),%rdi
lea    0xed2(%rip),%r12
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
lea    0xebc(%rip),%rdi
lea    0xebe(%rip),%r14
mov    %r14,%rdx
mov    $0xb,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
mov    %r12,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
lea    0xea8(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rdx
mov    $0xe,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
lea    0xe91(%rip),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    $0x11,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    $0x14,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    $0x17,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <seatest_assert_string_equal@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/home/a\00"
@.str.1 = [7 x i8] c"/home/\00"
@.str.2 = [2 x i8] c"a\00"
@__FUNCTION__.test_in_one_dir = [16 x i8] c"test_in_one_dir\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [6 x i8] c"/home\00"
define void @test_in_one_dir() {
%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 ([7 x i8], [7 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 ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 11)
br label %8
8: ; preds = %5
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, 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.3, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 14)
br label %15
15: ; preds = %12
%16 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 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.3, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 17)
br label %22
22: ; preds = %19
%23 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, 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.3, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 20)
br label %29
29: ; preds = %26
%30 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
store i8* %32, i8** %1
br label %33
33: ; preds = %29
%34 = load i8*, i8** %1
%35 = 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.3, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 23)
br label %36
36: ; preds = %33
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"/home/a\00"
@.str.1 = [7 x i8] c"/home/\00"
@.str.2 = [2 x i8] c"a\00"
@__FUNCTION__.test_in_one_dir = [16 x i8] c"test_in_one_dir\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [6 x i8] c"/home\00"
define void @test_in_one_dir() {
%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 ([7 x i8], [7 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 ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 11)
%5 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, 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.3, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 14)
%9 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 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.3, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 17)
%13 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, 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.3, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 20)
%17 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i8*
%20 = 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.3, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__FUNCTION__.test_in_one_dir, i64 0, i64 0), i32 23)
ret void
}