#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*/ assert(int);
size_t kmp(char *, size_t *, size_t, char *, size_t);
size_t strlen(char *);
int main(int argc, char *argv[]) {
  size_t table[32];
  size_t rc;
  char *key = "test1";
  char *str = "this is a test";
  rc = kmp(key, table, strlen(key), str, strlen(str));
  assert(rc == strlen(str));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x120(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    -0x120(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x148(%rbp)
mov    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x140(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x128(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x150(%rbp),%rdi
mov    -0x148(%rbp),%rsi
mov    -0x140(%rbp),%rdx
mov    -0x138(%rbp),%rcx
mov    %rax,%r8
call   1050 <kmp@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x128(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x108,%rsp
lea    0xed2(%rip),%rdi
lea    0xed1(%rip),%rcx
mov    %rsp,%rsi
mov    $0x5,%edx
mov    $0xe,%r8d
call   1040 <kmp@plt>
xor    %edi,%edi
cmp    $0xe,%rax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x108,%rsp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"test1\00"
@.str.1 = [15 x i8] c"this is a test\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i64]
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = load i8*, i8** %8
%11 = getelementptr inbounds [32 x i64], [32 x i64]* %6, i64 0, i64 0
%12 = load i8*, i8** %8
%13 = call i64 @strlen(i8* %12)
%14 = load i8*, i8** %9
%15 = load i8*, i8** %9
%16 = call i64 @strlen(i8* %15)
%17 = call i64 @kmp(i8* %10, i64* %11, i64 %13, i8* %14, i64 %16)
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = load i8*, i8** %9
%20 = call i64 @strlen(i8* %19)
%21 = icmp eq i64 %18, %20
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"test1\00"
@.str.1 = [15 x i8] c"this is a test\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i64]
%4 = bitcast [32 x i64]* %3 to i8*
%5 = getelementptr inbounds [32 x i64], [32 x i64]* %3, i64 0, i64 0
%6 = call i64 @kmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64* %5, i64 5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14)
%7 = icmp eq i64 %6, 14
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
ret i32 0
}