#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*/ GetNext(char *, int *);
int StrIndex_KMP(char *, char *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char t[10] = "aabcaabab";
  char *s = "aabcaabab";
  printf("----");
  s[0] = (int)9;
  t[0] = (int)9;
  int next[9] = {0};
  GetNext(t, next);
  int index = StrIndex_KMP(s, t, 1, next);
  printf("index: %d\n", index);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0xe(%rbp)
mov    0xea7(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    0xe94(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movb   $0x9,(%rax)
movb   $0x9,-0xe(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1050 <memset@plt>
lea    -0xe(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <GetNext@plt>
mov    -0x18(%rbp),%rdi
lea    -0xe(%rbp),%rsi
lea    -0x40(%rbp),%rcx
mov    $0x1,%edx
call   1030 <StrIndex_KMP@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movabs $0x6162616163626161,%rax
61 62 61
mov    %rax,(%rsp)
movw   $0x62,0x8(%rsp)
lea    0xeab(%rip),%r14
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movb   $0x9,(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
mov    %rsp,%rbx
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <GetNext@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
call   1030 <StrIndex_KMP@plt>
lea    0xe66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.t = [10 x i8] c"aabcaabab\00"
@.str = [10 x i8] c"aabcaabab\00"
@.str.1 = [5 x i8] c"----\00"
@.str.2 = [11 x i8] c"index: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i8*
%4 = alloca [9 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i8]* %2 to i8*
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 9, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
store i8 9, i8* %10
%11 = bitcast [9 x i32]* %4 to i8*
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 0
%14 = call i32 @GetNext(i8* %12, i32* %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 0
%18 = call i32 @StrIndex_KMP(i8* %15, i8* %16, i32 1, i32* %17)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"aabcaabab\00"
@.str.1 = [5 x i8] c"----\00"
@.str.2 = [11 x i8] c"index: %d\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [9 x i32]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 9, i8* %3
%5 = bitcast [9 x i32]* %2 to i8*
%6 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%7 = call i32 @GetNext(i8* %3, i32* %6)
%8 = call i32 @StrIndex_KMP(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3, i32 1, i32* %6)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %8)
ret i32 0
}