#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 */
char *BoyerMooreSearch(char const *, char const *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char const *);
int /*<<< orphan*/ stdout;
int main() {
  const char *testText;
  const char *testPattern;
  const char *result;
  int spaces;
  char *matchMarker = "^";
  testText = "A string searching example consisting of this sentence.";
  testPattern = "sting";
  result = BoyerMooreSearch(testText, testPattern);
  puts(testText);
  if (result) {
    spaces = result - testText;
    while (spaces--)
      putc(' ', stdout);
    puts(matchMarker);
  } else
    puts("Pattern not found.");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <BoyerMooreSearch@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <puts@plt>
cmpq   $0x0,-0x20(%rbp)
je     11cd <main+0x9d>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
je     11bf <main+0x8f>
mov    0x2e32(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <putc@plt>
jmp    1193 <main+0x63>
mov    -0x30(%rbp),%rdi
call   1030 <puts@plt>
jmp    11d9 <main+0xa9>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xec6(%rip),%r14
lea    0xef7(%rip),%rsi
mov    %r14,%rdi
call   1050 <BoyerMooreSearch@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <puts@plt>
test   %r15,%r15
je     1193 <main+0x63>
lea    0xea0(%rip),%rax
lea    0xe97(%rip),%r14
cmp    %eax,%r15d
je     119a <main+0x6a>
lea    0xe8d(%rip),%rbx
sub    %r15d,%ebx
mov    0x2e61(%rip),%r15
nop
mov    (%r15),%esi
mov    $0x20,%edi
call   1040 <putc@plt>
inc    %ebx
jne    1180 <main+0x50>
jmp    119a <main+0x6a>
lea    0xea6(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"^\00"
@.str.1 = [56 x i8] c"A string searching example consisting of this sentence.\00"
@.str.2 = [6 x i8] c"sting\00"
@stdout = global i32 0
@.str.3 = [19 x i8] c"Pattern not found.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %3
%7 = load i8*, i8** %2
%8 = load i8*, i8** %3
%9 = call i8* @BoyerMooreSearch(i8* %7, i8* %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %2
%11 = call i32 @puts(i8* %10)
%12 = load i8*, i8** %4
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %31
14: ; preds = %0
%15 = load i8*, i8** %4
%16 = load i8*, i8** %2
%17 = ptrtoint i8* %15 to i64
%18 = ptrtoint i8* %16 to i64
%19 = sub i64 %17, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
br label %21
21: ; preds = %25, %14
%22 = load i32, i32* %5
%23 = add nsw i32 %22, -1
store i32 %23, i32* %5
%24 = icmp ne i32 %22, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @stdout
%27 = call i32 @putc(i8 signext 32, i32 %26)
br label %21
28: ; preds = %21
%29 = load i8*, i8** %6
%30 = call i32 @puts(i8* %29)
br label %33
31: ; preds = %0
%32 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"^\00"
@.str.1 = [56 x i8] c"A string searching example consisting of this sentence.\00"
@.str.2 = [6 x i8] c"sting\00"
@stdout = global i32 0
@.str.3 = [19 x i8] c"Pattern not found.\00"
define i32 @main() {
%1 = tail call i8* @BoyerMooreSearch(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i8* %1, null
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = ptrtoint i8* %1 to i64
%6 = trunc i64 %5 to i32
%7 = sub i32 %6, ptrtoint ([56 x i8]* @.str.1 to i32)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %4, %9
%10 = phi i32 [ %11, %9 ], [ %7, %4 ]
%11 = add nsw i32 %10, -1
%12 = load i32, i32* @stdout
%13 = tail call i32 @putc(i8 signext 32, i32 %12)
%14 = icmp eq i32 %11, 0
br i1 %14, label %15, label %9
15: ; preds = %9, %0, %4
%16 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %9 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
ret i32 0
}