#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);
int rand();
double vrijemeZaRandomGeneriranePodnizoveOcc(int brojTestnihPrimjerka,
                                             int lengthOfInput, char *S,
                                             char *B, int duzinaAbecede,
                                             char *abeceda, int C[]) {
  int i = 0;
  clock_t beginStatTime, endStatTime;
  int duzinaRandomGeneriranogNiza = 0;
  double aritmetickaSredina = 0;
  double sum = 0;
  char *randomPodNiz;
  for (i = 0; i < brojTestnihPrimjerka; i++) {
    duzinaRandomGeneriranogNiza = rand() % lengthOfInput;
    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);
    free(randomPodNiz);
  }
  aritmetickaSredina = (double)sum / i;
  return aritmetickaSredina;
}


x86 assembly (clang, -O0):
<vrijemeZaRandomGeneriranePodnizoveOcc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
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)
movl   $0x0,-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    1272 <vrijemeZaRandomGeneriranePodnizoveOcc+0x112>
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x44(%rbp)
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    0x10(%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    0x2dc0(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdcd(%rip),%rdi
call   1060 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
mov    0x2d9a(%rip),%rax
divsd  (%rax),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a7 <vrijemeZaRandomGeneriranePodnizoveOcc+0x47>
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):
<vrijemeZaRandomGeneriranePodnizoveOcc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %edi,%edi
jle    1281 <vrijemeZaRandomGeneriranePodnizoveOcc+0x121>
mov    %r9,%r13
mov    %r8d,%ebp
mov    %esi,%ebx
mov    %edi,0x1c(%rsp)
mov    %edi,%eax
neg    %eax
mov    %rax,0x30(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0x1,%r12d
mov    %rcx,0x28(%rsp)
mov    %rdx,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <rand@plt>
cltd
idiv   %ebx
mov    %r13,%rdi
mov    %edx,%esi
mov    %ebp,%edx
call   1070 <generirajRandomStringNadAbecedom@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x70(%rsp),%rax
mov    %rax,(%rsp)
mov    %r14,%rdi
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    %r13,%rcx
mov    %ebx,%r8d
mov    %ebp,%r9d
call   1040 <FMindex@plt>
xor    %eax,%eax
call   1050 <clock@plt>
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2dd4(%rip),%r15
divsd  (%r15),%xmm0
lea    0xde8(%rip),%rdi
mov    %r12d,%esi
call   1060 <printf@plt>
movsd  0x8(%rsp),%xmm1
divsd  (%r15),%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rax
add    %r12d,%eax
add    $0x1,%eax
mov    %r12d,%ecx
add    $0x1,%ecx
mov    %ecx,%r12d
cmp    $0x1,%eax
jne    11b0 <vrijemeZaRandomGeneriranePodnizoveOcc+0x50>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x1c(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    1289 <vrijemeZaRandomGeneriranePodnizoveOcc+0x129>
movsd  0xd77(%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 @vrijemeZaRandomGeneriranePodnizoveOcc(i32 %0, i32 %1, i8* %2, i8* %3, i32 %4, i8* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i32* %6, i32** %14
store i32 0, i32* %15
store i32 0, i32* %18
store double 0.000000e+00, double* %19
store double 0.000000e+00, double* %20
store i32 0, i32* %15
br label %22
22: ; preds = %61, %7
%23 = load i32, i32* %15
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %64
26: ; preds = %22
%27 = call i32 (...) @rand()
%28 = load i32, i32* %9
%29 = srem i32 %27, %28
store i32 %29, i32* %18
%30 = load i8*, i8** %13
%31 = load i32, i32* %18
%32 = load i32, i32* %12
%33 = call i8* @generirajRandomStringNadAbecedom(i8* %30, i32 %31, i32 %32)
store i8* %33, i8** %21
%34 = call double (...) @clock()
store double %34, double* %16
%35 = load i8*, i8** %21
%36 = load i8*, i8** %10
%37 = load i8*, i8** %11
%38 = load i8*, i8** %13
%39 = load i32, i32* %9
%40 = load i32, i32* %12
%41 = load i32*, i32** %14
%42 = call i32 @FMindex(i8* %35, i8* %36, i8* %37, i8* %38, i32 %39, i32 %40, i32* %41)
%43 = call double (...) @clock()
store double %43, double* %17
%44 = load i32, i32* %15
%45 = add nsw i32 %44, 1
%46 = load double, double* %17
%47 = load double, double* %16
%48 = fsub double %46, %47
%49 = load double, double* @CLOCKS_PER_SEC
%50 = fdiv double %48, %49
%51 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %45, double %50)
%52 = load double, double* %20
%53 = load double, double* %17
%54 = load double, double* %16
%55 = fsub double %53, %54
%56 = load double, double* @CLOCKS_PER_SEC
%57 = fdiv double %55, %56
%58 = fadd double %52, %57
store double %58, double* %20
%59 = load i8*, i8** %21
%60 = call i32 @free(i8* %59)
br label %61
61: ; preds = %26
%62 = load i32, i32* %15
%63 = add nsw i32 %62, 1
store i32 %63, i32* %15
br label %22
64: ; preds = %22
%65 = load double, double* %20
%66 = load i32, i32* %15
%67 = sitofp i32 %66 to double
%68 = fdiv double %65, %67
store double %68, double* %19
%69 = load double, double* %19
ret double %69
}

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