#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 double clock_t;

/* Variables and functions */
int /*<<< orphan*/ BF(char *, int /*<<< orphan*/, char *, int);
scalar_t__ CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int readfile(char *, char **);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  char pattern[256];
  char filename[256];
  char *text;
  int n;
  clock_t initemps;
  sprintf(pattern, "%s", argv[2]);
  sprintf(filename, "%s", argv[1]);
  printf("pattern: %s \n", pattern);
  n = readfile(filename, &text);
  initemps = clock();
  BF(pattern, strlen(pattern), text, n);
  printf("Nombre de segons: %f s\n",
         (clock() - initemps) / (double)CLOCKS_PER_SEC);
  free(text);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe61(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe46(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x210(%rbp),%rdi
lea    -0x218(%rbp),%rsi
call   1090 <readfile@plt>
mov    %eax,-0x21c(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0x228(%rbp)
ff
lea    -0x110(%rbp),%rax
mov    %rax,-0x230(%rbp)
lea    -0x110(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x230(%rbp),%rdi
mov    %eax,%esi
mov    -0x218(%rbp),%rdx
mov    -0x21c(%rbp),%ecx
call   1070 <BF@plt>
mov    $0x0,%al
call   1040 <clock@plt>
subsd  -0x228(%rbp),%xmm0
ff
mov    0x2da1(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xdba(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    -0x218(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rsi
lea    0x110(%rsp),%r14
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x8(%rbx),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe57(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1090 <readfile@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    (%rsp),%rdx
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%ecx
call   1080 <BF@plt>
xor    %eax,%eax
call   1050 <clock@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2def(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xe05(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [14 x i8] c"pattern: %s \0A\00"
@.str.2 = [24 x i8] c"Nombre de segons: %f s\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%24 = call i32 @readfile(i8* %23, i8** %8)
store i32 %24, i32* %9
%25 = call double (...) @clock()
store double %25, double* %10
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = load i8*, i8** %8
%30 = load i32, i32* %9
%31 = call i32 @BF(i8* %26, i32 %28, i8* %29, i32 %30)
%32 = call double (...) @clock()
%33 = load double, double* %10
%34 = fsub double %32, %33
%35 = load i64, i64* @CLOCKS_PER_SEC
%36 = sitofp i64 %35 to double
%37 = fdiv double %34, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"pattern: %s \0A\00"
@.str.2 = [24 x i8] c"Nombre de segons: %f s\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = bitcast i8** %5 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = call i8* @strcpy(i8* %6, i8* dereferenceable(1) %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i8* @strcpy(i8* %7, i8* dereferenceable(1) %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%16 = call i32 @readfile(i8* %7, i8** %5)
%17 = call double (...) @clock()
%18 = call i32 @strlen(i8* %6)
%19 = load i8*, i8** %5
%20 = call i32 @BF(i8* %6, i32 %18, i8* %19, i32 %16)
%21 = call double (...) @clock()
%22 = fsub double %21, %17
%23 = load i64, i64* @CLOCKS_PER_SEC
%24 = sitofp i64 %23 to double
%25 = fdiv double %22, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = load i8*, i8** %5
%28 = call i32 @free(i8* %27)
ret i32 0
}