#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*/ cpy_array(int const *, int *, int);
int /*<<< orphan*/ printf(char *, char *, int, double);
void execute_sort(int const orig[], int copy[], int array_size, char *sort_name,
                  void (*sort_function)(int[], int)) {
  cpy_array(orig, copy, array_size);
  clock_t before = clock();
  sort_function(copy, array_size);
  printf("\n%s of %d items took %f seconds\n", sort_name, array_size,
         (double)(clock() - before) / CLOCKS_PER_SEC);
}


x86 assembly (clang, -O0):
<execute_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <cpy_array@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   *%rax
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e49(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_sort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8,%r15
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%rbx
call   1030 <cpy_array@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %ebp,%esi
call   *%r15
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r12,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e78(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe85(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"\0A%s of %d items took %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @execute_sort(i32* %0, i32* %1, i32 %2, i8* %3, void (i32*, i32)* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca void (i32*, i32)*
%11 = alloca i64
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store void (i32*, i32)* %4, void (i32*, i32)** %10
%12 = load i32*, i32** %6
%13 = load i32*, i32** %7
%14 = load i32, i32* %8
%15 = call i32 @cpy_array(i32* %12, i32* %13, i32 %14)
%16 = call i64 (...) @clock()
store i64 %16, i64* %11
%17 = load void (i32*, i32)*, void (i32*, i32)** %10
%18 = load i32*, i32** %7
%19 = load i32, i32* %8
%20 = load i8*, i8** %9
%21 = load i32, i32* %8
%22 = call i64 (...) @clock()
%23 = load i64, i64* %11
%24 = sub nsw i64 %22, %23
%25 = sitofp i64 %24 to double
%26 = load double, double* @CLOCKS_PER_SEC
%27 = fdiv double %25, %26
%28 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21, double %27)
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A%s of %d items took %f seconds\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define void @execute_sort(i32* %0, i32* %1, i32 %2, i8* %3, void (i32*, i32)* nocapture %4) {
%6 = tail call i32 @cpy_array(i32* %0, i32* %1, i32 %2)
%7 = tail call i64 (...) @clock()
tail call void %4(i32* %1, i32 %2)
%8 = tail call i64 (...) @clock()
%9 = sub nsw i64 %8, %7
%10 = sitofp i64 %9 to double
%11 = load double, double* @CLOCKS_PER_SEC
%12 = fdiv double %10, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %2, double %12)
ret void
}