void test_sorting(void) {
  char *buf;
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("acd"), __FUNCTION__, 40);
  } while (0);
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("abc"), __FUNCTION__, 41);
  } while (0);
  vle_compl_finish_group();
  do {
    seatest_assert_int_equal(0, vle_compl_add_last_match("a"), __FUNCTION__,
                             44);
  } while (0);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("abc", buf, __FUNCTION__, 47);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("acd", buf, __FUNCTION__, 50);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 53);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("abc", buf, __FUNCTION__, 56);
  } while (0);
  free(buf);
}


x86 assembly (clang, -O0):
<test_sorting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1080 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe73(%rip),%rdx
mov    $0x28,%ecx
mov    $0x0,%al
call   1070 <seatest_assert_int_equal@plt>
jmp    11a2 <test_sorting+0x32>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1080 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe49(%rip),%rdx
mov    $0x29,%ecx
mov    $0x0,%al
call   1070 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1050 <vle_compl_finish_group@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_last_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe1d(%rip),%rdx
mov    $0x2c,%ecx
mov    $0x0,%al
call   1070 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe06(%rip),%rdi
lea    0xdf2(%rip),%rdx
mov    $0x2f,%ecx
mov    $0x0,%al
call   1060 <seatest_assert_string_equal@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xdc1(%rip),%rdi
lea    0xdbe(%rip),%rdx
mov    $0x32,%ecx
mov    $0x0,%al
call   1060 <seatest_assert_string_equal@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xda2(%rip),%rdi
lea    0xd8a(%rip),%rdx
mov    $0x35,%ecx
mov    $0x0,%al
call   1060 <seatest_assert_string_equal@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xd6a(%rip),%rdi
lea    0xd56(%rip),%rdx
mov    $0x38,%ecx
mov    $0x0,%al
call   1060 <seatest_assert_string_equal@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sorting>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe80(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <vle_compl_add_match@plt>
lea    0xe73(%rip),%r13
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x28,%ecx
xor    %eax,%eax
call   1070 <seatest_assert_int_equal@plt>
lea    0xe66(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <vle_compl_add_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x29,%ecx
xor    %eax,%eax
call   1070 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1050 <vle_compl_finish_group@plt>
lea    0xe3f(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <vle_compl_add_last_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x2c,%ecx
xor    %eax,%eax
call   1070 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x2f,%ecx
xor    %eax,%eax
call   1060 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x32,%ecx
xor    %eax,%eax
call   1060 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x35,%ecx
xor    %eax,%eax
call   1060 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x38,%ecx
xor    %eax,%eax
call   1060 <seatest_assert_string_equal@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"acd\00"
@__FUNCTION__.test_sorting = [13 x i8] c"test_sorting\00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [2 x i8] c"a\00"
define void @test_sorting() {
%1 = alloca i8*
br label %2
2: ; preds = %0
%3 = call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 40)
br label %5
5: ; preds = %2
br label %6
6: ; preds = %5
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 41)
br label %9
9: ; preds = %6
%10 = call i32 (...) @vle_compl_finish_group()
br label %11
11: ; preds = %9
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_last_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 44)
br label %14
14: ; preds = %11
%15 = call i32 (...) @vle_compl_next()
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %1
br label %18
18: ; preds = %14
%19 = load i8*, i8** %1
%20 = 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.1, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 47)
br label %21
21: ; preds = %18
%22 = load i8*, i8** %1
%23 = call i32 (...) @vle_compl_next()
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i8*
store i8* %25, i8** %1
br label %26
26: ; preds = %21
%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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 50)
br label %29
29: ; preds = %26
%30 = load i8*, i8** %1
%31 = call i32 (...) @vle_compl_next()
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %1
br label %34
34: ; preds = %29
%35 = load i8*, i8** %1
%36 = 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* %35, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 53)
br label %37
37: ; preds = %34
%38 = load i8*, i8** %1
%39 = call i32 (...) @vle_compl_next()
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %1
br label %42
42: ; preds = %37
%43 = load i8*, i8** %1
%44 = 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.1, i64 0, i64 0), i8* %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 56)
br label %45
45: ; preds = %42
%46 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"acd\00"
@__FUNCTION__.test_sorting = [13 x i8] c"test_sorting\00"
@.str.1 = [4 x i8] c"abc\00"
@.str.2 = [2 x i8] c"a\00"
define void @test_sorting() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 40)
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 41)
%5 = tail call i32 (...) @vle_compl_finish_group()
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_last_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 44)
%8 = tail call i32 (...) @vle_compl_next()
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = 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.1, i64 0, i64 0), i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 47)
tail call void @free(i8* %10)
%12 = tail call i32 (...) @vle_compl_next()
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = 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, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 50)
tail call void @free(i8* %14)
%16 = tail call i32 (...) @vle_compl_next()
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = 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* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 53)
tail call void @free(i8* %18)
%20 = tail call i32 (...) @vle_compl_next()
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = 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.1, i64 0, i64 0), i8* %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.test_sorting, i64 0, i64 0), i32 56)
tail call void @free(i8* %22)
ret void
}