#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*/ printf(char *, char *);
char *rabinStr(char *, char *);
char *strstr(char *, char *);
int main() {
  char str[256] = "shyam";
  char substr[256] = "hy";
  char *ptr = NULL;
  ptr = rabinStr(str, substr);
  if (ptr) {
    printf("str %p\n", str);
    printf("Substring found %s\n", ptr);
  }
  printf("strstr %s\n", strstr(str, substr));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movb   $0x73,-0x110(%rbp)
movb   $0x68,-0x10f(%rbp)
movb   $0x79,-0x10e(%rbp)
movb   $0x61,-0x10d(%rbp)
movb   $0x6d,-0x10c(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movb   $0x68,-0x210(%rbp)
movb   $0x79,-0x20f(%rbp)
movq   $0x0,-0x218(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1050 <rabinStr@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
je     1202 <main+0xc2>
lea    -0x110(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
mov    -0x218(%rbp),%rsi
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rsi
call   1060 <strstr@plt>
mov    %rax,%rsi
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x200,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x61796873,(%rsp)
movb   $0x6d,0x4(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movw   $0x7968,0x100(%rsp)
mov    %rsp,%rdi
lea    0x100(%rsp),%rsi
call   1040 <rabinStr@plt>
test   %rax,%rax
je     126e <main+0x13e>
mov    %rax,%rbx
lea    0xda9(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
lea    0xda2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rsp,%rdi
lea    0x100(%rsp),%rsi
call   1050 <strstr@plt>
lea    0xd97(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"str %p\0A\00"
@.str.1 = [20 x i8] c"Substring found %s\0A\00"
@.str.2 = [11 x i8] c"strstr %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [256 x i8]* %2 to i8*
%6 = bitcast i8* %5 to [256 x i8]*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i32 0, i32 0
store i8 115, i8* %7
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i32 0, i32 1
store i8 104, i8* %8
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i32 0, i32 2
store i8 121, i8* %9
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i32 0, i32 3
store i8 97, i8* %10
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i32 0, i32 4
store i8 109, i8* %11
%12 = bitcast [256 x i8]* %3 to i8*
%13 = bitcast i8* %12 to [256 x i8]*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i32 0, i32 0
store i8 104, i8* %14
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i32 0, i32 1
store i8 121, i8* %15
store i8* null, i8** %4
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = call i8* @rabinStr(i8* %16, i8* %17)
store i8* %18, i8** %4
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %26
21: ; preds = %0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %4
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %0
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%29 = call i8* @strstr(i8* %27, i8* %28)
%30 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"str %p\0A\00"
@.str.1 = [20 x i8] c"Substring found %s\0A\00"
@.str.2 = [11 x i8] c"strstr %s\0A\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
store i8 115, i8* %3
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 1
store i8 104, i8* %4
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 2
store i8 121, i8* %5
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 3
store i8 97, i8* %6
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 4
store i8 109, i8* %7
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
store i8 104, i8* %8
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 1
store i8 121, i8* %9
%10 = call i8* @rabinStr(i8* %3, i8* %8)
%11 = icmp eq i8* %10, null
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %3)
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %15
15: ; preds = %12, %0
%16 = call i8* @strstr(i8* %3, i8* %8)
%17 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 0
}