#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 BoyerMoore1(unsigned char *, int, unsigned char *, int);
int BoyerMoore2(unsigned char *, int, unsigned char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int trivial(unsigned char *, int, unsigned char *, int);
int main(void) {
  unsigned char b[256];
  unsigned char a[10];
  int m, n, cont;
  if (1 == 1) {
    strcpy((char *)&b[1], "ana e mariana gostam de banana");
    strcpy((char *)&a[1], "ana");
  } else if (1 == 2) {
    strcpy((char *)&b[1], "Os algor?timos de ordena??o");
    strcpy((char *)&a[1], "algor?timo");
  } else if (1 == 3) {
    strcpy((char *)&b[1], "GTAGTATATATATATACTACTAGTAG");
    strcpy((char *)&a[1], "TACTA");
  } else if (1 == 4) {
    strcpy((char *)&b[1], "XCBABXCBAAXBCBABX");
    strcpy((char *)&a[1], "BCBA");
  }
  m = strlen((char *)a) - 1;
  n = strlen((char *)b) - 1;
  if (2 == 1)
    cont = trivial(a, m, b, n);
  else if (2 == 2)
    cont = BoyerMoore1(a, m, b, n);
  else if (2 == 3)
    cont = BoyerMoore2(a, m, b, n);
  printf("Encontradas %d ocorrencia(s).\n", cont);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
lea    -0x100(%rbp),%rdi
add    $0x1,%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x10a(%rbp),%rdi
add    $0x1,%rdi
lea    0xe97(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x10a(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x110(%rbp)
lea    -0x100(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x114(%rbp)
lea    -0x10a(%rbp),%rdi
mov    -0x110(%rbp),%esi
lea    -0x100(%rbp),%rdx
mov    -0x114(%rbp),%ecx
call   1070 <BoyerMoore1@plt>
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe4d(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
lea    0x11(%rsp),%rdi
lea    0xe99(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x7(%rsp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x6(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%ebp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%ecx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1070 <BoyerMoore1@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"ana e mariana gostam de banana\00"
@.str.1 = [4 x i8] c"ana\00"
@.str.2 = [31 x i8] c"Encontradas %d ocorrencia(s).\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [10 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 1
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %3
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %4
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%17 = load i32, i32* %3
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%19 = load i32, i32* %4
%20 = call i32 @BoyerMoore1(i8* %16, i32 %17, i8* %18, i32 %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"ana e mariana gostam de banana\00"
@.str.1 = [4 x i8] c"ana\00"
@.str.2 = [31 x i8] c"Encontradas %d ocorrencia(s).\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 1
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 1
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strlen(i8* %4)
%10 = add nsw i32 %9, -1
%11 = call i32 @strlen(i8* %3)
%12 = add nsw i32 %11, -1
%13 = call i32 @BoyerMoore1(i8* %4, i32 %10, i8* %3, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}