#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ tab_complete_add_sentence(char *);
char **tab_complete_find_matches(char *, int *);
int /*<<< orphan*/ tab_complete_save();
int /*<<< orphan*/ tab_complete_set_wordlist_file(char *);
int main() {
  tab_complete_set_wordlist_file("/home/nowl/.mudc/worlds/aardmud.org/tab");
  tab_complete_add_sentence("This is a simple test.");
  int results_len;
  char **results = tab_complete_find_matches("f", &results_len);
  if (results) {
    int i;
    for (i = 0; i < results_len; i++)
      printf("found '%s'\n", results[i]);
  } else {
    printf("no results found\n");
  }
  tab_complete_save();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1060 <tab_complete_set_wordlist_file@plt>
lea    0xeb6(%rip),%rdi
call   1030 <tab_complete_add_sentence@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <tab_complete_find_matches@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d6 <main+0x86>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d1 <main+0x81>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119d <main+0x4d>
jmp    11e4 <main+0x94>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <tab_complete_save@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rdi
call   1070 <tab_complete_set_wordlist_file@plt>
lea    0xeac(%rip),%rdi
call   1030 <tab_complete_add_sentence@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <tab_complete_find_matches@plt>
test   %rax,%rax
je     11ce <main+0x6e>
cmpl   $0x0,0xc(%rsp)
jle    11da <main+0x7a>
mov    %rax,%r15
lea    0xe99(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11b0 <main+0x50>
jmp    11da <main+0x7a>
lea    0xe78(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1040 <tab_complete_save@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [40 x i8] c"/home/nowl/.mudc/worlds/aardmud.org/tab\00"
@.str.1 = [23 x i8] c"This is a simple test.\00"
@.str.2 = [2 x i8] c"f\00"
@.str.3 = [12 x i8] c"found '%s'\0A\00"
@.str.4 = [18 x i8] c"no results found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @tab_complete_set_wordlist_file(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @tab_complete_add_sentence(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%7 = call i8** @tab_complete_find_matches(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i8** %7, i8*** %3
%8 = load i8**, i8*** %3
%9 = icmp ne i8** %8, null
br i1 %9, label %10, label %26
10: ; preds = %0
store i32 0, i32* %4
br label %11
11: ; preds = %22, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %25
15: ; preds = %11
%16 = load i8**, i8*** %3
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %11
25: ; preds = %11
br label %28
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %25
%29 = call i32 (...) @tab_complete_save()
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"/home/nowl/.mudc/worlds/aardmud.org/tab\00"
@.str.1 = [23 x i8] c"This is a simple test.\00"
@.str.2 = [2 x i8] c"f\00"
@.str.3 = [12 x i8] c"found '%s'\0A\00"
@str = [17 x i8] c"no results found\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @tab_complete_set_wordlist_file(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @tab_complete_add_sentence(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i8** @tab_complete_find_matches(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = icmp eq i8** %5, null
br i1 %6, label %19, label %7
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7, %10
%11 = phi i64 [ %15, %10 ], [ 0, %7 ]
%12 = getelementptr inbounds i8*, i8** %5, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = add nuw nsw i64 %11, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %10, label %21
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %10, %7, %19
%22 = call i32 (...) @tab_complete_save()
ret i32 0
}