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

/* Variables and functions */
int CLOCKS_PER_SEC;
int clock();
int /*<<< orphan*/ findMaxElement(int *, int);
float getTimeForFindMaxElement(int arr[], int arrSize) {
  int i;
  float total = 0.0;
  clock_t start, stop;
  for (i = 0; i < 5000; i++) {
    start = clock();
    findMaxElement(arr, arrSize);
    stop = clock();
    total += (float)(1000 * (stop - start) / CLOCKS_PER_SEC);
  }
  total = (float)total / 5000;
  return total;
}


x86 assembly (clang, -O0):
<getTimeForFindMaxElement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1388,-0x10(%rbp)
jge    119d <getTimeForFindMaxElement+0x7d>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <findMaxElement@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
imul   $0x3e8,%eax,%eax
mov    0x2e6a(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2ss %eax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <getTimeForFindMaxElement+0x1e>
movss  -0x14(%rbp),%xmm0
movss  0xe56(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimeForFindMaxElement>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
xorps  %xmm0,%xmm0
mov    $0x1388,%ebx
mov    0x2ea7(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <findMaxElement@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %ebp,%eax
imul   $0x3e8,%eax,%eax
cltd
idivl  (%r12)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xc(%rsp),%xmm0
add    $0xffffffff,%ebx
jne    1150 <getTimeForFindMaxElement+0x30>
divss  0xe58(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i32 0
define float @getTimeForFindMaxElement(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store float 0.000000e+00, float* %6
store i32 0, i32* %5
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 5000
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = call i32 (...) @clock()
store i32 %13, i32* %7
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @findMaxElement(i32* %14, i32 %15)
%17 = call i32 (...) @clock()
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = load i32, i32* %7
%20 = sub nsw i32 %18, %19
%21 = mul nsw i32 1000, %20
%22 = load i32, i32* @CLOCKS_PER_SEC
%23 = sdiv i32 %21, %22
%24 = sitofp i32 %23 to float
%25 = load float, float* %6
%26 = fadd float %25, %24
store float %26, float* %6
br label %27
27: ; preds = %12
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %9
30: ; preds = %9
%31 = load float, float* %6
%32 = fdiv float %31, 5.000000e+03
store float %32, float* %6
%33 = load float, float* %6
ret float %33
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i32 0
define float @getTimeForFindMaxElement(i32* %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %15, %3 ]
%5 = phi float [ 0.000000e+00, %2 ], [ %14, %3 ]
%6 = tail call i32 (...) @clock()
%7 = tail call i32 @findMaxElement(i32* %0, i32 %1)
%8 = tail call i32 (...) @clock()
%9 = sub nsw i32 %8, %6
%10 = mul nsw i32 %9, 1000
%11 = load i32, i32* @CLOCKS_PER_SEC
%12 = sdiv i32 %10, %11
%13 = sitofp i32 %12 to float
%14 = fadd float %5, %13
%15 = add nuw nsw i32 %4, 1
%16 = icmp eq i32 %15, 5000
br i1 %16, label %17, label %3
17: ; preds = %3
%18 = fdiv float %14, 5.000000e+03
ret float %18
}