#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__ check(int *, int *, int);
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, char *, ...);
void sort_test(void (*sort)(int *, int), int *data, int *answer, int size,
               char *name) {
  clock_t start, end;
  start = clock();
  sort(data, size);
  end = clock();
  printf("%s finished, time taken: %.4fs\n", name,
         (double)(end - start) / CLOCKS_PER_SEC);
  if (check(data, answer, 100000) != 0)
    printf("%s failed\n", name);
}


x86 assembly (clang, -O0):
<sort_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   *%rax
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rax
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e62(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x186a0,%edx
call   1050 <check@plt>
cmp    $0x0,%rax
je     11c6 <sort_test+0x96>
mov    -0x28(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r15
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %r13d,%esi
call   *%rbx
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbp,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e76(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe83(%rip),%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x186a0,%edx
call   1050 <check@plt>
test   %rax,%rax
je     11bb <sort_test+0x8b>
lea    0xe7d(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%s finished, time taken: %.4fs\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [11 x i8] c"%s failed\0A\00"
define void @sort_test(void (i32*, i32)* %0, i32* %1, i32* %2, i32 %3, i8* %4) {
%6 = alloca void (i32*, i32)*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
store void (i32*, i32)* %0, void (i32*, i32)** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%13 = call i64 (...) @clock()
store i64 %13, i64* %11
%14 = load void (i32*, i32)*, void (i32*, i32)** %6
%15 = load i32*, i32** %7
%16 = load i32, i32* %9
%17 = call i64 (...) @clock()
store i64 %17, i64* %12
%18 = load i8*, i8** %10
%19 = load i64, i64* %12
%20 = load i64, i64* %11
%21 = sub nsw i64 %19, %20
%22 = sitofp i64 %21 to double
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %18, double %24)
%26 = load i32*, i32** %7
%27 = load i32*, i32** %8
%28 = call i64 @check(i32* %26, i32* %27, i32 100000)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %5
%31 = load i8*, i8** %10
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %5
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"%s finished, time taken: %.4fs\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [11 x i8] c"%s failed\0A\00"
define void @sort_test(void (i32*, i32)* nocapture %0, i32* %1, i32* %2, i32 %3, i8* %4) {
%6 = tail call i64 (...) @clock()
tail call void %0(i32* %1, i32 %3)
%7 = tail call i64 (...) @clock()
%8 = sub nsw i64 %7, %6
%9 = sitofp i64 %8 to double
%10 = load double, double* @CLOCKS_PER_SEC
%11 = fdiv double %9, %10
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %4, double %11)
%13 = tail call i64 @check(i32* %1, i32* %2, i32 100000)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %5
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %17
17: ; preds = %15, %5
ret void
}