void quicksort(double **x, long first, long last) {
  long pivot, j, i;
  double temp;
  if (first < last) {
    pivot = first;
    i = first;
    j = last;
    while (i < j) {
      while (x[0][i] <= x[0][pivot] && i < last)
        i++;
      while (x[0][j] > x[0][pivot])
        j--;
      if (i < j) {
        temp = x[0][i];
        x[0][i] = x[0][j];
        x[0][j] = temp;
        temp = x[1][i];
        x[1][i] = x[1][j];
        x[1][j] = temp;
      }
    }
    temp = x[0][pivot];
    x[0][pivot] = x[0][j];
    x[0][j] = temp;
    temp = x[1][pivot];
    x[1][pivot] = x[1][j];
    x[1][j] = temp;
    quicksort(x, first, j - 1);
    quicksort(x, j + 1, last);
  }
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1364 <quicksort+0x254>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    12a2 <quicksort+0x192>
jmp    115d <quicksort+0x4d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x39(%rbp)
jb     119a <quicksort+0x8a>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11aa <quicksort+0x9a>
jmp    11bb <quicksort+0xab>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    115d <quicksort+0x4d>
jmp    11c0 <quicksort+0xb0>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    11f7 <quicksort+0xe7>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    11c0 <quicksort+0xb0>
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    129d <quicksort+0x18d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    114a <quicksort+0x3a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
call   1030 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
call   1030 <quicksort@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %r15
push   %r14
push   %rbx
cmp    %rdx,%rsi
jge    1200 <quicksort+0xf0>
mov    %rdx,%r15
mov    %rdi,%r14
jmp    1178 <quicksort+0x68>
cs nopw 0x0(%rax,%rax,1)
movsd  (%rax,%rsi,8),%xmm0
movsd  (%rax,%rbx,8),%xmm1
movsd  %xmm1,(%rax,%rsi,8)
movsd  %xmm0,(%rax,%rbx,8)
mov    0x8(%r14),%rax
movsd  (%rax,%rsi,8),%xmm0
movsd  (%rax,%rbx,8),%xmm1
movsd  %xmm1,(%rax,%rsi,8)
movsd  %xmm0,(%rax,%rbx,8)
lea    -0x1(%rbx),%rdx
mov    %r14,%rdi
call   1030 <quicksort@plt>
add    $0x1,%rbx
mov    %rbx,%rsi
cmp    %r15,%rbx
jge    1200 <quicksort+0xf0>
mov    (%r14),%rax
mov    %r15,%rbx
cmp    %r15,%rsi
jge    1130 <quicksort+0x20>
mov    %rsi,%rcx
mov    %r15,%rbx
nopl   0x0(%rax)
movsd  (%rax,%rsi,8),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rax,%rcx,8),%xmm0
lea    0x1(%rcx),%rdx
ucomisd %xmm0,%xmm1
jb     11b7 <quicksort+0xa7>
cmp    %r15,%rcx
mov    %rdx,%rcx
jl     11a0 <quicksort+0x90>
lea    -0x1(%rdx),%rcx
add    $0x1,%rbx
nop
movsd  -0x8(%rax,%rbx,8),%xmm2
add    $0xffffffffffffffff,%rbx
ucomisd %xmm1,%xmm2
ja     11c0 <quicksort+0xb0>
cmp    %rbx,%rcx
jge    1130 <quicksort+0x20>
movsd  %xmm2,-0x8(%rax,%rdx,8)
movsd  %xmm0,(%rax,%rbx,8)
mov    0x8(%r14),%rdi
movsd  -0x8(%rdi,%rdx,8),%xmm0
movsd  (%rdi,%rbx,8),%xmm1
movsd  %xmm1,-0x8(%rdi,%rdx,8)
movsd  %xmm0,(%rdi,%rbx,8)
jmp    1190 <quicksort+0x80>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @quicksort(double** %0, i64 %1, i64 %2) {
%4 = icmp slt i64 %1, %2
br i1 %4, label %5, label %56
5: ; preds = %3
%6 = getelementptr inbounds double*, double** %0, i64 1
br label %7
7: ; preds = %5, %42
%8 = phi i64 [ %1, %5 ], [ %54, %42 ]
%9 = icmp slt i64 %8, %2
%10 = load double*, double** %0
br i1 %9, label %11, label %42
11: ; preds = %7
%12 = getelementptr inbounds double, double* %10, i64 %8
br label %13
13: ; preds = %35, %11
%14 = phi i64 [ %8, %11 ], [ %18, %35 ]
%15 = phi i64 [ %2, %11 ], [ %28, %35 ]
%16 = load double, double* %12
br label %17
17: ; preds = %17, %13
%18 = phi i64 [ %24, %17 ], [ %14, %13 ]
%19 = getelementptr inbounds double, double* %10, i64 %18
%20 = load double, double* %19
%21 = fcmp ole double %20, %16
%22 = icmp slt i64 %18, %2
%23 = select i1 %21, i1 %22, i1 false
%24 = add nsw i64 %18, 1
br i1 %23, label %17, label %25
25: ; preds = %17
%26 = getelementptr inbounds double, double* %10, i64 %18
br label %27
27: ; preds = %27, %25
%28 = phi i64 [ %32, %27 ], [ %15, %25 ]
%29 = getelementptr inbounds double, double* %10, i64 %28
%30 = load double, double* %29
%31 = fcmp ogt double %30, %16
%32 = add nsw i64 %28, -1
br i1 %31, label %27, label %33
33: ; preds = %27
%34 = icmp slt i64 %18, %28
br i1 %34, label %35, label %42
35: ; preds = %33
%36 = getelementptr inbounds double, double* %10, i64 %28
store double %30, double* %26
store double %20, double* %36
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 %18
%39 = load double, double* %38
%40 = getelementptr inbounds double, double* %37, i64 %28
%41 = load double, double* %40
store double %41, double* %38
store double %39, double* %40
br label %13
42: ; preds = %33, %7
%43 = phi i64 [ %2, %7 ], [ %28, %33 ]
%44 = getelementptr inbounds double, double* %10, i64 %8
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %10, i64 %43
%47 = load double, double* %46
store double %47, double* %44
store double %45, double* %46
%48 = load double*, double** %6
%49 = getelementptr inbounds double, double* %48, i64 %8
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %48, i64 %43
%52 = load double, double* %51
store double %52, double* %49
store double %50, double* %51
%53 = add nsw i64 %43, -1
tail call void @quicksort(double** %0, i64 %8, i64 %53)
%54 = add nsw i64 %43, 1
%55 = icmp slt i64 %54, %2
br i1 %55, label %7, label %56
56: ; preds = %42, %3
ret void
}