void hpsort_tripledouble(unsigned long n, double ra[], double ra2[],
                         double ra3[]) {
  unsigned long i, ir, j, l;
  double rra;
  double rra2;
  double rra3;
  if (n < 1)
    return;
  l = (n >> 1) + 1;
  ir = n;
  for (;;) {
    if (l > 1) {
      rra = ra[--l - 1];
      rra2 = ra2[l - 1];
      rra3 = ra3[l - 1];
    } else {
      rra = ra[ir - 1];
      rra2 = ra2[ir - 1];
      rra3 = ra3[ir - 1];
      ra[ir - 1] = ra[0];
      ra2[ir - 1] = ra2[0];
      ra3[ir - 1] = ra3[0];
      if (--ir == 1) {
        ra[0] = rra;
        ra2[0] = rra2;
        ra3[0] = rra3;
        break;
      }
    }
    i = l;
    j = l + l;
    while (j <= ir) {
      if (j < ir && ra[j - 1] < ra[j])
        j++;
      if (rra < ra[j - 1]) {
        ra[i - 1] = ra[j - 1];
        ra2[i - 1] = ra2[j - 1];
        ra3[i - 1] = ra3[j - 1];
        i = j;
        j <<= 1;
      } else
        j = ir + 1;
    }
    ra[i - 1] = rra;
    ra2[i - 1] = rra2;
    ra3[i - 1] = rra3;
  }
}


x86 assembly (clang, -O0):
<hpsort_tripledouble>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x1,-0x8(%rbp)
jae    1124 <hpsort_tripledouble+0x24>
jmp    13c5 <hpsort_tripledouble+0x2c5>
mov    -0x8(%rbp),%rax
shr    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x1,-0x40(%rbp)
jbe    1196 <hpsort_tripledouble+0x96>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x40(%rbp)
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    126a <hpsort_tripledouble+0x16a>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
cmp    $0x1,%rax
jne    1265 <hpsort_tripledouble+0x165>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    13c5 <hpsort_tripledouble+0x2c5>
jmp    126a <hpsort_tripledouble+0x16a>
mov    -0x40(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
ja     137e <hpsort_tripledouble+0x27e>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    12ce <hpsort_tripledouble+0x1ce>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    12ce <hpsort_tripledouble+0x1ce>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    136d <hpsort_tripledouble+0x26d>
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1379 <hpsort_tripledouble+0x279>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    127e <hpsort_tripledouble+0x17e>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    $0x1,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    113c <hpsort_tripledouble+0x3c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpsort_tripledouble>:
test   %rdi,%rdi
je     1227 <hpsort_tripledouble+0x127>
mov    %rdi,%r8
shr    %r8
add    $0x1,%r8
jmp    1135 <hpsort_tripledouble+0x35>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,-0x8(%rsi,%r10,8)
movsd  %xmm1,-0x8(%rdx,%r10,8)
movsd  %xmm2,-0x8(%rcx,%r10,8)
cmp    $0x2,%r8
jb     1160 <hpsort_tripledouble+0x60>
movsd  -0x10(%rsi,%r8,8),%xmm0
movsd  -0x10(%rdx,%r8,8),%xmm1
movsd  -0x10(%rcx,%r8,8),%xmm2
add    $0xffffffffffffffff,%r8
jmp    11a3 <hpsort_tripledouble+0xa3>
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rdi),%rax
movsd  -0x8(%rsi,%rdi,8),%xmm0
movsd  -0x8(%rdx,%rdi,8),%xmm1
movsd  -0x8(%rcx,%rdi,8),%xmm2
movsd  (%rsi),%xmm3
movsd  %xmm3,-0x8(%rsi,%rdi,8)
movsd  (%rdx),%xmm3
movsd  %xmm3,-0x8(%rdx,%rdi,8)
movsd  (%rcx),%xmm3
movsd  %xmm3,-0x8(%rcx,%rdi,8)
mov    $0x1,%r8d
cmp    $0x1,%rax
je     121b <hpsort_tripledouble+0x11b>
mov    %rax,%rdi
lea    (%r8,%r8,1),%rax
mov    %r8,%r10
cmp    %rdi,%rax
ja     1120 <hpsort_tripledouble+0x20>
lea    0x1(%rdi),%r9
mov    %r8,%r10
jmp    11f4 <hpsort_tripledouble+0xf4>
nopl   0x0(%rax)
movsd  %xmm3,-0x8(%rsi,%r10,8)
movsd  -0x8(%rdx,%rax,8),%xmm3
movsd  %xmm3,-0x8(%rdx,%r10,8)
movsd  -0x8(%rcx,%rax,8),%xmm3
movsd  %xmm3,-0x8(%rcx,%r10,8)
lea    (%rax,%rax,1),%r11
mov    %rax,%r10
mov    %r11,%rax
cmp    %rdi,%r11
ja     1120 <hpsort_tripledouble+0x20>
cmp    %rdi,%rax
jae    120a <hpsort_tripledouble+0x10a>
movsd  (%rsi,%rax,8),%xmm3
ucomisd -0x8(%rsi,%rax,8),%xmm3
jbe    120a <hpsort_tripledouble+0x10a>
add    $0x1,%rax
movsd  -0x8(%rsi,%rax,8),%xmm3
ucomisd %xmm0,%xmm3
ja     11c0 <hpsort_tripledouble+0xc0>
mov    %r9,%r11
jmp    11e8 <hpsort_tripledouble+0xe8>
movsd  %xmm0,(%rsi)
movsd  %xmm1,(%rdx)
movsd  %xmm2,(%rcx)
ret

LLVM IR (-O0):
define void @hpsort_tripledouble(i64 %0, double* %1, double* %2, double* %3) {
%5 = alloca i64
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i64 %0, i64* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%16 = load i64, i64* %5
%17 = icmp ult i64 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %4
br label %181
19: ; preds = %4
%20 = load i64, i64* %5
%21 = lshr i64 %20, 1
%22 = add i64 %21, 1
store i64 %22, i64* %12
%23 = load i64, i64* %5
store i64 %23, i64* %10
br label %24
24: ; preds = %165, %19
%25 = load i64, i64* %12
%26 = icmp ugt i64 %25, 1
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load double*, double** %6
%29 = load i64, i64* %12
%30 = add i64 %29, -1
store i64 %30, i64* %12
%31 = sub i64 %30, 1
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
store double %33, double* %13
%34 = load double*, double** %7
%35 = load i64, i64* %12
%36 = sub i64 %35, 1
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
store double %38, double* %14
%39 = load double*, double** %8
%40 = load i64, i64* %12
%41 = sub i64 %40, 1
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
store double %43, double* %15
br label %95
44: ; preds = %24
%45 = load double*, double** %6
%46 = load i64, i64* %10
%47 = sub i64 %46, 1
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
store double %49, double* %13
%50 = load double*, double** %7
%51 = load i64, i64* %10
%52 = sub i64 %51, 1
%53 = getelementptr inbounds double, double* %50, i64 %52
%54 = load double, double* %53
store double %54, double* %14
%55 = load double*, double** %8
%56 = load i64, i64* %10
%57 = sub i64 %56, 1
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
store double %59, double* %15
%60 = load double*, double** %6
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = load double*, double** %6
%64 = load i64, i64* %10
%65 = sub i64 %64, 1
%66 = getelementptr inbounds double, double* %63, i64 %65
store double %62, double* %66
%67 = load double*, double** %7
%68 = getelementptr inbounds double, double* %67, i64 0
%69 = load double, double* %68
%70 = load double*, double** %7
%71 = load i64, i64* %10
%72 = sub i64 %71, 1
%73 = getelementptr inbounds double, double* %70, i64 %72
store double %69, double* %73
%74 = load double*, double** %8
%75 = getelementptr inbounds double, double* %74, i64 0
%76 = load double, double* %75
%77 = load double*, double** %8
%78 = load i64, i64* %10
%79 = sub i64 %78, 1
%80 = getelementptr inbounds double, double* %77, i64 %79
store double %76, double* %80
%81 = load i64, i64* %10
%82 = add i64 %81, -1
store i64 %82, i64* %10
%83 = icmp eq i64 %82, 1
br i1 %83, label %84, label %94
84: ; preds = %44
%85 = load double, double* %13
%86 = load double*, double** %6
%87 = getelementptr inbounds double, double* %86, i64 0
store double %85, double* %87
%88 = load double, double* %14
%89 = load double*, double** %7
%90 = getelementptr inbounds double, double* %89, i64 0
store double %88, double* %90
%91 = load double, double* %15
%92 = load double*, double** %8
%93 = getelementptr inbounds double, double* %92, i64 0
store double %91, double* %93
br label %181
94: ; preds = %44
br label %95
95: ; preds = %94, %27
%96 = load i64, i64* %12
store i64 %96, i64* %9
%97 = load i64, i64* %12
%98 = load i64, i64* %12
%99 = add i64 %97, %98
store i64 %99, i64* %11
br label %100
100: ; preds = %164, %95
%101 = load i64, i64* %11
%102 = load i64, i64* %10
%103 = icmp ule i64 %101, %102
br i1 %103, label %104, label %165
104: ; preds = %100
%105 = load i64, i64* %11
%106 = load i64, i64* %10
%107 = icmp ult i64 %105, %106
br i1 %107, label %108, label %122
108: ; preds = %104
%109 = load double*, double** %6
%110 = load i64, i64* %11
%111 = sub i64 %110, 1
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load double*, double** %6
%115 = load i64, i64* %11
%116 = getelementptr inbounds double, double* %114, i64 %115
%117 = load double, double* %116
%118 = fcmp olt double %113, %117
br i1 %118, label %119, label %122
119: ; preds = %108
%120 = load i64, i64* %11
%121 = add i64 %120, 1
store i64 %121, i64* %11
br label %122
122: ; preds = %119, %108, %104
%123 = load double, double* %13
%124 = load double*, double** %6
%125 = load i64, i64* %11
%126 = sub i64 %125, 1
%127 = getelementptr inbounds double, double* %124, i64 %126
%128 = load double, double* %127
%129 = fcmp olt double %123, %128
br i1 %129, label %130, label %161
130: ; preds = %122
%131 = load double*, double** %6
%132 = load i64, i64* %11
%133 = sub i64 %132, 1
%134 = getelementptr inbounds double, double* %131, i64 %133
%135 = load double, double* %134
%136 = load double*, double** %6
%137 = load i64, i64* %9
%138 = sub i64 %137, 1
%139 = getelementptr inbounds double, double* %136, i64 %138
store double %135, double* %139
%140 = load double*, double** %7
%141 = load i64, i64* %11
%142 = sub i64 %141, 1
%143 = getelementptr inbounds double, double* %140, i64 %142
%144 = load double, double* %143
%145 = load double*, double** %7
%146 = load i64, i64* %9
%147 = sub i64 %146, 1
%148 = getelementptr inbounds double, double* %145, i64 %147
store double %144, double* %148
%149 = load double*, double** %8
%150 = load i64, i64* %11
%151 = sub i64 %150, 1
%152 = getelementptr inbounds double, double* %149, i64 %151
%153 = load double, double* %152
%154 = load double*, double** %8
%155 = load i64, i64* %9
%156 = sub i64 %155, 1
%157 = getelementptr inbounds double, double* %154, i64 %156
store double %153, double* %157
%158 = load i64, i64* %11
store i64 %158, i64* %9
%159 = load i64, i64* %11
%160 = shl i64 %159, 1
store i64 %160, i64* %11
br label %164
161: ; preds = %122
%162 = load i64, i64* %10
%163 = add i64 %162, 1
store i64 %163, i64* %11
br label %164
164: ; preds = %161, %130
br label %100
165: ; preds = %100
%166 = load double, double* %13
%167 = load double*, double** %6
%168 = load i64, i64* %9
%169 = sub i64 %168, 1
%170 = getelementptr inbounds double, double* %167, i64 %169
store double %166, double* %170
%171 = load double, double* %14
%172 = load double*, double** %7
%173 = load i64, i64* %9
%174 = sub i64 %173, 1
%175 = getelementptr inbounds double, double* %172, i64 %174
store double %171, double* %175
%176 = load double, double* %15
%177 = load double*, double** %8
%178 = load i64, i64* %9
%179 = sub i64 %178, 1
%180 = getelementptr inbounds double, double* %177, i64 %179
store double %176, double* %180
br label %24
181: ; preds = %18, %84
ret void
}

LLVM IR (-O2):
define void @hpsort_tripledouble(i64 %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = icmp eq i64 %0, 0
br i1 %5, label %84, label %6
6: ; preds = %4
%7 = lshr i64 %0, 1
%8 = add nuw i64 %7, 1
br label %9
9: ; preds = %78, %6
%10 = phi i64 [ %0, %6 ], [ %36, %78 ]
%11 = phi i64 [ %8, %6 ], [ %37, %78 ]
%12 = icmp ugt i64 %11, 1
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = add i64 %11, -1
%15 = add i64 %11, -2
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %2, i64 %15
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %3, i64 %15
%21 = load double, double* %20
br label %35
22: ; preds = %9
%23 = add i64 %10, -1
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = load double, double* %24
%26 = getelementptr inbounds double, double* %2, i64 %23
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %3, i64 %23
%29 = load double, double* %28
%30 = load double, double* %1
store double %30, double* %24
%31 = load double, double* %2
store double %31, double* %26
%32 = load double, double* %3
store double %32, double* %28
%33 = icmp eq i64 %23, 1
br i1 %33, label %34, label %35
34: ; preds = %22
store double %25, double* %1
store double %27, double* %2
store double %29, double* %3
br label %84
35: ; preds = %22, %13
%36 = phi i64 [ %10, %13 ], [ %23, %22 ]
%37 = phi i64 [ %14, %13 ], [ 1, %22 ]
%38 = phi double [ %17, %13 ], [ %25, %22 ]
%39 = phi double [ %19, %13 ], [ %27, %22 ]
%40 = phi double [ %21, %13 ], [ %29, %22 ]
%41 = shl i64 %37, 1
%42 = icmp ugt i64 %41, %36
br i1 %42, label %78, label %43
43: ; preds = %35
%44 = add i64 %36, 1
br label %45
45: ; preds = %43, %74
%46 = phi i64 [ %41, %43 ], [ %76, %74 ]
%47 = phi i64 [ %37, %43 ], [ %75, %74 ]
%48 = icmp ult i64 %46, %36
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = add i64 %46, -1
%51 = getelementptr inbounds double, double* %1, i64 %50
%52 = load double, double* %51
%53 = getelementptr inbounds double, double* %1, i64 %46
%54 = load double, double* %53
%55 = fcmp olt double %52, %54
br i1 %55, label %56, label %58
56: ; preds = %49
%57 = add nuw i64 %46, 1
br label %58
58: ; preds = %56, %49, %45
%59 = phi i64 [ %57, %56 ], [ %46, %49 ], [ %46, %45 ]
%60 = add i64 %59, -1
%61 = getelementptr inbounds double, double* %1, i64 %60
%62 = load double, double* %61
%63 = fcmp olt double %38, %62
br i1 %63, label %64, label %74
64: ; preds = %58
%65 = add i64 %47, -1
%66 = getelementptr inbounds double, double* %1, i64 %65
store double %62, double* %66
%67 = getelementptr inbounds double, double* %2, i64 %60
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %2, i64 %65
store double %68, double* %69
%70 = getelementptr inbounds double, double* %3, i64 %60
%71 = load double, double* %70
%72 = getelementptr inbounds double, double* %3, i64 %65
store double %71, double* %72
%73 = shl i64 %59, 1
br label %74
74: ; preds = %58, %64
%75 = phi i64 [ %59, %64 ], [ %47, %58 ]
%76 = phi i64 [ %73, %64 ], [ %44, %58 ]
%77 = icmp ugt i64 %76, %36
br i1 %77, label %78, label %45
78: ; preds = %74, %35
%79 = phi i64 [ %37, %35 ], [ %75, %74 ]
%80 = add i64 %79, -1
%81 = getelementptr inbounds double, double* %1, i64 %80
store double %38, double* %81
%82 = getelementptr inbounds double, double* %2, i64 %80
store double %39, double* %82
%83 = getelementptr inbounds double, double* %3, i64 %80
store double %40, double* %83
br label %9
84: ; preds = %4, %34
ret void
}