#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ BoyerMooreHorspool(char *, int /*<<< orphan*/, char *,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
scalar_t__ malloc(long);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  long tamanho_arquivo;
  FILE *arquivo = fopen(argv[2], "r");
  fseek(arquivo, 0L, SEEK_END);
  tamanho_arquivo = ftell(arquivo);
  fseek(arquivo, 0L, SEEK_SET);
  char *palavra = (char *)malloc(20 * sizeof(char));
  char *linha = (char *)malloc(100 * sizeof(char));
  char *texto = (char *)malloc(tamanho_arquivo * sizeof(char));
  strcpy(texto, "");
  while (!feof(arquivo)) {
    fscanf(arquivo, "%[^\r\n]s", linha);
    fscanf(arquivo, "\r\n");
    palavra = strtok(linha, " 0123456789/");
    while (palavra != NULL) {
      strcat(texto, palavra);
      palavra = strtok(NULL, " 0123456789/");
    }
  }
  fclose(arquivo);
  BoyerMooreHorspool(texto, strlen(texto), argv[1], strlen(argv[1]));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1b(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <fseek@plt>
mov    $0x14,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x64,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
shl    $0x0,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1282 <main+0xc2>
jmp    12f4 <main+0x134>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd71(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x30(%rbp),%rdi
lea    0xd58(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12ef <main+0x12f>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10e0 <strcat@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd2c(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    12be <main+0xfe>
jmp    1264 <main+0xa4>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%rdx
mov    %eax,%ecx
call   1050 <BoyerMooreHorspool@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
mov    0x10(%rsi),%rdi
lea    0xe26(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    %r15,%rdi
call   1080 <ftell@plt>
mov    %rax,%rbx
mov    0x2dd1(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10b0 <fseek@plt>
mov    $0x14,%edi
call   10a0 <malloc@plt>
mov    $0x64,%edi
call   10a0 <malloc@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
lea    0xdd0(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     1294 <main+0xd4>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r14d
mov    (%rsp),%rax
mov    0x8(%rax),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
mov    %eax,%ecx
call   1050 <BoyerMooreHorspool@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd67(%rip),%r13
lea    0xd68(%rip),%rbp
lea    0xd64(%rip),%r14
jmp    12bc <main+0xfc>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1090 <feof@plt>
test   %eax,%eax
jne    1250 <main+0x90>
mov    %r15,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    %r12,%rdi
nopl   0x0(%rax)
mov    %r14,%rsi
call   10d0 <strtok@plt>
test   %rax,%rax
je     12b0 <main+0xf0>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10e0 <strcat@plt>
xor    %edi,%edi
jmp    12e0 <main+0x120>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [8 x i8] c"%[^\0D\0A]s\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [13 x i8] c" 0123456789/\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 2
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = load i32, i32* @SEEK_END
%17 = call i32 @fseek(i32* %15, i64 0, i32 %16)
%18 = load i32*, i32** %7
%19 = call i64 @ftell(i32* %18)
store i64 %19, i64* %6
%20 = load i32*, i32** %7
%21 = load i32, i32* @SEEK_SET
%22 = call i32 @fseek(i32* %20, i64 0, i32 %21)
%23 = call i64 @malloc(i64 20)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %8
%25 = call i64 @malloc(i64 100)
%26 = inttoptr i64 %25 to i8*
store i8* %26, i8** %9
%27 = load i64, i64* %6
%28 = mul i64 %27, 1
%29 = call i64 @malloc(i64 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %10
%31 = load i8*, i8** %10
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %54, %2
%34 = load i32*, i32** %7
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %55
38: ; preds = %33
%39 = load i32*, i32** %7
%40 = load i8*, i8** %9
%41 = call i32 (i32*, i8*, ...) @fscanf(i32* %39, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = load i32*, i32** %7
%43 = call i32 (i32*, i8*, ...) @fscanf(i32* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%44 = load i8*, i8** %9
%45 = call i8* @strtok(i8* %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i8* %45, i8** %8
br label %46
46: ; preds = %49, %38
%47 = load i8*, i8** %8
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i8*, i8** %10
%51 = load i8*, i8** %8
%52 = call i32 @strcat(i8* %50, i8* %51)
%53 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i8* %53, i8** %8
br label %46
54: ; preds = %46
br label %33
55: ; preds = %33
%56 = load i32*, i32** %7
%57 = call i32 @fclose(i32* %56)
%58 = load i8*, i8** %10
%59 = load i8*, i8** %10
%60 = call i32 @strlen(i8* %59)
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = call i32 @strlen(i8* %66)
%68 = call i32 @BoyerMooreHorspool(i8* %58, i32 %60, i8* %63, i32 %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [8 x i8] c"%[^\0D\0A]s\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
@.str.4 = [13 x i8] c" 0123456789/\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %5, i64 0, i32 %6)
%8 = tail call i64 @ftell(i32* %5)
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %5, i64 0, i32 %9)
%11 = tail call i64 @malloc(i64 20)
%12 = tail call i64 @malloc(i64 100)
%13 = inttoptr i64 %12 to i8*
%14 = tail call i64 @malloc(i64 %8)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @feof(i32* %5)
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %32
19: ; preds = %27, %22
%20 = tail call i32 @feof(i32* %5)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %32
22: ; preds = %2, %19
%23 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%24 = tail call i32 (i32*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i8* @strtok(i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %19, label %27
27: ; preds = %22, %27
%28 = phi i8* [ %30, %27 ], [ %25, %22 ]
%29 = tail call i32 @strcat(i8* %15, i8* %28)
%30 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i8* %30, null
br i1 %31, label %19, label %27
32: ; preds = %19, %2
%33 = tail call i32 @fclose(i32* %5)
%34 = tail call i32 @strlen(i8* %15)
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
%37 = tail call i32 @strlen(i8* %36)
%38 = tail call i32 @BoyerMooreHorspool(i8* %15, i32 %34, i8* %36, i32 %37)
ret i32 0
}