user: 请从给定的汇编指令推导出C源代码:

```asm
<heapsort2_d>:
  endbr64
  mov    %edi,%r8d
  push   %r14
  mov    %rsi,%rcx
  mov    %rdx,%rdi
  mov    %r8d,%r11d
  push   %r13
  shr    $0x1f,%r11d
  push   %r12
  add    %r8d,%r11d
  push   %rbp
  sar    %r11d
  push   %rbx
  sub    $0x1,%r11d
  js     L138
  movslq %r11d,%rbx
  lea    0x1(%r11,%r11,1),%ebp
  lea    -0x1(%r8),%r10d
  shl    $0x3,%rbx
  lea    (%rsi,%rbx,1),%r12
  add    %rdx,%rbx
  nopl   0x0(%rax,%rax,1)
L73:
  movsd  (%r12),%xmm2
  movsd  (%rbx),%xmm3
  mov    %r12,%r14
  mov    %rbx,%rdx
  mov    %ebp,%r13d
  cmp    %ebp,%r8d
  jle    L10
  movslq %r11d,%rdx
  jmp    L93
  nopl   (%rax)
L32:
  add    %rdi,%rax
  movsd  %xmm0,(%r14)
  lea    0x1(%rsi,%rsi,1),%r13d
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%rdx)
  cmp    %r13d,%r8d
  jle    L48
  movslq %esi,%rdx
L93:
  movslq %r13d,%rax
  mov    %r13d,%esi
  shl    $0x3,%rax
  lea    (%rcx,%rax,1),%r9
  movsd  (%r9),%xmm0
  cmp    %r10d,%r13d
  jge    L91
  lea    0x8(%rax),%r13
  lea    (%rcx,%r13,1),%r14
  movsd  (%r14),%xmm1
  comisd %xmm0,%xmm1
  jbe    L91
  add    $0x1,%esi
  movapd %xmm1,%xmm0
  mov    %r14,%r9
  mov    %r13,%rax
L91:
  shl    $0x3,%rdx
  lea    (%rcx,%rdx,1),%r14
  add    %rdi,%rdx
  comisd %xmm0,%xmm2
  jb     L32
L10:
  sub    $0x1,%r11d
  movsd  %xmm2,(%r14)
  sub    $0x8,%r12
  sub    $0x2,%ebp
  movsd  %xmm3,(%rdx)
  sub    $0x8,%rbx
  cmp    $0xffffffff,%r11d
  jne    L73
L138:
  test   %r8d,%r8d
  jle    L56
  lea    -0x1(%r8),%r10d
  sub    $0x2,%r8d
  movslq %r10d,%r10
  nopl   0x0(%rax,%rax,1)
L101:
  movsd  (%rcx),%xmm0
  movsd  (%rcx,%r10,8),%xmm2
  mov    %r10d,%r11d
  movsd  %xmm0,(%rcx,%r10,8)
  movsd  (%rdi),%xmm0
  movsd  (%rdi,%r10,8),%xmm3
  movsd  %xmm0,(%rdi,%r10,8)
  cmp    $0x1,%r10d
  jle    L8
  mov    $0x1,%esi
  xor    %eax,%eax
  jmp    L141
  cs nopw 0x0(%rax,%rax,1)
L148:
  add    %rdi,%rdx
  movsd  %xmm0,(%rsi)
  lea    0x1(%r9,%r9,1),%esi
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  cmp    %r11d,%esi
  jge    L34
  movslq %r9d,%rax
L141:
  movslq %esi,%rdx
  mov    %esi,%r9d
  shl    $0x3,%rdx
  lea    (%rcx,%rdx,1),%rbx
  movsd  (%rbx),%xmm0
  cmp    %r8d,%esi
  jge    L102
  lea    0x8(%rdx),%rsi
  lea    (%rcx,%rsi,1),%rbp
  movsd  0x0(%rbp),%xmm1
  comisd %xmm0,%xmm1
  jbe    L102
  add    $0x1,%r9d
  movapd %xmm1,%xmm0
  mov    %rbp,%rbx
  mov    %rsi,%rdx
L102:
  shl    $0x3,%rax
  lea    (%rcx,%rax,1),%rsi
  add    %rdi,%rax
  comisd %xmm0,%xmm2
  jb     L148
L167:
  movsd  %xmm2,(%rsi)
  movsd  %xmm3,(%rax)
L55:
  sub    $0x1,%r10
  sub    $0x1,%r8d
  jmp    L101
  nopw   0x0(%rax,%rax,1)
L48:
  mov    %rax,%rdx
  mov    %r9,%r14
  jmp    L10
  nopl   0x0(%rax,%rax,1)
L34:
  mov    %rdx,%rax
  mov    %rbx,%rsi
  jmp    L167
L8:
  movsd  %xmm2,(%rcx)
  movsd  %xmm3,(%rdi)
  je     L55
L56:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
void heapsort2_d(int n, double key[], double val[]) {
  int i, j, k;
  double key0;
  double val0;
  for (k = n / 2 - 1; k >= 0; k--) {
    i = k;
    key0 = key[i];
    val0 = val[i];
    j = 2 * i + 1;
    while (j <= n - 1) {
      if (j < n - 1 && key[j] < key[j + 1])
        j++;
      if (key0 >= key[j])
        break;
      key[i] = key[j];
      val[i] = val[j];
      i = j;
      j = 2 * i + 1;
    }
    key[i] = key0;
    val[i] = val0;
  }
  while (n > 0) {
    key0 = key[n - 1];
    key[n - 1] = key[0];
    val0 = val[n - 1];
    val[n - 1] = val[0];
    n--;
    i = 0;
    j = 2 * i + 1;
    while (j <= n - 1) {
      if (j < n - 1 && key[j] < key[j + 1])
        j++;
      if (key0 >= key[j])
        break;
      key[i] = key[j];
      val[i] = val[j];
      i = j;
      j = 2 * i + 1;
    }
    key[i] = key0;
    val[i] = val0;
  }
}
```