int KMP_test(void) {
  char txt[][100] = {"ABCAABCA", "AAAAB"};
  int n = sizeof(txt) / sizeof(txt[0]);
  for (int i = 0; i < n; i++) {
    if (isRepeat(txt[i]) == 1) {
      printf("TRUE\n");
    } else {
      printf("FALSE\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<KMP_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    -0xd0(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0xc8,%edx
call   1040 <memcpy@plt>
movl   $0x2,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    11d8 <KMP_test+0xa8>
movslq -0xd8(%rbp),%rax
lea    -0xd0(%rbp),%rdi
imul   $0x64,%rax,%rax
add    %rax,%rdi
mov    $0x0,%al
call   1050 <isRepeat@plt>
cmp    $0x1,%eax
jne    11b1 <KMP_test+0x81>
lea    0xf23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bf <KMP_test+0x8f>
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c4 <KMP_test+0x94>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1167 <KMP_test+0x37>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KMP_test>:
push   %r14
push   %rbx
sub    $0xc8,%rsp
lea    0xebf(%rip),%rsi
mov    %rsp,%rbx
mov    $0xc8,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <isRepeat@plt>
cmp    $0x1,%eax
lea    0xf69(%rip),%r14
lea    0xf5c(%rip),%rbx
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0x64(%rsp),%rdi
xor    %eax,%eax
call   1050 <isRepeat@plt>
cmp    $0x1,%eax
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.KMP_test.txt = [2 x [100 x i8]] [[100 x i8] c"ABCAABCA\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [100 x i8] c"AAAAB\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"]
@.str = [6 x i8] c"TRUE\0A\00"
@.str.1 = [7 x i8] c"FALSE\0A\00"
define i32 @KMP_test() {
%1 = alloca [2 x [100 x i8]]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [2 x [100 x i8]]* %1 to i8*
store i32 2, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %24
9: ; preds = %5
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %1, i64 0, i64 %11
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %12, i64 0, i64 0
%14 = call i32 (i8*, ...) bitcast (i32 (...)* @isRepeat to i32 (i8*, ...)*)(i8* %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %20
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %5
24: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@__const.KMP_test.txt = [2 x [100 x i8]] [[100 x i8] c"ABCAABCA\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [100 x i8] c"AAAAB\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"]
@str = [6 x i8] c"FALSE\00"
@str.2 = [5 x i8] c"TRUE\00"
define i32 @KMP_test() {
%1 = alloca [2 x [100 x i8]]
%2 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %1, i64 0, i64 0, i64 0
%3 = call i32 (i8*, ...) bitcast (i32 (...)* @isRepeat to i32 (i8*, ...)*)(i8* %2)
%4 = icmp eq i32 %3, 1
%5 = select i1 %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)
%6 = call i32 @puts(i8* dereferenceable(1) %5)
%7 = getelementptr inbounds [2 x [100 x i8]], [2 x [100 x i8]]* %1, i64 0, i64 1, i64 0
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @isRepeat to i32 (i8*, ...)*)(i8* %7)
%9 = icmp eq i32 %8, 1
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}