void test_under_dir(void) {
  const char *buf;
  buf = make_rel_path("/home/a/b", "/home/");
  do {
    seatest_assert_string_equal("a/b", buf, __FUNCTION__, 50);
  } while (0);
  buf = make_rel_path("/home/a/b///c", "/home/");
  do {
    seatest_assert_string_equal("a/b/c", buf, __FUNCTION__, 53);
  } while (0);
}


x86 assembly (clang, -O0):
<test_under_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0xed4(%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    0xebc(%rip),%rdx
mov    $0x32,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
lea    0xeb8(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1030 <make_rel_path@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea7(%rip),%rdi
lea    0xe83(%rip),%rdx
mov    $0x35,%ecx
mov    $0x0,%al
call   1040 <seatest_assert_string_equal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_under_dir>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
lea    0xed8(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
lea    0xec0(%rip),%rdi
lea    0xec4(%rip),%rbx
mov    %rbx,%rdx
mov    $0x32,%ecx
xor    %eax,%eax
call   1040 <seatest_assert_string_equal@plt>
lea    0xebd(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <make_rel_path@plt>
movslq %eax,%rsi
lea    0xeb7(%rip),%rdi
mov    %rbx,%rdx
mov    $0x35,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <seatest_assert_string_equal@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/home/a/b\00"
@.str.1 = [7 x i8] c"/home/\00"
@.str.2 = [4 x i8] c"a/b\00"
@__FUNCTION__.test_under_dir = [15 x i8] c"test_under_dir\00"
@.str.3 = [14 x i8] c"/home/a/b///c\00"
@.str.4 = [6 x i8] c"a/b/c\00"
define void @test_under_dir() {
%1 = alloca i8*
%2 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_under_dir, i64 0, i64 0), i32 50)
br label %8
8: ; preds = %5
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, 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 ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_under_dir, i64 0, i64 0), i32 53)
br label %15
15: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"/home/a/b\00"
@.str.1 = [7 x i8] c"/home/\00"
@.str.2 = [4 x i8] c"a/b\00"
@__FUNCTION__.test_under_dir = [15 x i8] c"test_under_dir\00"
@.str.3 = [14 x i8] c"/home/a/b///c\00"
@.str.4 = [6 x i8] c"a/b/c\00"
define void @test_under_dir() {
%1 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_under_dir, i64 0, i64 0), i32 50)
%5 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @make_rel_path to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, 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 ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__FUNCTION__.test_under_dir, i64 0, i64 0), i32 53)
ret void
}