void test_order(void) {
  char *buf;
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("aa"), __FUNCTION__, 179);
  } while (0);
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("az"), __FUNCTION__, 180);
  } while (0);
  vle_compl_finish_group();
  do {
    seatest_assert_int_equal(0, vle_compl_add_last_match("a"), __FUNCTION__,
                             183);
  } while (0);
  vle_compl_set_order(1);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("az", buf, __FUNCTION__, 188);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("aa", buf, __FUNCTION__, 192);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("a", buf, __FUNCTION__, 196);
  } while (0);
  free(buf);
}


x86 assembly (clang, -O0):
<test_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe62(%rip),%rdx
mov    $0xb3,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
jmp    11b2 <test_order+0x32>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe38(%rip),%rdx
mov    $0xb4,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1050 <vle_compl_finish_group@plt>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   10a0 <vle_compl_add_last_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe0c(%rip),%rdx
mov    $0xb7,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1060 <vle_compl_set_order@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xde7(%rip),%rdi
lea    0xdd5(%rip),%rdx
mov    $0xbc,%ecx
mov    $0x0,%al
call   1070 <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    0xda5(%rip),%rdi
lea    0xda1(%rip),%rdx
mov    $0xc0,%ecx
mov    $0x0,%al
call   1070 <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    0xd72(%rip),%rdi
lea    0xd6d(%rip),%rdx
mov    $0xc4,%ecx
mov    $0x0,%al
call   1070 <seatest_assert_string_equal@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_order>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
lea    0xe70(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <vle_compl_add_match@plt>
lea    0xe62(%rip),%r13
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0xb3,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
lea    0xe53(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <vle_compl_add_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0xb4,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1050 <vle_compl_finish_group@plt>
lea    0xe1b(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <vle_compl_add_last_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0xb7,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <vle_compl_set_order@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0xbc,%ecx
xor    %eax,%eax
call   1070 <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    $0xc0,%ecx
xor    %eax,%eax
call   1070 <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    $0xc4,%ecx
xor    %eax,%eax
call   1070 <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 = [3 x i8] c"aa\00"
@__FUNCTION__.test_order = [11 x i8] c"test_order\00"
@.str.1 = [3 x i8] c"az\00"
@.str.2 = [2 x i8] c"a\00"
define void @test_order() {
%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 ([3 x i8], [3 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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 179)
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 ([3 x i8], [3 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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 180)
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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 183)
br label %14
14: ; preds = %11
%15 = call i32 (i32, ...) bitcast (i32 (...)* @vle_compl_set_order to i32 (i32, ...)*)(i32 1)
%16 = call i32 (...) @vle_compl_next()
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %1
br label %19
19: ; preds = %14
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 188)
br label %22
22: ; preds = %19
%23 = load i8*, i8** %1
%24 = call i32 (...) @vle_compl_next()
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %1
br label %27
27: ; preds = %22
%28 = load i8*, i8** %1
%29 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 192)
br label %30
30: ; preds = %27
%31 = load i8*, i8** %1
%32 = call i32 (...) @vle_compl_next()
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %1
br label %35
35: ; preds = %30
%36 = load i8*, i8** %1
%37 = 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* %36, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 196)
br label %38
38: ; preds = %35
%39 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"aa\00"
@__FUNCTION__.test_order = [11 x i8] c"test_order\00"
@.str.1 = [3 x i8] c"az\00"
@.str.2 = [2 x i8] c"a\00"
define void @test_order() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 179)
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([3 x i8], [3 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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 180)
%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 ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 183)
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @vle_compl_set_order to i32 (i32, ...)*)(i32 1)
%9 = tail call i32 (...) @vle_compl_next()
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 188)
tail call void @free(i8* %11)
%13 = tail call i32 (...) @vle_compl_next()
%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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 192)
tail call void @free(i8* %15)
%17 = tail call i32 (...) @vle_compl_next()
%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.2, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__FUNCTION__.test_order, i64 0, i64 0), i32 196)
tail call void @free(i8* %19)
ret void
}