void test_unite_removes_duplicates(void) {
  char *buf;
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("echo"), __FUNCTION__, 12);
  } while (0);
  vle_compl_finish_group();
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("ec"), __FUNCTION__, 14);
  } while (0);
  vle_compl_finish_group();
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("echo"), __FUNCTION__, 16);
  } while (0);
  vle_compl_finish_group();
  do {
    seatest_assert_int_equal(0, vle_compl_add_match("e"), __FUNCTION__, 18);
  } while (0);
  do {
    seatest_assert_int_equal(4, vle_compl_get_count(), __FUNCTION__, 20);
  } while (0);
  vle_compl_unite_groups();
  do {
    seatest_assert_int_equal(3, vle_compl_get_count(), __FUNCTION__, 24);
  } while (0);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("e", buf, __FUNCTION__, 27);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("ec", buf, __FUNCTION__, 31);
  } while (0);
  free(buf);
  buf = vle_compl_next();
  do {
    seatest_assert_string_equal("echo", buf, __FUNCTION__, 35);
  } while (0);
  free(buf);
}


x86 assembly (clang, -O0):
<test_unite_removes_duplicates>:
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    0xe64(%rip),%rdx
mov    $0xc,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1050 <vle_compl_finish_group@plt>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe38(%rip),%rdx
mov    $0xe,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1050 <vle_compl_finish_group@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xe0c(%rip),%rdx
mov    $0x10,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1050 <vle_compl_finish_group@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1090 <vle_compl_add_match@plt>
mov    %eax,%esi
xor    %edi,%edi
lea    0xde0(%rip),%rdx
mov    $0x12,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
jmp    1236 <test_unite_removes_duplicates+0xb6>
mov    $0x0,%al
call   10a0 <vle_compl_get_count@plt>
mov    %eax,%esi
mov    $0x4,%edi
lea    0xdba(%rip),%rdx
mov    $0x14,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1060 <vle_compl_unite_groups@plt>
mov    $0x0,%al
call   10a0 <vle_compl_get_count@plt>
mov    %eax,%esi
mov    $0x3,%edi
lea    0xd92(%rip),%rdx
mov    $0x18,%ecx
mov    $0x0,%al
call   1080 <seatest_assert_int_equal@plt>
mov    $0x0,%al
call   1040 <vle_compl_next@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xd8f(%rip),%rdi
lea    0xd67(%rip),%rdx
mov    $0x1b,%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    0xd58(%rip),%rdi
lea    0xd33(%rip),%rdx
mov    $0x1f,%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    0xd01(%rip),%rdi
lea    0xcff(%rip),%rdx
mov    $0x23,%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_unite_removes_duplicates>:
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    0xe64(%rip),%r13
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0xc,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1050 <vle_compl_finish_group@plt>
lea    0xe61(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <vle_compl_add_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0xe,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1050 <vle_compl_finish_group@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <vle_compl_add_match@plt>
xor    %edi,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x10,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1050 <vle_compl_finish_group@plt>
lea    0xe15(%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    $0x12,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   10a0 <vle_compl_get_count@plt>
mov    $0x4,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x14,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1060 <vle_compl_unite_groups@plt>
xor    %eax,%eax
call   10a0 <vle_compl_get_count@plt>
mov    $0x3,%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x18,%ecx
xor    %eax,%eax
call   1080 <seatest_assert_int_equal@plt>
xor    %eax,%eax
call   1040 <vle_compl_next@plt>
movslq %eax,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    $0x1b,%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    $0x1f,%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    $0x23,%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 = [5 x i8] c"echo\00"
@__FUNCTION__.test_unite_removes_duplicates = [30 x i8] c"test_unite_removes_duplicates\00"
@.str.1 = [3 x i8] c"ec\00"
@.str.2 = [2 x i8] c"e\00"
define void @test_unite_removes_duplicates() {
%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 ([5 x i8], [5 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 ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 12)
br label %5
5: ; preds = %2
%6 = call i32 (...) @vle_compl_finish_group()
br label %7
7: ; preds = %5
%8 = 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))
%9 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 14)
br label %10
10: ; preds = %7
%11 = call i32 (...) @vle_compl_finish_group()
br label %12
12: ; preds = %10
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 16)
br label %15
15: ; preds = %12
%16 = call i32 (...) @vle_compl_finish_group()
br label %17
17: ; preds = %15
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 18)
br label %20
20: ; preds = %17
br label %21
21: ; preds = %20
%22 = call i32 (...) @vle_compl_get_count()
%23 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 4, i32 %22, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 20)
br label %24
24: ; preds = %21
%25 = call i32 (...) @vle_compl_unite_groups()
br label %26
26: ; preds = %24
%27 = call i32 (...) @vle_compl_get_count()
%28 = call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 3, i32 %27, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 24)
br label %29
29: ; preds = %26
%30 = call i32 (...) @vle_compl_next()
%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.2, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 27)
br label %36
36: ; preds = %33
%37 = load i8*, i8** %1
%38 = call i32 (...) @vle_compl_next()
%39 = sext i32 %38 to i64
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %1
br label %41
41: ; preds = %36
%42 = load i8*, i8** %1
%43 = 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* %42, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 31)
br label %44
44: ; preds = %41
%45 = load i8*, i8** %1
%46 = call i32 (...) @vle_compl_next()
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i8*
store i8* %48, i8** %1
br label %49
49: ; preds = %44
%50 = load i8*, i8** %1
%51 = call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 35)
br label %52
52: ; preds = %49
%53 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"echo\00"
@__FUNCTION__.test_unite_removes_duplicates = [30 x i8] c"test_unite_removes_duplicates\00"
@.str.1 = [3 x i8] c"ec\00"
@.str.2 = [2 x i8] c"e\00"
define void @test_unite_removes_duplicates() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 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 ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 12)
%3 = tail call i32 (...) @vle_compl_finish_group()
%4 = 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))
%5 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 14)
%6 = tail call i32 (...) @vle_compl_finish_group()
%7 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = tail 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 ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 16)
%9 = tail call i32 (...) @vle_compl_finish_group()
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vle_compl_add_match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 0, i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 18)
%12 = tail call i32 (...) @vle_compl_get_count()
%13 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 4, i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 20)
%14 = tail call i32 (...) @vle_compl_unite_groups()
%15 = tail call i32 (...) @vle_compl_get_count()
%16 = tail call i32 (i32, i32, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_int_equal to i32 (i32, i32, i8*, i32, ...)*)(i32 3, i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 24)
%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 ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 27)
tail call void @free(i8* %19)
%21 = tail call i32 (...) @vle_compl_next()
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
%24 = 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* %23, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 31)
tail call void @free(i8* %23)
%25 = tail call i32 (...) @vle_compl_next()
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8*
%28 = tail call i32 (i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @seatest_assert_string_equal to i32 (i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @__FUNCTION__.test_unite_removes_duplicates, i64 0, i64 0), i32 35)
tail call void @free(i8* %27)
ret void
}