#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 */

/* Variables and functions */
int /*<<< orphan*/ approxEqual(double, double);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double clock();
double kendallNlogN(double *, double *, int const);
double kendallSmallN(double *, double *, int const);
scalar_t__ malloc(int const);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int main() {
  double a[100], b[100];
  double smallNCor, largeNCor;
  int i;
  {
    double a1[] = {1, 2, 3, 5, 4};
    double a2[] = {1, 2, 3, 3, 5};
    assert(approxEqual(kendallSmallN(a1, a2, 5), 0.7378648));
    assert(approxEqual(kendallNlogN(a1, a2, 5), 0.7378648));
    double b1[] = {8, 6, 7, 5, 3, 0, 9};
    double b2[] = {3, 1, 4, 1, 5, 9, 2};
    assert(approxEqual(kendallSmallN(b1, b2, 7), -0.39036));
    assert(approxEqual(kendallNlogN(b1, b2, 7), -0.39036));
    double c1[] = {1, 1, 1, 2, 3, 3, 4, 4};
    double c2[] = {1, 2, 1, 3, 3, 5, 5, 5};
    assert(approxEqual(kendallSmallN(c1, c2, 8), 0.8695652));
    assert(approxEqual(kendallNlogN(c1, c2, 8), 0.8695652));
  }
  for (i = 0; i < 10000; i++) {
    int j, len;
    for (j = 0; j < 100; j++) {
      a[j] = rand() % 30;
      b[j] = rand() % 30;
    }
    len = rand() % 50 + 50;
    smallNCor = kendallSmallN(a, b, len);
    largeNCor = kendallNlogN(a, b, len);
    assert(approxEqual(largeNCor, smallNCor));
  }
  printf("Passed all tests.\n");
  {
    const int N = 30000;
    double *foo, *bar, *buf;
    size_t i;
    double startTime, stopTime;
    foo = (double *)malloc(N * sizeof(double));
    bar = (double *)malloc(N * sizeof(double));
    for (i = 0; i < N; i++) {
      foo[i] = rand();
      bar[i] = rand();
    }
    startTime = clock();
    kendallSmallN(foo, bar, N);
    stopTime = clock();
    printf("O(N^2) version:  %f milliseconds\n", stopTime - startTime);
    startTime = clock();
    kendallNlogN(foo, bar, N);
    stopTime = clock();
    printf("O(N log N) version:  %f milliseconds\n", stopTime - startTime);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x690(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x690(%rbp)
ff
movsd  0xe6b(%rip),%xmm0
movsd  %xmm0,-0x688(%rbp)
ff
movsd  0xe2b(%rip),%xmm0
movsd  %xmm0,-0x680(%rbp)
ff
movsd  0xe23(%rip),%xmm0
movsd  %xmm0,-0x678(%rbp)
ff
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x670(%rbp)
ff
lea    -0x6c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
movsd  0xe20(%rip),%xmm0
movsd  %xmm0,-0x6c0(%rbp)
ff
movsd  0xe08(%rip),%xmm0
movsd  %xmm0,-0x6b8(%rbp)
ff
movsd  0xdc8(%rip),%xmm0
movsd  %xmm0,-0x6b0(%rbp)
ff
movsd  0xdb8(%rip),%xmm0
movsd  %xmm0,-0x6a8(%rbp)
ff
movsd  0xdb0(%rip),%xmm0
movsd  %xmm0,-0x6a0(%rbp)
ff
lea    -0x690(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    $0x5,%edx
call   1040 <kendallSmallN@plt>
movsd  0xda8(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
lea    -0x690(%rbp),%rdi
lea    -0x6c0(%rbp),%rsi
mov    $0x5,%edx
call   1030 <kendallNlogN@plt>
movsd  0xd7c(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
lea    -0x700(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1070 <memset@plt>
movsd  0xd4d(%rip),%xmm0
movsd  %xmm0,-0x700(%rbp)
ff
movsd  0xd35(%rip),%xmm0
movsd  %xmm0,-0x6f8(%rbp)
ff
movsd  0xd1d(%rip),%xmm0
movsd  %xmm0,-0x6f0(%rbp)
ff
movsd  0xd05(%rip),%xmm0
movsd  %xmm0,-0x6e8(%rbp)
ff
movsd  0xced(%rip),%xmm0
movsd  %xmm0,-0x6e0(%rbp)
ff
movsd  0xcd5(%rip),%xmm0
movsd  %xmm0,-0x6d0(%rbp)
ff
lea    -0x740(%rbp),%rdi
lea    0xd0f(%rip),%rsi
mov    $0x38,%edx
call   1090 <memcpy@plt>
lea    -0x700(%rbp),%rdi
lea    -0x740(%rbp),%rsi
mov    $0x7,%edx
call   1040 <kendallSmallN@plt>
movsd  0xc8d(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
lea    -0x700(%rbp),%rdi
lea    -0x740(%rbp),%rsi
mov    $0x7,%edx
call   1030 <kendallNlogN@plt>
movsd  0xc61(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
lea    -0x780(%rbp),%rdi
lea    0xcdf(%rip),%rsi
mov    $0x40,%edx
call   1090 <memcpy@plt>
lea    -0x7c0(%rbp),%rdi
lea    0xd07(%rip),%rsi
mov    $0x40,%edx
call   1090 <memcpy@plt>
lea    -0x780(%rbp),%rdi
lea    -0x7c0(%rbp),%rsi
mov    $0x8,%edx
call   1040 <kendallSmallN@plt>
movsd  0xbfd(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
lea    -0x780(%rbp),%rdi
lea    -0x7c0(%rbp),%rsi
mov    $0x8,%edx
call   1030 <kendallNlogN@plt>
movsd  0xbd1(%rip),%xmm1
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
movl   $0x0,-0x664(%rbp)
cmpl   $0x2710,-0x664(%rbp)
jge    1550 <main+0x3b0>
movl   $0x0,-0x7c4(%rbp)
cmpl   $0x64,-0x7c4(%rbp)
jge    14c6 <main+0x326>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x1e,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movslq -0x7c4(%rbp),%rax
movsd  %xmm0,-0x330(%rbp,%rax,8)
ff ff
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x1e,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movslq -0x7c4(%rbp),%rax
movsd  %xmm0,-0x650(%rbp,%rax,8)
ff ff
mov    -0x7c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c4(%rbp)
jmp    145f <main+0x2bf>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x32,%ecx
cltd
idiv   %ecx
add    $0x32,%edx
mov    %edx,-0x7c8(%rbp)
lea    -0x330(%rbp),%rdi
lea    -0x650(%rbp),%rsi
mov    -0x7c8(%rbp),%edx
call   1040 <kendallSmallN@plt>
movsd  %xmm0,-0x658(%rbp)
ff
lea    -0x330(%rbp),%rdi
lea    -0x650(%rbp),%rsi
mov    -0x7c8(%rbp),%edx
call   1030 <kendallNlogN@plt>
movsd  %xmm0,-0x660(%rbp)
ff
movsd  -0x660(%rbp),%xmm0
ff
movsd  -0x658(%rbp),%xmm1
ff
call   10b0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
mov    -0x664(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x664(%rbp)
jmp    1445 <main+0x2a5>
lea    0xbc9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x7530,-0x7cc(%rbp)
mov    $0x3a980,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x7d8(%rbp)
mov    $0x3a980,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x7e0(%rbp)
movq   $0x0,-0x7f0(%rbp)
cmpq   $0x7530,-0x7f0(%rbp)
jae    15f9 <main+0x459>
mov    $0x0,%al
call   10c0 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    -0x7d8(%rbp),%rax
mov    -0x7f0(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    $0x0,%al
call   10c0 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    -0x7e0(%rbp),%rax
mov    -0x7f0(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x7f0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7f0(%rbp)
jmp    1595 <main+0x3f5>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x7f8(%rbp)
ff
mov    -0x7d8(%rbp),%rdi
mov    -0x7e0(%rbp),%rsi
mov    $0x7530,%edx
call   1040 <kendallSmallN@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x800(%rbp)
ff
movsd  -0x800(%rbp),%xmm0
ff
subsd  -0x7f8(%rbp),%xmm0
ff
lea    0xaed(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x7f8(%rbp)
ff
mov    -0x7d8(%rbp),%rdi
mov    -0x7e0(%rbp),%rsi
mov    $0x7530,%edx
call   1030 <kendallNlogN@plt>
mov    $0x0,%al
call   1050 <clock@plt>
movsd  %xmm0,-0x800(%rbp)
ff
movsd  -0x800(%rbp),%xmm0
ff
subsd  -0x7f8(%rbp),%xmm0
ff
lea    0xabb(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x738,%rsp
movaps 0xe5c(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe5d(%rip),%xmm1
movaps %xmm1,0x90(%rsp)
movabs $0x4010000000000000,%rax
mov    %rax,0xa0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps 0xe47(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movabs $0x4014000000000000,%rax
mov    %rax,0x70(%rsp)
lea    0x80(%rsp),%rbx
lea    0x50(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1050 <kendallSmallN@plt>
movsd  0xe3e(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <kendallNlogN@plt>
movsd  0xe1a(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xddf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xde3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movabs $0x4008000000000000,%rax
mov    %rax,0x30(%rsp)
movabs $0x4022000000000000,%rax
mov    %rax,0x40(%rsp)
mov    0xe19(%rip),%rax
mov    %rax,0xe0(%rsp)
movaps 0xdfa(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xddb(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xdbc(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
lea    0x10(%rsp),%rbx
lea    0xb0(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1050 <kendallSmallN@plt>
movsd  0xd77(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <kendallNlogN@plt>
movsd  0xd53(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
movaps 0xdc8(%rip),%xmm0
movaps %xmm0,0x440(%rsp)
movaps 0xda9(%rip),%xmm0
movaps %xmm0,0x430(%rsp)
movaps 0xd8a(%rip),%xmm0
movaps %xmm0,0x420(%rsp)
movaps 0xd6b(%rip),%xmm0
movaps %xmm0,0x410(%rsp)
movaps 0xdcc(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xdad(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xd8e(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movapd 0xd6e(%rip),%xmm0
movapd %xmm0,0xf0(%rsp)
lea    0x410(%rsp),%r14
lea    0xf0(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1050 <kendallSmallN@plt>
movsd  0xcad(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   1030 <kendallNlogN@plt>
movsd  0xc89(%rip),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
add    %eax,%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  %xmm0,0x410(%rsp,%rbp,8)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x4,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x5,%edx
mov    %ecx,%esi
sub    %edx,%esi
add    %ecx,%esi
add    %eax,%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  %xmm0,0xf0(%rsp,%rbp,8)
add    $0x1,%rbp
cmp    $0x64,%rbp
jne    1400 <main+0x270>
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x32,%ecx,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebp
add    $0x32,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <kendallSmallN@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <kendallNlogN@plt>
movsd  0x8(%rsp),%xmm1
call   10a0 <approxEqual@plt>
mov    %eax,%edi
call   1080 <assert@plt>
add    $0x1,%ebx
cmp    $0x2710,%ebx
jne    13f0 <main+0x260>
lea    0xc80(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3a980,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x3a980,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbp,8)
xor    %eax,%eax
call   10b0 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
cmp    $0x7530,%rbp
jne    1520 <main+0x390>
xor    %eax,%eax
call   1060 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7530,%edx
call   1050 <kendallSmallN@plt>
xor    %eax,%eax
call   1060 <clock@plt>
subsd  0x8(%rsp),%xmm0
lea    0xbab(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7530,%edx
call   1030 <kendallNlogN@plt>
xor    %eax,%eax
call   1060 <clock@plt>
subsd  0x8(%rsp),%xmm0
lea    0xb95(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x738,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.b2 = [7 x double] [double 3.000000e+00, double 1.000000e+00, double 4.000000e+00, double 1.000000e+00, double 5.000000e+00, double 9.000000e+00, double 2.000000e+00]
@__const.main.c1 = [8 x double] [double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 3.000000e+00, double 4.000000e+00, double 4.000000e+00]
@__const.main.c2 = [8 x double] [double 1.000000e+00, double 2.000000e+00, double 1.000000e+00, double 3.000000e+00, double 3.000000e+00, double 5.000000e+00, double 5.000000e+00, double 5.000000e+00]
@.str = [19 x i8] c"Passed all tests.\0A\00"
@.str.1 = [34 x i8] c"O(N^2) version: %f milliseconds\0A\00"
@.str.2 = [38 x i8] c"O(N log N) version: %f milliseconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x double]
%3 = alloca [100 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca [5 x double]
%8 = alloca [5 x double]
%9 = alloca [7 x double]
%10 = alloca [7 x double]
%11 = alloca [8 x double]
%12 = alloca [8 x double]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca i64
%20 = alloca double
%21 = alloca double
store i32 0, i32* %1
%22 = bitcast [5 x double]* %7 to i8*
%23 = bitcast i8* %22 to [5 x double]*
%24 = getelementptr inbounds [5 x double], [5 x double]* %23, i32 0, i32 0
store double 1.000000e+00, double* %24
%25 = getelementptr inbounds [5 x double], [5 x double]* %23, i32 0, i32 1
store double 2.000000e+00, double* %25
%26 = getelementptr inbounds [5 x double], [5 x double]* %23, i32 0, i32 2
store double 3.000000e+00, double* %26
%27 = getelementptr inbounds [5 x double], [5 x double]* %23, i32 0, i32 3
store double 5.000000e+00, double* %27
%28 = getelementptr inbounds [5 x double], [5 x double]* %23, i32 0, i32 4
store double 4.000000e+00, double* %28
%29 = bitcast [5 x double]* %8 to i8*
%30 = bitcast i8* %29 to [5 x double]*
%31 = getelementptr inbounds [5 x double], [5 x double]* %30, i32 0, i32 0
store double 1.000000e+00, double* %31
%32 = getelementptr inbounds [5 x double], [5 x double]* %30, i32 0, i32 1
store double 2.000000e+00, double* %32
%33 = getelementptr inbounds [5 x double], [5 x double]* %30, i32 0, i32 2
store double 3.000000e+00, double* %33
%34 = getelementptr inbounds [5 x double], [5 x double]* %30, i32 0, i32 3
store double 3.000000e+00, double* %34
%35 = getelementptr inbounds [5 x double], [5 x double]* %30, i32 0, i32 4
store double 5.000000e+00, double* %35
%36 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 0
%37 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 0
%38 = call double @kendallSmallN(double* %36, double* %37, i32 5)
%39 = call i32 @approxEqual(double %38, double 0x3FE79C96A41BD39B)
%40 = call i32 @assert(i32 %39)
%41 = getelementptr inbounds [5 x double], [5 x double]* %7, i64 0, i64 0
%42 = getelementptr inbounds [5 x double], [5 x double]* %8, i64 0, i64 0
%43 = call double @kendallNlogN(double* %41, double* %42, i32 5)
%44 = call i32 @approxEqual(double %43, double 0x3FE79C96A41BD39B)
%45 = call i32 @assert(i32 %44)
%46 = bitcast [7 x double]* %9 to i8*
%47 = bitcast i8* %46 to [7 x double]*
%48 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 0
store double 8.000000e+00, double* %48
%49 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 1
store double 6.000000e+00, double* %49
%50 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 2
store double 7.000000e+00, double* %50
%51 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 3
store double 5.000000e+00, double* %51
%52 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 4
store double 3.000000e+00, double* %52
%53 = getelementptr inbounds [7 x double], [7 x double]* %47, i32 0, i32 6
store double 9.000000e+00, double* %53
%54 = bitcast [7 x double]* %10 to i8*
%55 = getelementptr inbounds [7 x double], [7 x double]* %9, i64 0, i64 0
%56 = getelementptr inbounds [7 x double], [7 x double]* %10, i64 0, i64 0
%57 = call double @kendallSmallN(double* %55, double* %56, i32 7)
%58 = call i32 @approxEqual(double %57, double -3.903600e-01)
%59 = call i32 @assert(i32 %58)
%60 = getelementptr inbounds [7 x double], [7 x double]* %9, i64 0, i64 0
%61 = getelementptr inbounds [7 x double], [7 x double]* %10, i64 0, i64 0
%62 = call double @kendallNlogN(double* %60, double* %61, i32 7)
%63 = call i32 @approxEqual(double %62, double -3.903600e-01)
%64 = call i32 @assert(i32 %63)
%65 = bitcast [8 x double]* %11 to i8*
%66 = bitcast [8 x double]* %12 to i8*
%67 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 0
%68 = getelementptr inbounds [8 x double], [8 x double]* %12, i64 0, i64 0
%69 = call double @kendallSmallN(double* %67, double* %68, i32 8)
%70 = call i32 @approxEqual(double %69, double 0x3FEBD37A65F7AB9E)
%71 = call i32 @assert(i32 %70)
%72 = getelementptr inbounds [8 x double], [8 x double]* %11, i64 0, i64 0
%73 = getelementptr inbounds [8 x double], [8 x double]* %12, i64 0, i64 0
%74 = call double @kendallNlogN(double* %72, double* %73, i32 8)
%75 = call i32 @approxEqual(double %74, double 0x3FEBD37A65F7AB9E)
%76 = call i32 @assert(i32 %75)
store i32 0, i32* %6
br label %77
77: ; preds = %116, %0
%78 = load i32, i32* %6
%79 = icmp slt i32 %78, 10000
br i1 %79, label %80, label %119
80: ; preds = %77
store i32 0, i32* %13
br label %81
81: ; preds = %97, %80
%82 = load i32, i32* %13
%83 = icmp slt i32 %82, 100
br i1 %83, label %84, label %100
84: ; preds = %81
%85 = call i32 (...) @rand()
%86 = srem i32 %85, 30
%87 = sitofp i32 %86 to double
%88 = load i32, i32* %13
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 %89
store double %87, double* %90
%91 = call i32 (...) @rand()
%92 = srem i32 %91, 30
%93 = sitofp i32 %92 to double
%94 = load i32, i32* %13
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 %95
store double %93, double* %96
br label %97
97: ; preds = %84
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %81
100: ; preds = %81
%101 = call i32 (...) @rand()
%102 = srem i32 %101, 50
%103 = add nsw i32 %102, 50
store i32 %103, i32* %14
%104 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 0
%105 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
%106 = load i32, i32* %14
%107 = call double @kendallSmallN(double* %104, double* %105, i32 %106)
store double %107, double* %4
%108 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 0
%109 = getelementptr inbounds [100 x double], [100 x double]* %3, i64 0, i64 0
%110 = load i32, i32* %14
%111 = call double @kendallNlogN(double* %108, double* %109, i32 %110)
store double %111, double* %5
%112 = load double, double* %5
%113 = load double, double* %4
%114 = call i32 @approxEqual(double %112, double %113)
%115 = call i32 @assert(i32 %114)
br label %116
116: ; preds = %100
%117 = load i32, i32* %6
%118 = add nsw i32 %117, 1
store i32 %118, i32* %6
br label %77
119: ; preds = %77
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 30000, i32* %15
%121 = call i64 @malloc(i32 240000)
%122 = inttoptr i64 %121 to double*
store double* %122, double** %16
%123 = call i64 @malloc(i32 240000)
%124 = inttoptr i64 %123 to double*
store double* %124, double** %17
store i64 0, i64* %19
br label %125
125: ; preds = %139, %119
%126 = load i64, i64* %19
%127 = icmp ult i64 %126, 30000
br i1 %127, label %128, label %142
128: ; preds = %125
%129 = call i32 (...) @rand()
%130 = sitofp i32 %129 to double
%131 = load double*, double** %16
%132 = load i64, i64* %19
%133 = getelementptr inbounds double, double* %131, i64 %132
store double %130, double* %133
%134 = call i32 (...) @rand()
%135 = sitofp i32 %134 to double
%136 = load double*, double** %17
%137 = load i64, i64* %19
%138 = getelementptr inbounds double, double* %136, i64 %137
store double %135, double* %138
br label %139
139: ; preds = %128
%140 = load i64, i64* %19
%141 = add i64 %140, 1
store i64 %141, i64* %19
br label %125
142: ; preds = %125
%143 = call double (...) @clock()
store double %143, double* %20
%144 = load double*, double** %16
%145 = load double*, double** %17
%146 = call double @kendallSmallN(double* %144, double* %145, i32 30000)
%147 = call double (...) @clock()
store double %147, double* %21
%148 = load double, double* %21
%149 = load double, double* %20
%150 = fsub double %148, %149
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %150)
%152 = call double (...) @clock()
store double %152, double* %20
%153 = load double*, double** %16
%154 = load double*, double** %17
%155 = call double @kendallNlogN(double* %153, double* %154, i32 30000)
%156 = call double (...) @clock()
store double %156, double* %21
%157 = load double, double* %21
%158 = load double, double* %20
%159 = fsub double %157, %158
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %159)
ret i32 0
}

LLVM IR (-O2):
@__const.main.b2 = [7 x double] [double 3.000000e+00, double 1.000000e+00, double 4.000000e+00, double 1.000000e+00, double 5.000000e+00, double 9.000000e+00, double 2.000000e+00]
@__const.main.c1 = [8 x double] [double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 2.000000e+00, double 3.000000e+00, double 3.000000e+00, double 4.000000e+00, double 4.000000e+00]
@__const.main.c2 = [8 x double] [double 1.000000e+00, double 2.000000e+00, double 1.000000e+00, double 3.000000e+00, double 3.000000e+00, double 5.000000e+00, double 5.000000e+00, double 5.000000e+00]
@.str.1 = [34 x i8] c"O(N^2) version: %f milliseconds\0A\00"
@.str.2 = [38 x i8] c"O(N log N) version: %f milliseconds\0A\00"
@str = [18 x i8] c"Passed all tests.\00"
define i32 @main() {
%1 = alloca [100 x double]
%2 = alloca [100 x double]
%3 = alloca [5 x double]
%4 = alloca [5 x double]
%5 = alloca [7 x double]
%6 = alloca [7 x double]
%7 = alloca [8 x double]
%8 = alloca [8 x double]
%9 = bitcast [100 x double]* %1 to i8*
%10 = bitcast [100 x double]* %2 to i8*
%11 = bitcast [5 x double]* %3 to i8*
%12 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%13 = bitcast [5 x double]* %3 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 2
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 3.000000e+00, double 5.000000e+00>, <2 x double>* %15
%16 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 4
store double 4.000000e+00, double* %16
%17 = bitcast [5 x double]* %4 to i8*
%18 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 0
%19 = bitcast [5 x double]* %4 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %19
%20 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 2
%21 = bitcast double* %20 to <2 x double>*
store <2 x double> <double 3.000000e+00, double 3.000000e+00>, <2 x double>* %21
%22 = getelementptr inbounds [5 x double], [5 x double]* %4, i64 0, i64 4
store double 5.000000e+00, double* %22
%23 = call double @kendallSmallN(double* %12, double* %18, i32 5)
%24 = call i32 @approxEqual(double %23, double 0x3FE79C96A41BD39B)
%25 = call i32 @assert(i32 %24)
%26 = call double @kendallNlogN(double* %12, double* %18, i32 5)
%27 = call i32 @approxEqual(double %26, double 0x3FE79C96A41BD39B)
%28 = call i32 @assert(i32 %27)
%29 = bitcast [7 x double]* %5 to i8*
%30 = getelementptr inbounds [7 x double], [7 x double]* %5, i64 0, i64 4
%31 = bitcast double* %30 to i8*
%32 = getelementptr inbounds [7 x double], [7 x double]* %5, i64 0, i64 0
%33 = bitcast [7 x double]* %5 to <2 x double>*
store <2 x double> <double 8.000000e+00, double 6.000000e+00>, <2 x double>* %33
%34 = getelementptr inbounds [7 x double], [7 x double]* %5, i64 0, i64 2
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> <double 7.000000e+00, double 5.000000e+00>, <2 x double>* %35
%36 = getelementptr inbounds [7 x double], [7 x double]* %5, i64 0, i64 4
store double 3.000000e+00, double* %36
%37 = getelementptr inbounds [7 x double], [7 x double]* %5, i64 0, i64 6
store double 9.000000e+00, double* %37
%38 = bitcast [7 x double]* %6 to i8*
%39 = getelementptr inbounds [7 x double], [7 x double]* %6, i64 0, i64 0
%40 = call double @kendallSmallN(double* %32, double* %39, i32 7)
%41 = call i32 @approxEqual(double %40, double -3.903600e-01)
%42 = call i32 @assert(i32 %41)
%43 = call double @kendallNlogN(double* %32, double* %39, i32 7)
%44 = call i32 @approxEqual(double %43, double -3.903600e-01)
%45 = call i32 @assert(i32 %44)
%46 = bitcast [8 x double]* %7 to i8*
%47 = bitcast [8 x double]* %8 to i8*
%48 = getelementptr inbounds [8 x double], [8 x double]* %7, i64 0, i64 0
%49 = getelementptr inbounds [8 x double], [8 x double]* %8, i64 0, i64 0
%50 = call double @kendallSmallN(double* %48, double* %49, i32 8)
%51 = call i32 @approxEqual(double %50, double 0x3FEBD37A65F7AB9E)
%52 = call i32 @assert(i32 %51)
%53 = call double @kendallNlogN(double* %48, double* %49, i32 8)
%54 = call i32 @approxEqual(double %53, double 0x3FEBD37A65F7AB9E)
%55 = call i32 @assert(i32 %54)
%56 = getelementptr inbounds [100 x double], [100 x double]* %1, i64 0, i64 0
%57 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 0
br label %58
58: ; preds = %0, %72
%59 = phi i32 [ 0, %0 ], [ %80, %72 ]
br label %60
60: ; preds = %58, %60
%61 = phi i64 [ 0, %58 ], [ %70, %60 ]
%62 = call i32 (...) @rand()
%63 = srem i32 %62, 30
%64 = sitofp i32 %63 to double
%65 = getelementptr inbounds [100 x double], [100 x double]* %1, i64 0, i64 %61
store double %64, double* %65
%66 = call i32 (...) @rand()
%67 = srem i32 %66, 30
%68 = sitofp i32 %67 to double
%69 = getelementptr inbounds [100 x double], [100 x double]* %2, i64 0, i64 %61
store double %68, double* %69
%70 = add nuw nsw i64 %61, 1
%71 = icmp eq i64 %70, 100
br i1 %71, label %72, label %60
72: ; preds = %60
%73 = call i32 (...) @rand()
%74 = srem i32 %73, 50
%75 = add nsw i32 %74, 50
%76 = call double @kendallSmallN(double* %56, double* %57, i32 %75)
%77 = call double @kendallNlogN(double* %56, double* %57, i32 %75)
%78 = call i32 @approxEqual(double %77, double %76)
%79 = call i32 @assert(i32 %78)
%80 = add nuw nsw i32 %59, 1
%81 = icmp eq i32 %80, 10000
br i1 %81, label %82, label %58
82: ; preds = %72
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%84 = call i64 @malloc(i32 240000)
%85 = inttoptr i64 %84 to double*
%86 = call i64 @malloc(i32 240000)
%87 = inttoptr i64 %86 to double*
br label %88
88: ; preds = %82, %88
%89 = phi i64 [ 0, %82 ], [ %96, %88 ]
%90 = call i32 (...) @rand()
%91 = sitofp i32 %90 to double
%92 = getelementptr inbounds double, double* %85, i64 %89
store double %91, double* %92
%93 = call i32 (...) @rand()
%94 = sitofp i32 %93 to double
%95 = getelementptr inbounds double, double* %87, i64 %89
store double %94, double* %95
%96 = add nuw nsw i64 %89, 1
%97 = icmp eq i64 %96, 30000
br i1 %97, label %98, label %88
98: ; preds = %88
%99 = call double (...) @clock()
%100 = call double @kendallSmallN(double* %85, double* %87, i32 30000)
%101 = call double (...) @clock()
%102 = fsub double %101, %99
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %102)
%104 = call double (...) @clock()
%105 = call double @kendallNlogN(double* %85, double* %87, i32 30000)
%106 = call double (...) @clock()
%107 = fsub double %106, %104
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), double %107)
ret i32 0
}