#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*/ rabin_karp(char *, char *, int, int);
void test_rabin_karp() {
  int base = 256, q = 65536;
  char cs[] = "naive string matcher algorithm for strings";
  char ds[] = "string";
  rabin_karp(cs, ds, base, q);
  char es[] = "2359023141526739921";
  char fs[] = "90231415267";
  rabin_karp(es, fs, base, q);
}


x86 assembly (clang, -O0):
<test_rabin_karp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x100,-0x4(%rbp)
movl   $0x10000,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xebf(%rip),%rsi
mov    $0x2b,%edx
call   1040 <memcpy@plt>
mov    0xef3(%rip),%eax
mov    %eax,-0x47(%rbp)
mov    0xeed(%rip),%ax
mov    %ax,-0x43(%rbp)
mov    0xee5(%rip),%al
mov    %al,-0x41(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x47(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1030 <rabin_karp@plt>
mov    0xeae(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea9(%rip),%eax
mov    %eax,-0x50(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x6c(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x6c(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1030 <rabin_karp@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_rabin_karp>:
sub    $0x78,%rsp
movups 0xf00(%rip),%xmm0
movups %xmm0,0x5b(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movl   $0x676e69,0xb(%rsp)
movl   $0x69727473,0x8(%rsp)
69
lea    0x40(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x100,%edx
mov    $0x10000,%ecx
call   1030 <rabin_karp@plt>
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x313239,0x30(%rsp)
movabs $0x3531343133323039,%rax
34 31 35
mov    %rax,0x10(%rsp)
movl   $0x373632,0x18(%rsp)
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x100,%edx
mov    $0x10000,%ecx
call   1030 <rabin_karp@plt>
add    $0x78,%rsp
ret

LLVM IR (-O0):
@__const.test_rabin_karp.cs = [43 x i8] c"naive string matcher algorithm for strings\00"
@__const.test_rabin_karp.ds = [7 x i8] c"string\00"
@__const.test_rabin_karp.es = [20 x i8] c"2359023141526739921\00"
@__const.test_rabin_karp.fs = [12 x i8] c"90231415267\00"
define void @test_rabin_karp() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [43 x i8]
%4 = alloca [7 x i8]
%5 = alloca [20 x i8]
%6 = alloca [12 x i8]
store i32 256, i32* %1
store i32 65536, i32* %2
%7 = bitcast [43 x i8]* %3 to i8*
%8 = bitcast [7 x i8]* %4 to i8*
%9 = getelementptr inbounds [43 x i8], [43 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @rabin_karp(i8* %9, i8* %10, i32 %11, i32 %12)
%14 = bitcast [20 x i8]* %5 to i8*
%15 = bitcast [12 x i8]* %6 to i8*
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 @rabin_karp(i8* %16, i8* %17, i32 %18, i32 %19)
ret void
}

LLVM IR (-O2):
@__const.test_rabin_karp.cs = [43 x i8] c"naive string matcher algorithm for strings\00"
@__const.test_rabin_karp.ds = [7 x i8] c"string\00"
@__const.test_rabin_karp.es = [20 x i8] c"2359023141526739921\00"
@__const.test_rabin_karp.fs = [12 x i8] c"90231415267\00"
define void @test_rabin_karp() {
%1 = alloca [43 x i8]
%2 = alloca [7 x i8]
%3 = alloca [20 x i8]
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [43 x i8], [43 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = call i32 @rabin_karp(i8* %5, i8* %6, i32 256, i32 65536)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%10 = call i32 @rabin_karp(i8* %8, i8* %9, i32 256, i32 65536)
ret void
}