user: Converte this assembly snippet into its equivalent C code:

```asm
<hpsort_double_doublematrix>:
  endbr64
  push   %rbp
  mov    %rcx,%r8
  mov    %rsp,%rbp
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x78,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    0x0(,%rsi,8),%rax
  mov    %rsp,%rcx
  mov    %rsp,-0x98(%rbp)
  mov    %rax,-0x88(%rbp)
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L251
L374:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L374
L251:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L216
  mov    %rsp,%r9
  test   %r12,%r12
  je     L348
L193:
  mov    %r12,%rax
  mov    %r15,%r14
  shr    %rax
  shr    %r14
  add    $0x1,%rax
  shl    $0x4,%r14
  mov    %rax,-0x48(%rbp)
  mov    %r15,%rax
  and    $0xfffffffffffffffe,%rax
  test   %r15,%r15
  mov    %rax,-0x58(%rbp)
  lea    0x0(,%rax,8),%r13
  mov    $0x8,%eax
  cmovne -0x88(%rbp),%rax
  mov    %rax,-0x90(%rbp)
  lea    -0x1(%r15),%rax
  mov    %rax,-0x50(%rbp)
L43:
  cmpq   $0x1,-0x48(%rbp)
  jne    L389
  nopw   0x0(%rax,%rax,1)
L196:
  lea    0x0(,%r12,8),%rax
  movsd  (%rbx),%xmm0
  lea    -0x8(%rbx,%rax,1),%rcx
  movsd  (%rcx),%xmm1
  test   %r15,%r15
  je     L309
  mov    -0x8(%r8,%rax,1),%rsi
  mov    -0x88(%rbp),%rdx
  mov    %r9,%rdi
  mov    %rcx,-0x80(%rbp)
  mov    %r8,-0x68(%rbp)
  mov    %rsi,-0x60(%rbp)
  movsd  %xmm0,-0x78(%rbp)
  movsd  %xmm1,-0x70(%rbp)
  call   <memcpy@plt>
  mov    -0x68(%rbp),%r8
  mov    -0x60(%rbp),%rsi
  movsd  -0x78(%rbp),%xmm0
  mov    -0x80(%rbp),%rcx
  mov    %rax,%r9
  mov    (%r8),%rdx
  movsd  -0x70(%rbp),%xmm1
  movsd  %xmm0,(%rcx)
  lea    0x8(%rdx),%rax
  cmp    %rax,%rsi
  je     L166
  xor    %eax,%eax
  cmpq   $0x2,-0x50(%rbp)
  jbe    L166
  nopw   0x0(%rax,%rax,1)
L135:
  movupd (%rdx,%rax,1),%xmm4
  movups %xmm4,(%rsi,%rax,1)
  add    $0x10,%rax
  cmp    %r14,%rax
  jne    L135
  cmp    -0x58(%rbp),%r15
  je     L307
  movsd  (%rdx,%r13,1),%xmm0
  movsd  %xmm0,(%rsi,%r13,1)
L307:
  sub    $0x1,%r12
  cmp    $0x1,%r12
  je     L336
  test   %r12,%r12
  je     L100
  movsd  (%rbx),%xmm0
L38:
  mov    -0x48(%rbp),%r11
  mov    %r11,%rax
  jmp    L110
L264:
  lea    0x1(%r12),%rax
  cmp    %r12,%rax
  ja     L398
L19:
  movsd  -0x8(%rbx,%rax,8),%xmm0
L110:
  lea    0x0(,%rax,8),%rdx
  lea    -0x8(%rdx),%r10
  lea    (%rbx,%r10,1),%rdi
  cmp    %r12,%rax
  jae    L272
  lea    (%rbx,%rdx,1),%rcx
  movsd  (%rcx),%xmm2
  comisd %xmm0,%xmm2
  jbe    L272
  add    $0x1,%rax
  movapd %xmm2,%xmm0
  mov    %rcx,%rdi
  mov    %rdx,%r10
L272:
  comisd %xmm1,%xmm0
  lea    0x0(,%r11,8),%rdx
  lea    -0x8(%rdx),%rcx
  lea    (%rbx,%rcx,1),%rsi
  jbe    L264
  movsd  %xmm0,(%rsi)
  test   %r15,%r15
  je     L154
  mov    (%r8,%r10,1),%rcx
  mov    -0x8(%r8,%rdx,1),%rsi
  lea    0x8(%rcx),%rdx
  cmp    %rdx,%rsi
  mov    $0x0,%edx
  je     L101
  cmpq   $0x2,-0x50(%rbp)
  jbe    L101
  nopw   0x0(%rax,%rax,1)
L224:
  movupd (%rcx,%rdx,1),%xmm3
  movups %xmm3,(%rsi,%rdx,1)
  add    $0x10,%rdx
  cmp    %rdx,%r14
  jne    L224
  cmp    -0x58(%rbp),%r15
  je     L154
  movsd  (%rcx,%r13,1),%xmm0
  movsd  %xmm0,(%rsi,%r13,1)
L154:
  mov    %rax,%r11
  add    %rax,%rax
  mov    %rdi,%rsi
  mov    %r10,%rcx
  cmp    %r12,%rax
  jbe    L19
L398:
  mov    %rsi,%rdi
L370:
  movsd  %xmm1,(%rdi)
  test   %r15,%r15
  je     L43
  mov    (%r8,%rcx,1),%r10
L158:
  mov    -0x90(%rbp),%rdx
  mov    %r9,%rsi
  mov    %r10,%rdi
  mov    %r8,-0x68(%rbp)
  mov    %r9,-0x60(%rbp)
  call   <memcpy@plt>
  cmpq   $0x1,-0x48(%rbp)
  mov    -0x60(%rbp),%r9
  mov    -0x68(%rbp),%r8
  je     L196
L389:
  subq   $0x1,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  shl    $0x3,%rax
  movsd  -0x8(%rbx,%rax,1),%xmm0
  test   %r15,%r15
  je     L329
  mov    -0x8(%r8,%rax,1),%r10
  mov    -0x88(%rbp),%rdx
  mov    %r9,%rdi
  mov    %r8,-0x68(%rbp)
  movsd  %xmm0,-0x70(%rbp)
  mov    %r10,%rsi
  mov    %r10,-0x60(%rbp)
  call   <memcpy@plt>
  movsd  -0x70(%rbp),%xmm0
  cmp    -0x48(%rbp),%r12
  mov    -0x60(%rbp),%r10
  mov    -0x68(%rbp),%r8
  mov    %rax,%r9
  movapd %xmm0,%xmm1
  jae    L38
  jmp    L158
  nopl   (%rax)
L101:
  movsd  (%rcx,%rdx,8),%xmm0
  movsd  %xmm0,(%rsi,%rdx,8)
  add    $0x1,%rdx
  cmp    %r15,%rdx
  jne    L101
  jmp    L154
L336:
  movsd  %xmm1,(%rbx)
  test   %r15,%r15
  je     L348
  mov    (%r8),%rdi
  mov    -0x88(%rbp),%rdx
  mov    %r9,%rsi
  call   <memcpy@plt>
L348:
  mov    -0x98(%rbp),%rsp
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L90
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L166:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L268:
  movsd  (%rdx,%rax,8),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r15
  jne    L268
  jmp    L307
L309:
  movsd  %xmm0,(%rcx)
  jmp    L307
L100:
  mov    %rbx,%rdi
  xor    %ecx,%ecx
  jmp    L370
L329:
  movapd %xmm0,%xmm1
  cmp    -0x48(%rbp),%r12
  jae    L38
  jmp    L43
L216:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  mov    %rsp,%r9
  test   %r12,%r12
  jne    L193
  jmp    L348
L90:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void hpsort_double_doublematrix(unsigned long n, unsigned long nmat, double ra[], double **ra2) {
  unsigned long i, ir, j, l;
  unsigned long iaux;
  double rra;
  double rra2[nmat];
  if (n < 1)
    return;
  l = (n >> 1) + 1;
  ir = n;
  for (;;) {
    if (l > 1) {
      rra = ra[--l - 1];
      for (iaux = 0; iaux < nmat; iaux++) {
        rra2[iaux] = ra2[l - 1][iaux];
      }
    } else {
      rra = ra[ir - 1];
      for (iaux = 0; iaux < nmat; iaux++) {
        rra2[iaux] = ra2[ir - 1][iaux];
      }
      ra[ir - 1] = ra[0];
      for (iaux = 0; iaux < nmat; iaux++) {
        ra2[ir - 1][iaux] = ra2[0][iaux];
      }
      if (--ir == 1) {
        ra[0] = rra;
        for (iaux = 0; iaux < nmat; iaux++) {
          ra2[0][iaux] = rra2[iaux];
        }
        break;
      }
    }
    i = l;
    j = l;
    while (j <= ir) {
      if (j < ir && ra[j - 1] < ra[j])
        j++;
      if (rra < ra[j - 1]) {
        ra[i - 1] = ra[j - 1];
        for (iaux = 0; iaux < nmat; iaux++) {
          ra2[i - 1][iaux] = ra2[j - 1][iaux];
        }
        i = j;
        j <<= 1;
      } else
        j = ir + 1;
    }
    ra[i - 1] = rra;
    for (iaux = 0; iaux < nmat; iaux++) {
      ra2[i - 1][iaux] = rra2[iaux];
    }
  }
}
```