void mysort2(int N, double *data1, double *data2) {
  int i, j;
  double v, t1, t2;
  if (N <= 1)
    return;
  v = data1[0];
  i = 0;
  j = N;
  for (;;) {
    while (++i < N ? data1[i] < v : 0) {
    }
    while (data1[--j] > v) {
    }
    if (i >= j)
      break;
    t1 = data1[i];
    data1[i] = data1[j];
    data1[j] = t1;
    t2 = data2[i];
    data2[i] = data2[j];
    data2[j] = t2;
  }
  t1 = data1[i - 1];
  data1[i - 1] = data1[0];
  data1[0] = t1;
  t2 = data2[i - 1];
  data2[i - 1] = data2[0];
  data2[0] = t2;
  mysort2(i - 1, data1, data2);
  mysort2(N - i, data1 + i, data2 + i);
}


x86 assembly (clang, -O0):
<mysort2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     1132 <mysort2+0x22>
jmp    1318 <mysort2+0x208>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1151 <mysort2+0x41>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    -0x4(%rbp),%eax
jge    1189 <mysort2+0x79>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
jmp    1193 <mysort2+0x83>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    1193 <mysort2+0x83>
mov    -0x3c(%rbp),%eax
cmp    $0x0,%eax
je     11a4 <mysort2+0x94>
jmp    1151 <mysort2+0x41>
jmp    11a9 <mysort2+0x99>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11ce <mysort2+0xbe>
jmp    11a9 <mysort2+0x99>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     11df <mysort2+0xcf>
jmp    1260 <mysort2+0x150>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    114c <mysort2+0x3c>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x1c(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <mysort2@plt>
mov    -0x4(%rbp),%edi
sub    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1030 <mysort2@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysort2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jge    1132 <mysort2+0x22>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
movabs $0xffffffff00000000,%r14
ff ff ff
movabs $0x100000000,%r11
jmp    11c4 <mysort2+0xb4>
nopl   0x0(%rax,%rax,1)
lea    (%r15,%r13,1),%edi
mov    %r12,%rax
neg    %rax
sar    $0x1d,%rax
movsd  (%rbx,%rax,1),%xmm0
movsd  (%rbx),%xmm1
movsd  %xmm1,(%rbx,%rax,1)
movsd  %xmm0,(%rbx)
movsd  (%rdx,%rax,1),%xmm0
movsd  (%rdx),%xmm1
movsd  %xmm1,(%rdx,%rax,1)
movsd  %xmm0,(%rdx)
mov    %rbx,%rsi
mov    %rdx,0x10(%rsp)
mov    %r11,%rbp
call   1030 <mysort2@plt>
mov    %rbp,%r11
mov    0x10(%rsp),%rdx
mov    0xc(%rsp),%eax
sub    %r13d,%eax
not    %r15d
add    %eax,%r15d
mov    %rbp,%rax
sub    %r12,%rax
sar    $0x1d,%rax
add    %rax,%rbx
add    %rax,%rdx
mov    %r15d,%edi
cmp    $0x1,%r15d
jle    1123 <mysort2+0x13>
movsd  (%rbx),%xmm0
mov    %edi,%r10d
lea    0x8(%rbx),%r8
mov    %edi,0xc(%rsp)
mov    %edi,%eax
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movslq %r13d,%r9
mov    %r9,%rsi
imul   %r14,%rsi
lea    0x1(%r9),%rdi
lea    (%r8,%r9,8),%rcx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rsi,%r12
mov    %rbp,%r15
lea    (%rdi,%rbp,1),%rsi
cmp    %r10,%rsi
jge    121f <mysort2+0x10f>
lea    (%r12,%r14,1),%rsi
lea    0x1(%r15),%rbp
ucomisd (%rcx,%r15,8),%xmm0
ja     1200 <mysort2+0xf0>
cltq
lea    (%r9,%r15,1),%rsi
add    $0x1,%rsi
nopl   0x0(%rax)
movsd  -0x8(%rbx,%rax,8),%xmm1
add    $0xffffffffffffffff,%rax
ucomisd %xmm0,%xmm1
ja     1230 <mysort2+0x120>
lea    (%r15,%r13,1),%ecx
add    $0x1,%ecx
cmp    %eax,%ecx
jge    1150 <mysort2+0x40>
mov    %r11,%rcx
sub    %r12,%rcx
sar    $0x1d,%rcx
movsd  (%rbx,%rcx,1),%xmm2
movsd  %xmm1,(%rbx,%rcx,1)
movsd  %xmm2,(%rbx,%rax,8)
movsd  (%rdx,%rcx,1),%xmm1
movsd  (%rdx,%rax,8),%xmm2
movsd  %xmm2,(%rdx,%rcx,1)
movsd  %xmm1,(%rdx,%rax,8)
mov    %rsi,%r13
jmp    11e0 <mysort2+0xd0>

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

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