#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*/ KMPSearch(char *, char *, int *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char str[] = "abcxabcdabcdabcyabcdabcy";
  char subString[] = "abcdabcy";
  int strCount = 0;
  KMPSearch(str, subString, &strCount);
  printf("The pattern %s was found %d times\n", subString, strCount);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xec2(%rip),%al
mov    %al,-0x8(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x29(%rbp)
mov    0xeb7(%rip),%al
mov    %al,-0x21(%rbp)
movl   $0x0,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x29(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1040 <KMPSearch@plt>
lea    -0x29(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xedd(%rip),%xmm0
movups %xmm0,0x29(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x7963626164636261,%rax
62 63 79
mov    %rax,0x10(%rsp)
movb   $0x0,0x18(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <KMPSearch@plt>
mov    0xc(%rsp),%edx
lea    0xea7(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.str = [25 x i8] c"abcxabcdabcdabcyabcdabcy\00"
@__const.main.subString = [9 x i8] c"abcdabcy\00"
@.str = [35 x i8] c"The pattern %s was found %d times\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i8]
%3 = alloca [9 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [25 x i8]* %2 to i8*
%6 = bitcast [9 x i8]* %3 to i8*
store i32 0, i32* %4
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%9 = call i32 @KMPSearch(i8* %7, i8* %8, i32* %4)
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* %4
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [25 x i8] c"abcxabcdabcdabcyabcdabcy\00"
@__const.main.subString = [9 x i8] c"abcdabcy\00"
@.str = [35 x i8] c"The pattern %s was found %d times\0A\00"
define i32 @main() {
%1 = alloca [25 x i8]
%2 = alloca [9 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [25 x i8], [25 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i32 @KMPSearch(i8* %4, i8* %5, i32* %3)
%8 = load i32, i32* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %8)
ret i32 0
}