#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 /*<<< orphan*/ v;

/* Variables and functions */
double getMilliseconds();
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ quick_sort(int *, int);
int main(void) {
  int i;
  double timer = getMilliseconds();
  for (i = 0; i < 100 * 1000; i++) {
    int v[] = {5, 2, 4, 8, 5, 8, 3, 2, 9, 0, 12, 4, 25, 5, 6};
    int n = sizeof(v) / sizeof(int);
    quick_sort(v, n);
  }
  timer = getMilliseconds() - timer;
  printf("[ test program ] time elapsed: %.3f sec\n", timer / 1000.0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getMilliseconds@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x186a0,-0x8(%rbp)
jge    11a5 <main+0x65>
lea    -0x50(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x3c,%edx
call   1050 <memcpy@plt>
movl   $0xf,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1060 <quick_sort@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x22>
mov    $0x0,%al
call   1040 <getMilliseconds@plt>
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
xor    %eax,%eax
call   1040 <getMilliseconds@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x186a0,%ebp
lea    0x10(%rsp),%rbx
nopl   (%rax)
movups 0xee5(%rip),%xmm0
movups %xmm0,0x3c(%rsp)
movaps 0xecd(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movapd 0xe94(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0xf,%esi
call   1050 <quick_sort@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
call   1040 <getMilliseconds@plt>
subsd  0x8(%rsp),%xmm0
divsd  0xe57(%rip),%xmm0
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.v = [15 x i32] [i32 5, i32 2, i32 4, i32 8, i32 5, i32 8, i32 3, i32 2, i32 9, i32 0, i32 12, i32 4, i32 25, i32 5, i32 6]
@.str = [41 x i8] c"[ test program ] time elapsed: %.3f sec\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca [15 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = call double (...) @getMilliseconds()
store double %6, double* %3
store i32 0, i32* %2
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 100000
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = bitcast [15 x i32]* %4 to i8*
store i32 15, i32* %5
%12 = getelementptr inbounds [15 x i32], [15 x i32]* %4, i64 0, i64 0
%13 = load i32, i32* %5
%14 = call i32 @quick_sort(i32* %12, i32 %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %7
18: ; preds = %7
%19 = call double (...) @getMilliseconds()
%20 = load double, double* %3
%21 = fsub double %19, %20
store double %21, double* %3
%22 = load double, double* %3
%23 = fdiv double %22, 1.000000e+03
%24 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %23)
ret i32 0
}

LLVM IR (-O2):
@__const.main.v = [15 x i32] [i32 5, i32 2, i32 4, i32 8, i32 5, i32 8, i32 3, i32 2, i32 9, i32 0, i32 12, i32 4, i32 25, i32 5, i32 6]
@.str = [41 x i8] c"[ test program ] time elapsed: %.3f sec\0A\00"
define i32 @main() {
%1 = alloca [15 x i32]
%2 = tail call double (...) @getMilliseconds()
%3 = bitcast [15 x i32]* %1 to i8*
%4 = getelementptr inbounds [15 x i32], [15 x i32]* %1, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %8, %5 ]
%7 = call i32 @quick_sort(i32* %4, i32 15)
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 100000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = call double (...) @getMilliseconds()
%12 = fsub double %11, %2
%13 = fdiv double %12, 1.000000e+03
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %13)
ret i32 0
}