#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;
int atoi(char *);
scalar_t__ clock();
int /*<<< orphan*/ nicksort(int *, int);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(int *, int);
int rand();
int /*<<< orphan*/ srand(scalar_t__);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  if (argc < 2 + 1) {
    usage(argv[0]);
    return 1;
  }
  int num_elements = atoi(argv[1]);
  int num_attempts = atoi(argv[2]);
  int i, j;
  clock_t begin, end;
  int q_test_array[10], n_test_array[10];
  int q_array[num_elements], n_array[num_elements];
  double q_total_time, n_total_time, q_avg_time, n_avg_time;
  printf("Beginning sanity check:\n");
  srand(clock());
  for (i = 0; i < 10; ++i) {
    q_test_array[i] = n_test_array[i] = rand() % 10;
  }
  printf("\tTest array: ");
  print_array(q_test_array, 10);
  quicksort(q_test_array, 10);
  printf("\tQuicksort:  ");
  print_array(q_test_array, 10);
  nicksort(n_test_array, 10);
  printf("\tNicksort:   ");
  print_array(n_test_array, 10);
  for (i = 0; i < num_attempts; ++i) {
    srand(clock());
    for (j = 0; j < num_elements; ++j) {
      q_array[j] = n_array[j] = rand() % num_elements;
    }
    begin = clock();
    quicksort(q_array, num_elements);
    end = clock();
    q_total_time += ((double)end - (double)begin) / CLOCKS_PER_SEC;
    begin = clock();
    nicksort(n_array, num_elements);
    end = clock();
    n_total_time += ((double)end - (double)begin) / CLOCKS_PER_SEC;
  }
  q_avg_time = q_total_time / num_attempts;
  n_avg_time = n_total_time / num_attempts;
  printf("Testing finished, statistics (in seconds):\n");
  printf("\tQuicksort total time:   %f\n", q_total_time);
  printf("\tQuicksort average time: %f\n", q_avg_time);
  printf("\tNicksort total time:    %f\n", n_total_time);
  printf("\tNicksort average time:  %f\n", n_avg_time);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11cb <main+0x3b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    14d6 <main+0x346>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x98(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xd8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xa0(%rbp)
mov    -0x14(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xd0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xa8(%rbp)
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,%rdi
call   1080 <srand@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    129f <main+0x10f>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
movslq -0x1c(%rbp),%rax
mov    %edx,-0x90(%rbp,%rax,4)
movslq -0x1c(%rbp),%rax
mov    %edx,-0x60(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1265 <main+0xd5>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1040 <print_array@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1050 <quicksort@plt>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1040 <print_array@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
call   1070 <nicksort@plt>
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0xa,%esi
call   1040 <print_array@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    142d <main+0x29d>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,%rdi
call   1080 <srand@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    137f <main+0x1ef>
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0xd0(%rbp),%rcx
cltd
idivl  -0x14(%rbp)
mov    -0xd8(%rbp),%rax
movslq -0x20(%rbp),%rsi
mov    %edx,(%rcx,%rsi,4)
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    133e <main+0x1ae>
mov    $0x0,%al
call   1030 <clock@plt>
mov    -0xd8(%rbp),%rdi
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
call   1050 <quicksort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
mov    0x2c2d(%rip),%rax
divsd  (%rax),%xmm0
addsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
mov    $0x0,%al
call   1030 <clock@plt>
mov    -0xd0(%rbp),%rdi
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
call   1070 <nicksort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
cvtsi2sdq -0x28(%rbp),%xmm1
subsd  %xmm1,%xmm0
mov    0x2bdd(%rip),%rax
divsd  (%rax),%xmm0
addsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    131c <main+0x18c>
movsd  -0xb0(%rbp),%xmm0
ff
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
lea    0xbdd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsd  -0xb0(%rbp),%xmm0
ff
lea    0xbf3(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0xc0(%rbp),%xmm0
ff
lea    0xbfa(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0xb8(%rbp),%xmm0
ff
lea    0xc01(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0xc8(%rbp),%xmm0
ff
lea    0xc08(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     11ce <main+0x2e>
mov    (%rbx),%rdi
call   10a0 <usage@plt>
mov    $0x1,%eax
jmp    15f7 <main+0x457>
mov    0x8(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,-0xa8(%rbp)
mov    %r14d,%r12d
mov    %rsp,%rcx
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rdi
call   1090 <srand@plt>
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x70(%rbp)
mov    %eax,-0xa0(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    %eax,-0x9c(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    %eax,-0x98(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    %eax,-0x94(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x60(%rbp)
mov    %eax,-0x90(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    %eax,-0x8c(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x58(%rbp)
mov    %eax,-0x88(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    %eax,-0x84(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    %eax,-0x80(%rbp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    %eax,-0x7c(%rbp)
lea    0xbf3(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    -0xa0(%rbp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <print_array@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <quicksort@plt>
lea    0xbd2(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <print_array@plt>
lea    -0x70(%rbp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <nicksort@plt>
lea    0xbb4(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1050 <print_array@plt>
mov    %ebx,-0x30(%rbp)
test   %ebx,%ebx
jle    1572 <main+0x3d2>
xor    %r15d,%r15d
jmp    1525 <main+0x385>
nop
xor    %eax,%eax
call   1040 <clock@plt>
mov    %r14,%rdi
mov    %rax,%r14
mov    %r12d,%esi
call   1060 <quicksort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14,%xmm1
subsd  %xmm1,%xmm0
mov    0x2b21(%rip),%rbx
divsd  (%rbx),%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x40(%rbp)
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    %r13,%rdi
mov    %r12d,%esi
call   1080 <nicksort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r14,%xmm1
subsd  %xmm1,%xmm0
divsd  (%rbx),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x48(%rbp)
add    $0x1,%r15d
cmp    -0x30(%rbp),%r15d
je     1572 <main+0x3d2>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rdi
call   1090 <srand@plt>
test   %r12d,%r12d
mov    -0x38(%rbp),%r14
jle    1490 <main+0x2f0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   10c0 <rand@plt>
cltd
idiv   %r12d
mov    %edx,0x0(%r13,%rbx,4)
mov    %edx,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1550 <main+0x3b0>
jmp    1490 <main+0x2f0>
xorps  %xmm0,%xmm0
cvtsi2sdl -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x30(%rbp)
lea    0xb19(%rip),%rdi
call   1030 <puts@plt>
lea    0xa81(%rip),%rdi
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xa8b(%rip),%rdi
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xa95(%rip),%rdi
movsd  -0x48(%rbp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
lea    0xa9f(%rip),%rdi
movsd  -0x30(%rbp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0xa8(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Beginning sanity check:\0A\00"
@.str.1 = [14 x i8] c"\09Test array: \00"
@.str.2 = [14 x i8] c"\09Quicksort: \00"
@.str.3 = [14 x i8] c"\09Nicksort: \00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.4 = [44 x i8] c"Testing finished, statistics (in seconds):\0A\00"
@.str.5 = [29 x i8] c"\09Quicksort total time: %f\0A\00"
@.str.6 = [29 x i8] c"\09Quicksort average time: %f\0A\00"
@.str.7 = [29 x i8] c"\09Nicksort total time: %f\0A\00"
@.str.8 = [29 x i8] c"\09Nicksort average time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca [10 x i32]
%13 = alloca [10 x i32]
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 3
br i1 %22, label %23, label %28
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @usage(i8* %26)
store i32 1, i32* %3
br label %149
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %6
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = zext i32 %37 to i64
%39 = call i8* @llvm.stacksave()
store i8* %39, i8** %14
%40 = alloca i32, i64 %38
store i64 %38, i64* %15
%41 = load i32, i32* %6
%42 = zext i32 %41 to i64
%43 = alloca i32, i64 %42
store i64 %42, i64* %16
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%45 = call i64 (...) @clock()
%46 = call i32 @srand(i64 %45)
store i32 0, i32* %8
br label %47
47: ; preds = %59, %28
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 10
br i1 %49, label %50, label %62
50: ; preds = %47
%51 = call i32 (...) @rand()
%52 = srem i32 %51, 10
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 %54
store i32 %52, i32* %55
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i64 0, i64 %57
store i32 %52, i32* %58
br label %59
59: ; preds = %50
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %47
62: ; preds = %47
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i64 0, i64 0
%65 = call i32 @print_array(i32* %64, i32 10)
%66 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i64 0, i64 0
%67 = call i32 @quicksort(i32* %66, i32 10)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%69 = getelementptr inbounds [10 x i32], [10 x i32]* %12, i64 0, i64 0
%70 = call i32 @print_array(i32* %69, i32 10)
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 0
%72 = call i32 @nicksort(i32* %71, i32 10)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%74 = getelementptr inbounds [10 x i32], [10 x i32]* %13, i64 0, i64 0
%75 = call i32 @print_array(i32* %74, i32 10)
store i32 0, i32* %8
br label %76
76: ; preds = %127, %62
%77 = load i32, i32* %8
%78 = load i32, i32* %7
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %130
80: ; preds = %76
%81 = call i64 (...) @clock()
%82 = call i32 @srand(i64 %81)
store i32 0, i32* %9
br label %83
83: ; preds = %97, %80
%84 = load i32, i32* %9
%85 = load i32, i32* %6
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %100
87: ; preds = %83
%88 = call i32 (...) @rand()
%89 = load i32, i32* %6
%90 = srem i32 %88, %89
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %43, i64 %92
store i32 %90, i32* %93
%94 = load i32, i32* %9
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %40, i64 %95
store i32 %90, i32* %96
br label %97
97: ; preds = %87
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 1
store i32 %99, i32* %9
br label %83
100: ; preds = %83
%101 = call i64 (...) @clock()
store i64 %101, i64* %10
%102 = load i32, i32* %6
%103 = call i32 @quicksort(i32* %40, i32 %102)
%104 = call i64 (...) @clock()
store i64 %104, i64* %11
%105 = load i64, i64* %11
%106 = sitofp i64 %105 to double
%107 = load i64, i64* %10
%108 = sitofp i64 %107 to double
%109 = fsub double %106, %108
%110 = load double, double* @CLOCKS_PER_SEC
%111 = fdiv double %109, %110
%112 = load double, double* %17
%113 = fadd double %112, %111
store double %113, double* %17
%114 = call i64 (...) @clock()
store i64 %114, i64* %10
%115 = load i32, i32* %6
%116 = call i32 @nicksort(i32* %43, i32 %115)
%117 = call i64 (...) @clock()
store i64 %117, i64* %11
%118 = load i64, i64* %11
%119 = sitofp i64 %118 to double
%120 = load i64, i64* %10
%121 = sitofp i64 %120 to double
%122 = fsub double %119, %121
%123 = load double, double* @CLOCKS_PER_SEC
%124 = fdiv double %122, %123
%125 = load double, double* %18
%126 = fadd double %125, %124
store double %126, double* %18
br label %127
127: ; preds = %100
%128 = load i32, i32* %8
%129 = add nsw i32 %128, 1
store i32 %129, i32* %8
br label %76
130: ; preds = %76
%131 = load double, double* %17
%132 = load i32, i32* %7
%133 = sitofp i32 %132 to double
%134 = fdiv double %131, %133
store double %134, double* %19
%135 = load double, double* %18
%136 = load i32, i32* %7
%137 = sitofp i32 %136 to double
%138 = fdiv double %135, %137
store double %138, double* %20
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%140 = load double, double* %17
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %140)
%142 = load double, double* %19
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %142)
%144 = load double, double* %18
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %144)
%146 = load double, double* %20
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), double %146)
store i32 0, i32* %3
%148 = load i8*, i8** %14
br label %149
149: ; preds = %130, %23
%150 = load i32, i32* %3
ret i32 %150
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"\09Test array: \00"
@.str.2 = [14 x i8] c"\09Quicksort: \00"
@.str.3 = [14 x i8] c"\09Nicksort: \00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.5 = [29 x i8] c"\09Quicksort total time: %f\0A\00"
@.str.6 = [29 x i8] c"\09Quicksort average time: %f\0A\00"
@.str.7 = [29 x i8] c"\09Nicksort total time: %f\0A\00"
@.str.8 = [29 x i8] c"\09Nicksort average time: %f\0A\00"
@str = [24 x i8] c"Beginning sanity check:\00"
@str.9 = [43 x i8] c"Testing finished, statistics (in seconds):\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
br label %122
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = bitcast [10 x i32]* %3 to i8*
%17 = bitcast [10 x i32]* %4 to i8*
%18 = zext i32 %12 to i64
%19 = tail call i8* @llvm.stacksave()
%20 = alloca i32, i64 %18
%21 = alloca i32, i64 %18
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%23 = tail call i64 (...) @clock()
%24 = tail call i32 @srand(i64 %23)
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 10
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
store i32 %26, i32* %27
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 %26, i32* %28
%29 = tail call i32 (...) @rand()
%30 = srem i32 %29, 10
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 1
store i32 %30, i32* %31
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
store i32 %30, i32* %32
%33 = tail call i32 (...) @rand()
%34 = srem i32 %33, 10
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 2
store i32 %34, i32* %35
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
store i32 %34, i32* %36
%37 = tail call i32 (...) @rand()
%38 = srem i32 %37, 10
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 3
store i32 %38, i32* %39
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
store i32 %38, i32* %40
%41 = tail call i32 (...) @rand()
%42 = srem i32 %41, 10
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 4
store i32 %42, i32* %43
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
store i32 %42, i32* %44
%45 = tail call i32 (...) @rand()
%46 = srem i32 %45, 10
%47 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 5
store i32 %46, i32* %47
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
store i32 %46, i32* %48
%49 = tail call i32 (...) @rand()
%50 = srem i32 %49, 10
%51 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 6
store i32 %50, i32* %51
%52 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
store i32 %50, i32* %52
%53 = tail call i32 (...) @rand()
%54 = srem i32 %53, 10
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 7
store i32 %54, i32* %55
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
store i32 %54, i32* %56
%57 = tail call i32 (...) @rand()
%58 = srem i32 %57, 10
%59 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 8
store i32 %58, i32* %59
%60 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
store i32 %58, i32* %60
%61 = tail call i32 (...) @rand()
%62 = srem i32 %61, 10
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 9
store i32 %62, i32* %63
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
store i32 %62, i32* %64
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%66 = call i32 @print_array(i32* %28, i32 10)
%67 = call i32 @quicksort(i32* %28, i32 10)
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%69 = call i32 @print_array(i32* %28, i32 10)
%70 = call i32 @nicksort(i32* %27, i32 10)
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%72 = call i32 @print_array(i32* %27, i32 10)
%73 = icmp sgt i32 %15, 0
br i1 %73, label %74, label %111
74: ; preds = %9
%75 = icmp sgt i32 %12, 0
br label %76
76: ; preds = %74, %90
%77 = phi i32 [ 0, %74 ], [ %109, %90 ]
%78 = phi double [ undef, %74 ], [ %108, %90 ]
%79 = phi double [ undef, %74 ], [ %99, %90 ]
%80 = call i64 (...) @clock()
%81 = call i32 @srand(i64 %80)
br i1 %75, label %82, label %90
82: ; preds = %76, %82
%83 = phi i64 [ %88, %82 ], [ 0, %76 ]
%84 = call i32 (...) @rand()
%85 = srem i32 %84, %12
%86 = getelementptr inbounds i32, i32* %21, i64 %83
store i32 %85, i32* %86
%87 = getelementptr inbounds i32, i32* %20, i64 %83
store i32 %85, i32* %87
%88 = add nuw nsw i64 %83, 1
%89 = icmp eq i64 %88, %18
br i1 %89, label %90, label %82
90: ; preds = %82, %76
%91 = call i64 (...) @clock()
%92 = call i32 @quicksort(i32* %20, i32 %12)
%93 = call i64 (...) @clock()
%94 = sitofp i64 %93 to double
%95 = sitofp i64 %91 to double
%96 = fsub double %94, %95
%97 = load double, double* @CLOCKS_PER_SEC
%98 = fdiv double %96, %97
%99 = fadd double %79, %98
%100 = call i64 (...) @clock()
%101 = call i32 @nicksort(i32* %21, i32 %12)
%102 = call i64 (...) @clock()
%103 = sitofp i64 %102 to double
%104 = sitofp i64 %100 to double
%105 = fsub double %103, %104
%106 = load double, double* @CLOCKS_PER_SEC
%107 = fdiv double %105, %106
%108 = fadd double %78, %107
%109 = add nuw nsw i32 %77, 1
%110 = icmp eq i32 %109, %15
br i1 %110, label %111, label %76
111: ; preds = %90, %9
%112 = phi double [ undef, %9 ], [ %99, %90 ]
%113 = phi double [ undef, %9 ], [ %108, %90 ]
%114 = sitofp i32 %15 to double
%115 = fdiv double %112, %114
%116 = fdiv double %113, %114
%117 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.9, i64 0, i64 0))
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), double %112)
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), double %115)
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), double %113)
%121 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), double %116)
br label %122
122: ; preds = %111, %6
%123 = phi i32 [ 1, %6 ], [ 0, %111 ]
ret i32 %123
}