#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 *, int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  size_t table[32];
  size_t rc;
  char *key = "test";
  char *str = "this is a test";
  rc = kmp(key, table, strlen(key), str, strlen(str));
  assert(rc == 10);
  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    0xeba(%rip),%rax
mov    %rax,-0x120(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    -0x120(%rbp),%rax
mov    %rax,-0x148(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x120(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x134(%rbp)
mov    -0x128(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x128(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x148(%rbp),%rdi
mov    -0x140(%rbp),%rsi
mov    -0x134(%rbp),%edx
mov    -0x130(%rbp),%rcx
mov    %eax,%r8d
call   1050 <kmp@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0xa,-0x118(%rbp)
0a
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>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
lea    0xec8(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xead(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
call   1050 <kmp@plt>
xor    %edi,%edi
cmp    $0xa,%rax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"test\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 ([5 x i8], [5 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 i32 @strlen(i8* %12)
%14 = load i8*, i8** %9
%15 = load i8*, i8** %9
%16 = call i32 @strlen(i8* %15)
%17 = call i64 @kmp(i8* %10, i64* %11, i32 %13, i8* %14, i32 %16)
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = icmp eq i64 %18, 10
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\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 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%8 = call i64 @kmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %5, i32 %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp eq i64 %8, 10
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
ret i32 0
}