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

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ randomInitialize(int *, int, int, int);
void stub1(int *, int);
double average_CPU_time(void (*sortFuncPtr)(int[], int), int arr[], int size,
                        int numRuns) {
  int i;
  double total = 0.0;
  clock_t start, end;
  for (i = 0; i < numRuns; ++i) {
    randomInitialize(arr, size, 1, 999);
    start = clock();
    (*sortFuncPtr)(arr, size);
    end = clock();
    total += ((double)(end - start)) / CLOCKS_PER_SEC;
  }
  return total / numRuns;
}


x86 assembly (clang, -O0):
<average_CPU_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ba <average_CPU_time+0x9a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
mov    $0x3e7,%ecx
call   1040 <randomInitialize@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   *%rax
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e4a(%rip),%rax
divsd  (%rax),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <average_CPU_time+0x25>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<average_CPU_time>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %ecx,%ecx
mov    %ecx,0xc(%rsp)
jle    11a8 <average_CPU_time+0x88>
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%r15
xorpd  %xmm0,%xmm0
mov    0x2e9e(%rip),%r13
mov    %ecx,%r14d
nopl   (%rax)
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    $0x3e7,%ecx
call   1040 <randomInitialize@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %r12d,%esi
call   *%r15
xor    %eax,%eax
call   1030 <clock@plt>
movsd  0x10(%rsp),%xmm0
sub    %rbp,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
divsd  0x0(%r13),%xmm1
addsd  %xmm1,%xmm0
add    $0xffffffff,%r14d
jne    1150 <average_CPU_time+0x30>
jmp    11ac <average_CPU_time+0x8c>
xorpd  %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl 0xc(%rsp),%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @average_CPU_time(void (i32*, i32)* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca void (i32*, i32)*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i64
%12 = alloca i64
store void (i32*, i32)* %0, void (i32*, i32)** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %10
store i32 0, i32* %9
br label %13
13: ; preds = %34, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %37
17: ; preds = %13
%18 = load i32*, i32** %6
%19 = load i32, i32* %7
%20 = call i32 @randomInitialize(i32* %18, i32 %19, i32 1, i32 999)
%21 = call i64 (...) @clock()
store i64 %21, i64* %11
%22 = load void (i32*, i32)*, void (i32*, i32)** %5
%23 = load i32*, i32** %6
%24 = load i32, i32* %7
%25 = call i64 (...) @clock()
store i64 %25, i64* %12
%26 = load i64, i64* %12
%27 = load i64, i64* %11
%28 = sub nsw i64 %26, %27
%29 = sitofp i64 %28 to double
%30 = load double, double* @CLOCKS_PER_SEC
%31 = fdiv double %29, %30
%32 = load double, double* %10
%33 = fadd double %32, %31
store double %33, double* %10
br label %34
34: ; preds = %17
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
br label %13
37: ; preds = %13
%38 = load double, double* %10
%39 = load i32, i32* %8
%40 = sitofp i32 %39 to double
%41 = fdiv double %38, %40
ret double %41
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @average_CPU_time(void (i32*, i32)* nocapture %0, i32* %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %19
6: ; preds = %4, %6
%7 = phi i32 [ %17, %6 ], [ 0, %4 ]
%8 = phi double [ %16, %6 ], [ 0.000000e+00, %4 ]
%9 = tail call i32 @randomInitialize(i32* %1, i32 %2, i32 1, i32 999)
%10 = tail call i64 (...) @clock()
tail call void %0(i32* %1, i32 %2)
%11 = tail call i64 (...) @clock()
%12 = sub nsw i64 %11, %10
%13 = sitofp i64 %12 to double
%14 = load double, double* @CLOCKS_PER_SEC
%15 = fdiv double %13, %14
%16 = fadd double %8, %15
%17 = add nuw nsw i32 %7, 1
%18 = icmp eq i32 %17, %3
br i1 %18, label %19, label %6
19: ; preds = %6, %4
%20 = phi double [ 0.000000e+00, %4 ], [ %16, %6 ]
%21 = sitofp i32 %3 to double
%22 = fdiv double %20, %21
ret double %22
}