#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;
typedef int /*<<< orphan*/ a2;
typedef int /*<<< orphan*/ a1;

/* Variables and functions */
double CSPL_Stats_median_bin(double *, long);
double CSPL_Stats_median_quickselect(double *, long);
double CSPL_Stats_median_sort(double *, long);
scalar_t__ calloc(long, int);
scalar_t__ clock();
int fabs(int /*<<< orphan*/);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int);
int main(void) {
  double dat1[5] = {15, 20, 35, 40, 50};
  clock_t start;
  double a1, a2, a3;
  start = clock();
  a1 = CSPL_Stats_median_sort(dat1, 5);
  printf("median1_sort: %lf  -- %ld ticks\n", a1, (clock() - start));
  start = clock();
  a2 = CSPL_Stats_median_quickselect(dat1, 5);
  printf("median1_quick: %lf  -- %ld ticks\n", a2, (clock() - start));
  start = clock();
  a3 = CSPL_Stats_median_bin(dat1, 5);
  printf("CSPL_Stats_median_bin: %lf  -- %ld ticks\n", a3, (clock() - start));
  {
    if ((fabs((a1) - (a2)) < (1e-5)) == 0)
      return (1);
  };
  {
    if ((fabs((a1) - (a3)) < (1e-5)) == 0)
      return (1);
  };
  {
    if ((fabs((a2) - (a3)) < (1e-5)) == 0)
      return (1);
  };
  {
    if ((fabs((a1) - (35.0)) < (1e-5)) == 0)
      return (1);
  };
  printf("--------------------\n");
  {
    double *dat1;
    long c;
    long lens[3] = {101, 1000001, 2000};
    double ans[3] = {39, 51, 52};
    long len;
    for (len = 0; len < 3; len++) {
      dat1 = (double *)calloc(lens[len], sizeof(double));
      srand(123);
      for (c = 0; c < lens[len]; c++) {
        dat1[c] = rand() % 100 + 1;
      }
      a1 = CSPL_Stats_median_sort(dat1, lens[len]);
      printf("Repeat for %ld random numbers from 0 to 100\n", lens[len]);
      CSPL_Stats_median_bin(dat1, lens[len]);
      start = clock();
      printf("CSPL_Stats_median_sort: %lf  -- %ld ticks\n", a1,
             (clock() - start));
      start = clock();
      a2 = CSPL_Stats_median_quickselect(dat1, lens[len]);
      printf("CSPL_Stats_median_quickselect: %lf  -- %ld ticks\n", a2,
             (clock() - start));
      start = clock();
      a3 = CSPL_Stats_median_quickselect(dat1, lens[len]);
      printf("CSPL_Stats_median_bin: %lf  -- %ld ticks\n", a3,
             (clock() - start));
      {
        if ((fabs((a1) - (a2)) < (1e-5)) == 0)
          return (1);
      };
      {
        if ((fabs((a1) - (a3)) < (1e-5)) == 0)
          return (1);
      };
      {
        if ((fabs((a2) - (a3)) < (1e-5)) == 0)
          return (1);
      };
      {
        if ((fabs((a1) - (ans[len])) < (1e-5)) == 0)
          return (1);
      };
      free(dat1);
      printf("--------------------\n");
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1070 <memset@plt>
movsd  0xe4e(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe39(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe24(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe0f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdfa(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   10b0 <CSPL_Stats_median_sort@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xc0(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xb8(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xda7(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   10c0 <CSPL_Stats_median_bin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xb0(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xce1(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1340 <main+0x190>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x40(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xca1(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1380 <main+0x1d0>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xc61(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    13c0 <main+0x210>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x40(%rbp),%xmm0
movsd  0xc4b(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xc1a(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1407 <main+0x257>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xd24(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xd21(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xd1e(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xd23(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xd1d(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xd17(%rip),%rax
mov    %rax,-0x90(%rbp)
movq   $0x0,-0xa8(%rbp)
cmpq   $0x3,-0xa8(%rbp)
03
jge    1759 <main+0x5a9>
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rdi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x7b,%edi
call   1080 <srand@plt>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    -0xa8(%rbp),%rcx
cmp    -0x80(%rbp,%rcx,8),%rax
jge    14ef <main+0x33f>
mov    $0x0,%al
call   10d0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm0
mov    -0x58(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    14a5 <main+0x2f5>
mov    -0x58(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   10b0 <CSPL_Stats_median_sort@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
lea    0xb97(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   10c0 <CSPL_Stats_median_bin@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xd8(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xb73(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   1050 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xd0(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xb48(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    -0x80(%rbp,%rax,8),%rsi
call   1050 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    $0x0,%al
call   1040 <clock@plt>
movsd  -0xc8(%rbp),%xmm0
ff
mov    %rax,%rsi
sub    -0x38(%rbp),%rsi
lea    0xa5a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0x9c1(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1660 <main+0x4b0>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x40(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0x981(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    16a0 <main+0x4f0>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0x941(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    16e0 <main+0x530>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
movsd  -0x40(%rbp),%xmm0
mov    -0xa8(%rbp),%rax
subsd  -0xa0(%rbp,%rax,8),%xmm0
ff ff
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0x8f6(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    172b <main+0x57b>
movl   $0x1,-0x4(%rbp)
jmp    1760 <main+0x5b0>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
lea    0x962(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa8(%rbp)
jmp    146b <main+0x2bb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xe3b(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe3f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x4049000000000000,%rax
mov    %rax,0x40(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbp
lea    0x20(%rsp),%rbx
mov    $0x5,%esi
mov    %rbx,%rdi
call   10b0 <CSPL_Stats_median_sort@plt>
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbp,%rax
lea    0xe10(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbp
mov    $0x5,%esi
mov    %rbx,%rdi
call   1060 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbp,%rax
lea    0xdf3(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbp
mov    $0x5,%esi
mov    %rbx,%rdi
call   10c0 <CSPL_Stats_median_bin@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbp,%rax
lea    0xdd7(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
movsd  0x8(%rsp),%xmm0
addsd  0xd23(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jle    131e <main+0x16e>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
xor    %r13d,%r13d
lea    0xe0c(%rip),%rax
mov    (%rax,%r13,8),%r14
mov    %r14,%rdi
mov    $0x8,%esi
call   1090 <calloc@plt>
mov    %rax,%r12
mov    $0x7b,%edi
call   1080 <srand@plt>
cmp    $0x2,%r14
mov    $0x1,%ebx
cmovge %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10d0 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1370 <main+0x1c0>
mov    %r12,%rdi
mov    %r14,%rsi
call   10b0 <CSPL_Stats_median_sort@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xcd0(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   10c0 <CSPL_Stats_median_bin@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r15,%rax
lea    0xccd(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbx,%rax
lea    0xcbc(%rip),%rdi
movsd  0x18(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <CSPL_Stats_median_quickselect@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1050 <clock@plt>
sub    %rbx,%rax
lea    0xbfe(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    %rax,%rsi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
lea    0xc85(%rip),%rax
movsd  0x8(%rsp),%xmm0
subsd  (%rax,%r13,8),%xmm0
cvttsd2si %xmm0,%edi
call   10a0 <fabs@plt>
test   %eax,%eax
jg     130a <main+0x15a>
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xc18(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r13
xor    %eax,%eax
cmp    $0x3,%r13
jne    132d <main+0x17d>
jmp    130f <main+0x15f>

LLVM IR (-O0):
@.str = [33 x i8] c"median1_sort: %lf -- %ld ticks\0A\00"
@.str.1 = [34 x i8] c"median1_quick: %lf -- %ld ticks\0A\00"
@.str.2 = [42 x i8] c"CSPL_Stats_median_bin: %lf -- %ld ticks\0A\00"
@.str.3 = [22 x i8] c"--------------------\0A\00"
@__const.main.lens = [3 x i64] [i64 101, i64 1000001, i64 2000]
@__const.main.ans = [3 x double] [double 3.900000e+01, double 5.100000e+01, double 5.200000e+01]
@.str.4 = [45 x i8] c"Repeat for %ld random numbers from 0 to 100\0A\00"
@.str.5 = [43 x i8] c"CSPL_Stats_median_sort: %lf -- %ld ticks\0A\00"
@.str.6 = [50 x i8] c"CSPL_Stats_median_quickselect: %lf -- %ld ticks\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x double]
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca i64
%9 = alloca [3 x i64]
%10 = alloca [3 x double]
%11 = alloca i64
store i32 0, i32* %1
%12 = bitcast [5 x double]* %2 to i8*
%13 = bitcast i8* %12 to [5 x double]*
%14 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 0
store double 1.500000e+01, double* %14
%15 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 1
store double 2.000000e+01, double* %15
%16 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 2
store double 3.500000e+01, double* %16
%17 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 3
store double 4.000000e+01, double* %17
%18 = getelementptr inbounds [5 x double], [5 x double]* %13, i32 0, i32 4
store double 5.000000e+01, double* %18
%19 = call i64 (...) @clock()
store i64 %19, i64* %3
%20 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%21 = call double @CSPL_Stats_median_sort(double* %20, i64 5)
store double %21, double* %4
%22 = load double, double* %4
%23 = call i64 (...) @clock()
%24 = load i64, i64* %3
%25 = sub nsw i64 %23, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %22, i64 %25)
%27 = call i64 (...) @clock()
store i64 %27, i64* %3
%28 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%29 = call double @CSPL_Stats_median_quickselect(double* %28, i64 5)
store double %29, double* %5
%30 = load double, double* %5
%31 = call i64 (...) @clock()
%32 = load i64, i64* %3
%33 = sub nsw i64 %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %30, i64 %33)
%35 = call i64 (...) @clock()
store i64 %35, i64* %3
%36 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%37 = call double @CSPL_Stats_median_bin(double* %36, i64 5)
store double %37, double* %6
%38 = load double, double* %6
%39 = call i64 (...) @clock()
%40 = load i64, i64* %3
%41 = sub nsw i64 %39, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %38, i64 %41)
%43 = load double, double* %4
%44 = load double, double* %5
%45 = fsub double %43, %44
%46 = fptosi double %45 to i32
%47 = call i32 @fabs(i32 %46)
%48 = sitofp i32 %47 to double
%49 = fcmp olt double %48, 1.000000e-05
%50 = zext i1 %49 to i32
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %0
store i32 1, i32* %1
br label %212
53: ; preds = %0
%54 = load double, double* %4
%55 = load double, double* %6
%56 = fsub double %54, %55
%57 = fptosi double %56 to i32
%58 = call i32 @fabs(i32 %57)
%59 = sitofp i32 %58 to double
%60 = fcmp olt double %59, 1.000000e-05
%61 = zext i1 %60 to i32
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %53
store i32 1, i32* %1
br label %212
64: ; preds = %53
%65 = load double, double* %5
%66 = load double, double* %6
%67 = fsub double %65, %66
%68 = fptosi double %67 to i32
%69 = call i32 @fabs(i32 %68)
%70 = sitofp i32 %69 to double
%71 = fcmp olt double %70, 1.000000e-05
%72 = zext i1 %71 to i32
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %64
store i32 1, i32* %1
br label %212
75: ; preds = %64
%76 = load double, double* %4
%77 = fsub double %76, 3.500000e+01
%78 = fptosi double %77 to i32
%79 = call i32 @fabs(i32 %78)
%80 = sitofp i32 %79 to double
%81 = fcmp olt double %80, 1.000000e-05
%82 = zext i1 %81 to i32
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %75
store i32 1, i32* %1
br label %212
85: ; preds = %75
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%87 = bitcast [3 x i64]* %9 to i8*
%88 = bitcast [3 x double]* %10 to i8*
store i64 0, i64* %11
br label %89
89: ; preds = %208, %85
%90 = load i64, i64* %11
%91 = icmp slt i64 %90, 3
br i1 %91, label %92, label %211
92: ; preds = %89
%93 = load i64, i64* %11
%94 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %93
%95 = load i64, i64* %94
%96 = call i64 @calloc(i64 %95, i32 8)
%97 = inttoptr i64 %96 to double*
store double* %97, double** %7
%98 = call i32 @srand(i32 123)
store i64 0, i64* %8
br label %99
99: ; preds = %113, %92
%100 = load i64, i64* %8
%101 = load i64, i64* %11
%102 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %101
%103 = load i64, i64* %102
%104 = icmp slt i64 %100, %103
br i1 %104, label %105, label %116
105: ; preds = %99
%106 = call i32 (...) @rand()
%107 = srem i32 %106, 100
%108 = add nsw i32 %107, 1
%109 = sitofp i32 %108 to double
%110 = load double*, double** %7
%111 = load i64, i64* %8
%112 = getelementptr inbounds double, double* %110, i64 %111
store double %109, double* %112
br label %113
113: ; preds = %105
%114 = load i64, i64* %8
%115 = add nsw i64 %114, 1
store i64 %115, i64* %8
br label %99
116: ; preds = %99
%117 = load double*, double** %7
%118 = load i64, i64* %11
%119 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %118
%120 = load i64, i64* %119
%121 = call double @CSPL_Stats_median_sort(double* %117, i64 %120)
store double %121, double* %4
%122 = load i64, i64* %11
%123 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %122
%124 = load i64, i64* %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i64 %124)
%126 = load double*, double** %7
%127 = load i64, i64* %11
%128 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %127
%129 = load i64, i64* %128
%130 = call double @CSPL_Stats_median_bin(double* %126, i64 %129)
%131 = call i64 (...) @clock()
store i64 %131, i64* %3
%132 = load double, double* %4
%133 = call i64 (...) @clock()
%134 = load i64, i64* %3
%135 = sub nsw i64 %133, %134
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), double %132, i64 %135)
%137 = call i64 (...) @clock()
store i64 %137, i64* %3
%138 = load double*, double** %7
%139 = load i64, i64* %11
%140 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %139
%141 = load i64, i64* %140
%142 = call double @CSPL_Stats_median_quickselect(double* %138, i64 %141)
store double %142, double* %5
%143 = load double, double* %5
%144 = call i64 (...) @clock()
%145 = load i64, i64* %3
%146 = sub nsw i64 %144, %145
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %143, i64 %146)
%148 = call i64 (...) @clock()
store i64 %148, i64* %3
%149 = load double*, double** %7
%150 = load i64, i64* %11
%151 = getelementptr inbounds [3 x i64], [3 x i64]* %9, i64 0, i64 %150
%152 = load i64, i64* %151
%153 = call double @CSPL_Stats_median_quickselect(double* %149, i64 %152)
store double %153, double* %6
%154 = load double, double* %6
%155 = call i64 (...) @clock()
%156 = load i64, i64* %3
%157 = sub nsw i64 %155, %156
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %154, i64 %157)
%159 = load double, double* %4
%160 = load double, double* %5
%161 = fsub double %159, %160
%162 = fptosi double %161 to i32
%163 = call i32 @fabs(i32 %162)
%164 = sitofp i32 %163 to double
%165 = fcmp olt double %164, 1.000000e-05
%166 = zext i1 %165 to i32
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %169
168: ; preds = %116
store i32 1, i32* %1
br label %212
169: ; preds = %116
%170 = load double, double* %4
%171 = load double, double* %6
%172 = fsub double %170, %171
%173 = fptosi double %172 to i32
%174 = call i32 @fabs(i32 %173)
%175 = sitofp i32 %174 to double
%176 = fcmp olt double %175, 1.000000e-05
%177 = zext i1 %176 to i32
%178 = icmp eq i32 %177, 0
br i1 %178, label %179, label %180
179: ; preds = %169
store i32 1, i32* %1
br label %212
180: ; preds = %169
%181 = load double, double* %5
%182 = load double, double* %6
%183 = fsub double %181, %182
%184 = fptosi double %183 to i32
%185 = call i32 @fabs(i32 %184)
%186 = sitofp i32 %185 to double
%187 = fcmp olt double %186, 1.000000e-05
%188 = zext i1 %187 to i32
%189 = icmp eq i32 %188, 0
br i1 %189, label %190, label %191
190: ; preds = %180
store i32 1, i32* %1
br label %212
191: ; preds = %180
%192 = load double, double* %4
%193 = load i64, i64* %11
%194 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %193
%195 = load double, double* %194
%196 = fsub double %192, %195
%197 = fptosi double %196 to i32
%198 = call i32 @fabs(i32 %197)
%199 = sitofp i32 %198 to double
%200 = fcmp olt double %199, 1.000000e-05
%201 = zext i1 %200 to i32
%202 = icmp eq i32 %201, 0
br i1 %202, label %203, label %204
203: ; preds = %191
store i32 1, i32* %1
br label %212
204: ; preds = %191
%205 = load double*, double** %7
%206 = call i32 @free(double* %205)
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %208
208: ; preds = %204
%209 = load i64, i64* %11
%210 = add nsw i64 %209, 1
store i64 %210, i64* %11
br label %89
211: ; preds = %89
store i32 0, i32* %1
br label %212
212: ; preds = %211, %203, %190, %179, %168, %84, %74, %63, %52
%213 = load i32, i32* %1
ret i32 %213
}

LLVM IR (-O2):
@.str = [33 x i8] c"median1_sort: %lf -- %ld ticks\0A\00"
@.str.1 = [34 x i8] c"median1_quick: %lf -- %ld ticks\0A\00"
@.str.2 = [42 x i8] c"CSPL_Stats_median_bin: %lf -- %ld ticks\0A\00"
@__const.main.lens = [3 x i64] [i64 101, i64 1000001, i64 2000]
@__const.main.ans = [3 x double] [double 3.900000e+01, double 5.100000e+01, double 5.200000e+01]
@.str.4 = [45 x i8] c"Repeat for %ld random numbers from 0 to 100\0A\00"
@.str.5 = [43 x i8] c"CSPL_Stats_median_sort: %lf -- %ld ticks\0A\00"
@.str.6 = [50 x i8] c"CSPL_Stats_median_quickselect: %lf -- %ld ticks\0A\00"
@str.7 = [21 x i8] c"--------------------\00"
define i32 @main() {
%1 = alloca [5 x double]
%2 = bitcast [5 x double]* %1 to i8*
%3 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 0
%4 = bitcast [5 x double]* %1 to <2 x double>*
store <2 x double> <double 1.500000e+01, double 2.000000e+01>, <2 x double>* %4
%5 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 2
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 3.500000e+01, double 4.000000e+01>, <2 x double>* %6
%7 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 4
store double 5.000000e+01, double* %7
%8 = tail call i64 (...) @clock()
%9 = call double @CSPL_Stats_median_sort(double* %3, i64 5)
%10 = call i64 (...) @clock()
%11 = sub nsw i64 %10, %8
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %9, i64 %11)
%13 = call i64 (...) @clock()
%14 = call double @CSPL_Stats_median_quickselect(double* %3, i64 5)
%15 = call i64 (...) @clock()
%16 = sub nsw i64 %15, %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), double %14, i64 %16)
%18 = call i64 (...) @clock()
%19 = call double @CSPL_Stats_median_bin(double* %3, i64 5)
%20 = call i64 (...) @clock()
%21 = sub nsw i64 %20, %18
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %19, i64 %21)
%23 = fsub double %9, %14
%24 = fptosi double %23 to i32
%25 = call i32 @fabs(i32 %24)
%26 = icmp sgt i32 %25, 0
br i1 %26, label %105, label %27
27: ; preds = %0
%28 = fsub double %9, %19
%29 = fptosi double %28 to i32
%30 = call i32 @fabs(i32 %29)
%31 = icmp sgt i32 %30, 0
br i1 %31, label %105, label %32
32: ; preds = %27
%33 = fsub double %14, %19
%34 = fptosi double %33 to i32
%35 = call i32 @fabs(i32 %34)
%36 = icmp sgt i32 %35, 0
br i1 %36, label %105, label %37
37: ; preds = %32
%38 = fadd double %9, -3.500000e+01
%39 = fptosi double %38 to i32
%40 = call i32 @fabs(i32 %39)
%41 = icmp sgt i32 %40, 0
br i1 %41, label %105, label %42
42: ; preds = %37
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
br label %44
44: ; preds = %100, %42
%45 = phi i64 [ 0, %42 ], [ %103, %100 ]
%46 = getelementptr inbounds [3 x i64], [3 x i64]* @__const.main.lens, i64 0, i64 %45
%47 = load i64, i64* %46
%48 = call i64 @calloc(i64 %47, i32 8)
%49 = inttoptr i64 %48 to double*
%50 = call i32 @srand(i32 123)
%51 = call i64 @llvm.smax.i64(i64 %47, i64 1)
br label %52
52: ; preds = %44, %52
%53 = phi i64 [ %59, %52 ], [ 0, %44 ]
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 100
%56 = add nsw i32 %55, 1
%57 = sitofp i32 %56 to double
%58 = getelementptr inbounds double, double* %49, i64 %53
store double %57, double* %58
%59 = add nuw nsw i64 %53, 1
%60 = icmp eq i64 %59, %51
br i1 %60, label %61, label %52
61: ; preds = %52
%62 = call double @CSPL_Stats_median_sort(double* %49, i64 %47)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i64 %47)
%64 = call double @CSPL_Stats_median_bin(double* %49, i64 %47)
%65 = call i64 (...) @clock()
%66 = call i64 (...) @clock()
%67 = sub nsw i64 %66, %65
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), double %62, i64 %67)
%69 = call i64 (...) @clock()
%70 = call double @CSPL_Stats_median_quickselect(double* %49, i64 %47)
%71 = call i64 (...) @clock()
%72 = sub nsw i64 %71, %69
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), double %70, i64 %72)
%74 = call i64 (...) @clock()
%75 = call double @CSPL_Stats_median_quickselect(double* %49, i64 %47)
%76 = call i64 (...) @clock()
%77 = sub nsw i64 %76, %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %75, i64 %77)
%79 = fsub double %62, %70
%80 = fptosi double %79 to i32
%81 = call i32 @fabs(i32 %80)
%82 = icmp sgt i32 %81, 0
br i1 %82, label %105, label %83
83: ; preds = %61
%84 = fsub double %62, %75
%85 = fptosi double %84 to i32
%86 = call i32 @fabs(i32 %85)
%87 = icmp sgt i32 %86, 0
br i1 %87, label %105, label %88
88: ; preds = %83
%89 = fsub double %70, %75
%90 = fptosi double %89 to i32
%91 = call i32 @fabs(i32 %90)
%92 = icmp sgt i32 %91, 0
br i1 %92, label %105, label %93
93: ; preds = %88
%94 = getelementptr inbounds [3 x double], [3 x double]* @__const.main.ans, i64 0, i64 %45
%95 = load double, double* %94
%96 = fsub double %62, %95
%97 = fptosi double %96 to i32
%98 = call i32 @fabs(i32 %97)
%99 = icmp sgt i32 %98, 0
br i1 %99, label %105, label %100
100: ; preds = %93
%101 = call i32 @free(double* %49)
%102 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
%103 = add nuw nsw i64 %45, 1
%104 = icmp eq i64 %103, 3
br i1 %104, label %105, label %44
105: ; preds = %93, %88, %83, %61, %100, %37, %32, %27, %0
%106 = phi i32 [ 1, %0 ], [ 1, %27 ], [ 1, %32 ], [ 1, %37 ], [ 1, %93 ], [ 1, %88 ], [ 1, %83 ], [ 1, %61 ], [ 0, %100 ]
ret i32 %106
}