#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 /*<<< orphan*/ bubbleSort(int *, int);
int clock();
int /*<<< orphan*/ fillArray(int *, int);
float getTimeForBubbleSort(int arr[], int arrSize) {
  int i;
  float total = 0.0;
  clock_t start, stop;
  for (i = 0; i < 5000; i++) {
    start = clock();
    bubbleSort(arr, arrSize);
    stop = clock();
    total += (float)(1000 * (stop - start) / CLOCKS_PER_SEC);
    fillArray(arr, arrSize);
  }
  total = (float)total / 5000;
  return total;
}


x86 assembly (clang, -O0):
<getTimeForBubbleSort>:
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    11b9 <getTimeForBubbleSort+0x89>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <bubbleSort@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    0x2e5a(%rip),%rcx
cltd
idivl  (%rcx)
cvtsi2ss %eax,%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <fillArray@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <getTimeForBubbleSort+0x1e>
movss  -0x14(%rbp),%xmm0
movss  0xe3a(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTimeForBubbleSort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x1388,%ebx
mov    0x2e91(%rip),%r12
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r14d,%esi
call   1050 <bubbleSort@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)
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <fillArray@plt>
add    $0xffffffff,%ebx
jne    1160 <getTimeForBubbleSort+0x30>
movss  0xc(%rsp),%xmm0
divss  0xe43(%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 @getTimeForBubbleSort(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 = %30, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 5000
br i1 %11, label %12, label %33
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 @bubbleSort(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
%27 = load i32*, i32** %3
%28 = load i32, i32* %4
%29 = call i32 @fillArray(i32* %27, i32 %28)
br label %30
30: ; preds = %12
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %9
33: ; preds = %9
%34 = load float, float* %6
%35 = fdiv float %34, 5.000000e+03
store float %35, float* %6
%36 = load float, float* %6
ret float %36
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i32 0
define float @getTimeForBubbleSort(i32* %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %16, %3 ]
%5 = phi float [ 0.000000e+00, %2 ], [ %14, %3 ]
%6 = tail call i32 (...) @clock()
%7 = tail call i32 @bubbleSort(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 = tail call i32 @fillArray(i32* %0, i32 %1)
%16 = add nuw nsw i32 %4, 1
%17 = icmp eq i32 %16, 5000
br i1 %17, label %18, label %3
18: ; preds = %3
%19 = fdiv float %14, 5.000000e+03
ret float %19
}