#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 */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
int *copy_array(int *, int);
int /*<<< orphan*/ free(int *);
float benchmark(int *l, int n, void (*func)(int *, int, int)) {
  int *sample = copy_array(l, n);
  clock_t cycles, tick_count = clock();
  func(sample, 0, n - 1);
  cycles = clock() - tick_count;
  free(sample);
  return (float)cycles / (float)CLOCKS_PER_SEC;
}


x86 assembly (clang, -O0):
<benchmark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <copy_array@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   *%rax
mov    $0x0,%al
call   1040 <clock@plt>
sub    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cvtsi2ssq -0x28(%rbp),%xmm0
mov    0x2e53(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<benchmark>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
call   1050 <copy_array@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r15
add    $0xffffffff,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   *%r14
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbp
sub    %r15,%rbp
mov    %rbx,%rdi
call   1030 <free@plt>
cvtsi2ss %rbp,%xmm0
mov    0x2e6c(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global i64 0
define float @benchmark(i32* %0, i32 %1, void (i32*, i32, i32)* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca void (i32*, i32, i32)*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store void (i32*, i32, i32)* %2, void (i32*, i32, i32)** %6
%10 = load i32*, i32** %4
%11 = load i32, i32* %5
%12 = call i32* @copy_array(i32* %10, i32 %11)
store i32* %12, i32** %7
%13 = call i64 (...) @clock()
store i64 %13, i64* %9
%14 = load void (i32*, i32, i32)*, void (i32*, i32, i32)** %6
%15 = load i32*, i32** %7
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = call i64 (...) @clock()
%19 = load i64, i64* %9
%20 = sub nsw i64 %18, %19
store i64 %20, i64* %8
%21 = load i32*, i32** %7
%22 = call i32 @free(i32* %21)
%23 = load i64, i64* %8
%24 = sitofp i64 %23 to float
%25 = load i64, i64* @CLOCKS_PER_SEC
%26 = sitofp i64 %25 to float
%27 = fdiv float %24, %26
ret float %27
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global i64 0
define float @benchmark(i32* %0, i32 %1, void (i32*, i32, i32)* nocapture %2) {
%4 = tail call i32* @copy_array(i32* %0, i32 %1)
%5 = tail call i64 (...) @clock()
%6 = add nsw i32 %1, -1
tail call void %2(i32* %4, i32 0, i32 %6)
%7 = tail call i64 (...) @clock()
%8 = sub nsw i64 %7, %5
%9 = tail call i32 @free(i32* %4)
%10 = sitofp i64 %8 to float
%11 = load i64, i64* @CLOCKS_PER_SEC
%12 = sitofp i64 %11 to float
%13 = fdiv float %10, %12
ret float %13
}