#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 */
double CLOCKS_PER_SEC;
int /*<<< orphan*/ FMindex(char *, char *, char *, char *, int, int, int *);
double clock();
int /*<<< orphan*/ free(char *);
char *generirajRandomStringNadAbecedom(char *, int, int);
int /*<<< orphan*/ printf(char *, int, double);
double vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc(
    int brojTestnihPrimjerka, int lengthOfInput, char *S, char *B,
    int duzinaAbecede, char *abeceda, int duzinaPodnizova,
    double *tablicaVrijednosti, int C[]) {
  int i = 0;
  clock_t beginStatTime, endStatTime;
  int duzinaRandomGeneriranogNiza = duzinaPodnizova;
  double aritmetickaSredina = 0;
  double sum = 0;
  char *randomPodNiz;
  for (i = 0; i < brojTestnihPrimjerka; i++) {
    randomPodNiz = generirajRandomStringNadAbecedom(
        abeceda, duzinaRandomGeneriranogNiza, duzinaAbecede);
    beginStatTime = clock();
    FMindex(randomPodNiz, S, B, abeceda, lengthOfInput, duzinaAbecede, C);
    endStatTime = clock();
    printf("\n%4d. %.10f", i + 1,
           ((double)endStatTime - beginStatTime) / CLOCKS_PER_SEC);
    sum = sum + (((double)endStatTime - beginStatTime) / CLOCKS_PER_SEC);
    *(tablicaVrijednosti + i) =
        (((double)endStatTime - beginStatTime) / CLOCKS_PER_SEC);
    free(randomPodNiz);
  }
  aritmetickaSredina = (double)sum / i;
  return aritmetickaSredina;
}


x86 assembly (clang, -O0):
<vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x44(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    127c <vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc+0x12c>
mov    -0x28(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1070 <generirajRandomStringNadAbecedom@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    0x20(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <FMindex@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    0x2dd8(%rip),%rax
divsd  (%rax),%xmm0
lea    0xde5(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
mov    0x2db2(%rip),%rax
divsd  (%rax),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    0x2d94(%rip),%rax
divsd  (%rax),%xmm0
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    119d <vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc+0x4d>
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %edi,%edi
jle    1277 <vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc+0x127>
mov    %r9,%r14
mov    %r8d,%ebx
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %edi,%eax
mov    %rax,0x28(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %r15d,%r15d
mov    %esi,0x20(%rsp)
mov    %rcx,0x30(%rsp)
mov    %r8d,0x24(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    0x70(%rsp),%esi
mov    %ebx,%edx
call   1070 <generirajRandomStringNadAbecedom@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x80(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r14,%rcx
mov    0x20(%rsp),%r8d
mov    %ebx,%r9d
call   1040 <FMindex@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %r14,%r12
lea    0x1(%r15),%r14
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x2de4(%rip),%rbx
divsd  (%rbx),%xmm0
lea    0xdf9(%rip),%rdi
mov    %r14d,%esi
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm1
divsd  (%rbx),%xmm1
movsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x78(%rsp),%rax
movsd  %xmm1,(%rax,%r15,8)
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r14,%r15
cmp    %r14,0x28(%rsp)
mov    %r12,%r14
mov    0x24(%rsp),%ebx
mov    0x30(%rsp),%r12
jne    11a0 <vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc+0x50>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    127f <vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc+0x12f>
movsd  0xd81(%rip),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"\0A%4d. %.10f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* %5, i32 %6, double* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca double*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca i32
%23 = alloca double
%24 = alloca double
%25 = alloca i8*
store i32 %0, i32* %10
store i32 %1, i32* %11
store i8* %2, i8** %12
store i8* %3, i8** %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store double* %7, double** %17
store i32* %8, i32** %18
store i32 0, i32* %19
%26 = load i32, i32* %16
store i32 %26, i32* %22
store double 0.000000e+00, double* %23
store double 0.000000e+00, double* %24
store i32 0, i32* %19
br label %27
27: ; preds = %72, %9
%28 = load i32, i32* %19
%29 = load i32, i32* %10
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %75
31: ; preds = %27
%32 = load i8*, i8** %15
%33 = load i32, i32* %22
%34 = load i32, i32* %14
%35 = call i8* @generirajRandomStringNadAbecedom(i8* %32, i32 %33, i32 %34)
store i8* %35, i8** %25
%36 = call double (...) @clock()
store double %36, double* %20
%37 = load i8*, i8** %25
%38 = load i8*, i8** %12
%39 = load i8*, i8** %13
%40 = load i8*, i8** %15
%41 = load i32, i32* %11
%42 = load i32, i32* %14
%43 = load i32*, i32** %18
%44 = call i32 @FMindex(i8* %37, i8* %38, i8* %39, i8* %40, i32 %41, i32 %42, i32* %43)
%45 = call double (...) @clock()
store double %45, double* %21
%46 = load i32, i32* %19
%47 = add nsw i32 %46, 1
%48 = load double, double* %21
%49 = load double, double* %20
%50 = fsub double %48, %49
%51 = load double, double* @CLOCKS_PER_SEC
%52 = fdiv double %50, %51
%53 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %47, double %52)
%54 = load double, double* %24
%55 = load double, double* %21
%56 = load double, double* %20
%57 = fsub double %55, %56
%58 = load double, double* @CLOCKS_PER_SEC
%59 = fdiv double %57, %58
%60 = fadd double %54, %59
store double %60, double* %24
%61 = load double, double* %21
%62 = load double, double* %20
%63 = fsub double %61, %62
%64 = load double, double* @CLOCKS_PER_SEC
%65 = fdiv double %63, %64
%66 = load double*, double** %17
%67 = load i32, i32* %19
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
store double %65, double* %69
%70 = load i8*, i8** %25
%71 = call i32 @free(i8* %70)
br label %72
72: ; preds = %31
%73 = load i32, i32* %19
%74 = add nsw i32 %73, 1
store i32 %74, i32* %19
br label %27
75: ; preds = %27
%76 = load double, double* %24
%77 = load i32, i32* %19
%78 = sitofp i32 %77 to double
%79 = fdiv double %76, %78
store double %79, double* %23
%80 = load double, double* %23
ret double %80
}

LLVM IR (-O2):
@.str = [12 x i8] c"\0A%4d. %.10f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @vrijemeZaRandomGeneriranePodnizoveZadaneDuzineOcc(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* %5, i32 %6, double* nocapture writeonly %7, i32* %8) {
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %35
11: ; preds = %9
%12 = zext i32 %0 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %20, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %28, %13 ]
%16 = tail call i8* @generirajRandomStringNadAbecedom(i8* %5, i32 %6, i32 %4)
%17 = tail call double (...) @clock()
%18 = tail call i32 @FMindex(i8* %16, i8* %2, i8* %3, i8* %5, i32 %1, i32 %4, i32* %8)
%19 = tail call double (...) @clock()
%20 = add nuw nsw i64 %14, 1
%21 = fsub double %19, %17
%22 = load double, double* @CLOCKS_PER_SEC
%23 = fdiv double %21, %22
%24 = trunc i64 %20 to i32
%25 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %24, double %23)
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %21, %26
%28 = fadd double %15, %27
%29 = getelementptr inbounds double, double* %7, i64 %14
store double %27, double* %29
%30 = tail call i32 @free(i8* %16)
%31 = icmp eq i64 %20, %12
br i1 %31, label %32, label %13
32: ; preds = %13
%33 = sitofp i32 %0 to double
%34 = fdiv double %28, %33
br label %35
35: ; preds = %32, %9
%36 = phi double [ %34, %32 ], [ 0x7FF8000000000000, %9 ]
ret double %36
}