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

```asm
<heapsort>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,0x38(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rcx,0x8(%rsp)
  cmp    $0x1,%rsi
  jbe    L836
  mov    %rdx,%r12
  test   %rdx,%rdx
  je     L555
  mov    %rdx,%rdi
  call   <malloc@plt>
  mov    %rax,0x40(%rsp)
  test   %rax,%rax
  je     L537
  mov    0x38(%rsp),%r15
  mov    %r12,%r13
  and    $0xfffffffffffffff0,%r13
  mov    %r15,%rax
  mov    %r13,0x48(%rsp)
  sub    %r12,%rax
  mov    %rax,0x28(%rsp)
  mov    0x18(%rsp),%rax
  shr    %rax
  mov    %rax,0x58(%rsp)
  lea    -0x1(%r12),%rax
  mov    %rax,0x10(%rsp)
  mov    %r12,%rax
  and    $0xf,%eax
  mov    %rax,0x20(%rsp)
  sub    $0x1,%rax
  mov    %rax,0x50(%rsp)
  nopl   0x0(%rax)
L242:
  mov    0x58(%rsp),%r14
  lea    (%r14,%r14,1),%rax
  cmp    %rax,0x18(%rsp)
  jb     L78
  mov    %r15,%rcx
  mov    %r14,%rbp
  mov    %r13,%r15
  mov    %rcx,%r13
L197:
  mov    %r12,%rbx
  mov    %rax,%r14
  imul   %rax,%rbx
  add    0x28(%rsp),%rbx
  cmp    %rax,0x18(%rsp)
  jbe    L669
  lea    (%rbx,%r12,1),%rdx
  mov    0x8(%rsp),%rax
  mov    %rbx,%rdi
  mov    %rdx,0x30(%rsp)
  mov    %rdx,%rsi
  call   *%rax
  test   %eax,%eax
  jns    L669
  mov    0x30(%rsp),%rbx
  add    $0x1,%r14
L669:
  mov    %rbp,%rdx
  mov    0x28(%rsp),%rax
  mov    %rbx,%rdi
  imul   %r12,%rdx
  lea    (%rax,%rdx,1),%rbp
  mov    %rdx,0x30(%rsp)
  mov    0x8(%rsp),%rax
  mov    %rbp,%rsi
  call   *%rax
  mov    0x30(%rsp),%rdx
  test   %eax,%eax
  jle    L790
  mov    %rdx,%rax
  sub    %r12,%rax
  lea    0x10(%r13,%rax,1),%rsi
  lea    0x0(%r13,%rax,1),%rdx
  cmp    %rsi,%rbx
  lea    0x10(%rbx),%rsi
  setae  %dil
  cmp    %rsi,%rdx
  setae  %sil
  or     %dil,%sil
  je     L323
  mov    0x10(%rsp),%rcx
  cmp    $0x6,%rcx
  jbe    L323
  cmp    $0xe,%rcx
  jbe    L664
  xor    %esi,%esi
  xchg   %ax,%ax
L750:
  movdqu (%rdx,%rsi,1),%xmm0
  movdqu (%rbx,%rsi,1),%xmm1
  movups %xmm1,(%rdx,%rsi,1)
  movups %xmm0,(%rbx,%rsi,1)
  add    $0x10,%rsi
  cmp    %r15,%rsi
  jne    L750
  mov    0x48(%rsp),%rsi
  lea    (%rbx,%rsi,1),%rdx
  add    %rsi,%rbp
  cmp    %rsi,%r12
  je     L620
  mov    0x20(%rsp),%rdi
  cmpq   $0x6,0x50(%rsp)
  mov    %rdi,%r11
  jbe    L604
L691:
  add    %rsi,%rax
  add    %rbx,%rsi
  movq   (%rsi),%xmm0
  add    %r13,%rax
  mov    (%rax),%rbx
  movq   %xmm0,(%rax)
  mov    %r11,%rax
  and    $0xfffffffffffffff8,%rax
  mov    %rbx,(%rsi)
  sub    %rax,%rdi
  add    %rax,%rdx
  add    %rax,%rbp
  cmp    %rax,%r11
  je     L620
L604:
  movzbl 0x0(%rbp),%eax
  movzbl (%rdx),%esi
  mov    %sil,0x0(%rbp)
  mov    %al,(%rdx)
  cmp    $0x1,%rdi
  je     L620
  movzbl 0x1(%rbp),%eax
  movzbl 0x1(%rdx),%esi
  mov    %sil,0x1(%rbp)
  mov    %al,0x1(%rdx)
  cmp    $0x2,%rdi
  je     L620
  movzbl 0x2(%rbp),%eax
  movzbl 0x2(%rdx),%esi
  mov    %sil,0x2(%rbp)
  mov    %al,0x2(%rdx)
  cmp    $0x3,%rdi
  je     L620
  movzbl 0x3(%rbp),%eax
  movzbl 0x3(%rdx),%esi
  mov    %sil,0x3(%rbp)
  mov    %al,0x3(%rdx)
  cmp    $0x4,%rdi
  je     L620
  movzbl 0x4(%rbp),%eax
  movzbl 0x4(%rdx),%esi
  mov    %sil,0x4(%rbp)
  mov    %al,0x4(%rdx)
  cmp    $0x5,%rdi
  je     L620
  movzbl 0x5(%rbp),%eax
  movzbl 0x5(%rdx),%esi
  mov    %sil,0x5(%rbp)
  mov    %al,0x5(%rdx)
  cmp    $0x6,%rdi
  je     L620
  movzbl 0x6(%rbp),%eax
  movzbl 0x6(%rdx),%esi
  mov    %sil,0x6(%rbp)
  mov    %al,0x6(%rdx)
L620:
  lea    (%r14,%r14,1),%rax
  cmp    %rax,0x18(%rsp)
  jb     L790
L417:
  mov    %r14,%rbp
  jmp    L197
  xchg   %ax,%ax
L323:
  lea    (%rbx,%r12,1),%rsi
  nopl   0x0(%rax)
L432:
  movzbl 0x0(%rbp),%eax
  movzbl (%rbx),%edx
  add    $0x1,%rbx
  add    $0x1,%rbp
  mov    %dl,-0x1(%rbp)
  mov    %al,-0x1(%rbx)
  cmp    %rsi,%rbx
  jne    L432
  lea    (%r14,%r14,1),%rax
  cmp    %rax,0x18(%rsp)
  jae    L417
  nopl   (%rax)
L790:
  mov    %r13,%rax
  mov    %r15,%r13
  mov    %rax,%r15
L78:
  subq   $0x1,0x58(%rsp)
  jne    L242
  mov    0x18(%rsp),%rax
  mov    0x48(%rsp),%rbp
  mov    %r13,0x60(%rsp)
  mov    %r12,%r13
  mov    0x28(%rsp),%rcx
  sub    $0x1,%rax
  mov    %rax,0x70(%rsp)
  imul   %r12,%rax
  mov    %rax,0x78(%rsp)
  mov    0x38(%rsp),%rax
  add    %rbp,%rax
  mov    %rax,0x88(%rsp)
  lea    (%rcx,%r12,1),%rax
  mov    %rax,0x80(%rsp)
  mov    %r12,%rax
  mov    %rcx,%r12
  sub    %rbp,%rax
  mov    %rax,0x28(%rsp)
  sub    $0x1,%rax
  mov    %rax,0x30(%rsp)
  nopl   0x0(%rax)
L502:
  mov    0x78(%rsp),%r14
  mov    0x80(%rsp),%rbx
  mov    %r13,%rdx
  mov    0x40(%rsp),%rdi
  add    %r14,%rbx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  mov    0x10(%rsp),%rdx
  lea    -0x1(%r14),%rax
  cmp    $0x6,%rdx
  seta   0x18(%rsp)
  movzbl 0x18(%rsp),%edi
  cmp    $0xe,%rax
  jbe    L37
  test   %dil,%dil
  je     L37
  cmp    $0xe,%rdx
  jbe    L455
  mov    0x38(%rsp),%rsi
  mov    0x60(%rsp),%rcx
  xor    %eax,%eax
  mov    %rsi,%rdx
  add    %r14,%rdx
  xchg   %ax,%ax
L525:
  movdqu (%rsi,%rax,1),%xmm4
  movups %xmm4,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L525
  add    %rbp,%rbx
  cmp    %rbp,%r13
  je     L413
  cmpq   $0x6,0x30(%rsp)
  mov    0x28(%rsp),%rdi
  jbe    L754
  mov    0x88(%rsp),%rax
  mov    0x20(%rsp),%rsi
  mov    %rbp,%r10
L818:
  mov    0x38(%rsp),%rcx
  mov    (%rcx,%r10,1),%r11
  mov    %r11,(%rdx,%r10,1)
  mov    %rdi,%rdx
  and    $0xfffffffffffffff8,%rdx
  sub    %rdx,%rsi
  add    %rdx,%rbx
  add    %rdx,%rax
  cmp    %rdx,%rdi
  je     L413
L613:
  movzbl (%rax),%edx
  mov    %dl,(%rbx)
  cmp    $0x1,%rsi
  je     L413
  movzbl 0x1(%rax),%edx
  mov    %dl,0x1(%rbx)
  cmp    $0x2,%rsi
  je     L413
  movzbl 0x2(%rax),%edx
  mov    %dl,0x2(%rbx)
  cmp    $0x3,%rsi
  je     L413
  movzbl 0x3(%rax),%edx
  mov    %dl,0x3(%rbx)
  cmp    $0x4,%rsi
  je     L413
  movzbl 0x4(%rax),%edx
  mov    %dl,0x4(%rbx)
  cmp    $0x5,%rsi
  je     L413
  movzbl 0x5(%rax),%edx
  mov    %dl,0x5(%rbx)
  cmp    $0x6,%rsi
  je     L413
  movzbl 0x6(%rax),%eax
  mov    %al,0x6(%rbx)
L413:
  mov    0x70(%rsp),%r8
  cmp    $0x1,%r8
  je     L660
L122:
  mov    %r12,%r14
  mov    %rbp,%r12
  mov    0x60(%rsp),%rbp
  mov    $0x2,%edx
  mov    $0x1,%ebx
  nopl   0x0(%rax,%rax,1)
L4:
  mov    %r13,%r11
  imul   %rdx,%r11
  mov    %r11,0x48(%rsp)
  lea    (%r14,%r11,1),%r15
  cmp    %rdx,%r8
  jbe    L871
  lea    (%r15,%r13,1),%rsi
  mov    %r8,0x58(%rsp)
  mov    0x8(%rsp),%rax
  mov    %r15,%rdi
  mov    %rdx,0x50(%rsp)
  mov    %rsi,0x68(%rsp)
  call   *%rax
  mov    0x50(%rsp),%r10
  mov    0x58(%rsp),%r8
  mov    %r15,%r9
  test   %eax,%eax
  jns    L508
  mov    0x38(%rsp),%rax
  mov    0x48(%rsp),%r11
  add    $0x1,%r10
  mov    0x68(%rsp),%r15
  lea    (%rax,%r11,1),%r9
L508:
  imul   %r13,%rbx
  mov    0x38(%rsp),%rax
  lea    0x1(%r15),%rdi
  lea    (%r14,%rbx,1),%rdx
  sub    %r13,%rbx
  add    %rbx,%rax
  mov    %rax,%rsi
  sub    %rdi,%rsi
  cmp    $0xe,%rsi
  jbe    L54
  cmpb   $0x0,0x18(%rsp)
  je     L54
  cmpq   $0xe,0x10(%rsp)
  jbe    L773
  xor    %esi,%esi
  xchg   %ax,%ax
L838:
  movdqu (%r15,%rsi,1),%xmm3
  movups %xmm3,(%rax,%rsi,1)
  add    $0x10,%rsi
  cmp    %rbp,%rsi
  jne    L838
  add    %r12,%rdx
  lea    (%r15,%r12,1),%rsi
  cmp    %r12,%r13
  je     L168
  cmpq   $0x6,0x30(%rsp)
  mov    0x28(%rsp),%r11
  jbe    L523
  mov    0x20(%rsp),%rdi
  mov    %r12,%rbx
L318:
  mov    (%r15,%rbx,1),%r15
  mov    %r15,(%rax,%rbx,1)
  mov    %r11,%rax
  and    $0xfffffffffffffff8,%rax
  sub    %rax,%rdi
  add    %rax,%rdx
  add    %rax,%rsi
  cmp    %rax,%r11
  je     L168
L374:
  movzbl (%rsi),%eax
  mov    %al,(%rdx)
  cmp    $0x1,%rdi
  je     L168
  movzbl 0x1(%rsi),%eax
  mov    %al,0x1(%rdx)
  cmp    $0x2,%rdi
  je     L168
  movzbl 0x2(%rsi),%eax
  mov    %al,0x2(%rdx)
  cmp    $0x3,%rdi
  je     L168
  movzbl 0x3(%rsi),%eax
  mov    %al,0x3(%rdx)
  cmp    $0x4,%rdi
  je     L168
  movzbl 0x4(%rsi),%eax
  mov    %al,0x4(%rdx)
  cmp    $0x5,%rdi
  je     L168
  movzbl 0x5(%rsi),%eax
  mov    %al,0x5(%rdx)
  cmp    $0x6,%rdi
  je     L168
  movzbl 0x6(%rsi),%eax
  mov    %al,0x6(%rdx)
L168:
  lea    (%r10,%r10,1),%rdx
  cmp    %rdx,%r8
  jb     L409
L481:
  mov    %r10,%rbx
  jmp    L4
  nopl   (%rax)
L871:
  mov    %r15,%r9
  mov    %rdx,%r10
  jmp    L508
  nopl   0x0(%rax,%rax,1)
L54:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L345:
  movzbl (%r15,%rax,1),%ecx
  mov    %cl,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%r13
  jne    L345
  lea    (%r10,%r10,1),%rdx
  cmp    %rdx,%r8
  jae    L481
L409:
  mov    %r10,%r15
  mov    %r12,%rbp
  mov    %r14,%r12
  mov    %r9,%r14
  shr    %r15
  mov    %r15,%rbx
  imul   %r13,%rbx
  add    %r12,%rbx
  cmp    $0x1,%r10
  je     L255
  mov    %rbp,%rax
  mov    %r12,%rbp
  mov    %r15,%r12
  mov    %rax,%r15
  nopl   0x0(%rax)
L528:
  mov    0x40(%rsp),%rdi
  mov    0x8(%rsp),%rax
  mov    %rbx,%rsi
  call   *%rax
  test   %eax,%eax
  js     L196
  lea    0x1(%rbx),%rdx
  mov    %r14,%rax
  sub    %rdx,%rax
  cmp    $0xe,%rax
  jbe    L94
  cmpb   $0x0,0x18(%rsp)
  je     L94
  cmpq   $0xe,0x10(%rsp)
  jbe    L72
  mov    0x60(%rsp),%rcx
  xor    %eax,%eax
  nopl   0x0(%rax)
L231:
  movdqu (%rbx,%rax,1),%xmm2
  movups %xmm2,(%r14,%rax,1)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L231
  lea    (%r14,%r15,1),%rax
  lea    (%rbx,%r15,1),%rdx
  cmp    %r15,%r13
  je     L265
  cmpq   $0x6,0x30(%rsp)
  mov    0x28(%rsp),%rdi
  mov    0x20(%rsp),%rsi
  jbe    L56
  mov    %r15,%r11
L487:
  mov    (%rbx,%r11,1),%rbx
  mov    %rbx,(%r14,%r11,1)
  mov    %rdi,%r11
  and    $0xfffffffffffffff8,%r11
  sub    %r11,%rsi
  add    %r11,%rax
  add    %r11,%rdx
  cmp    %r11,%rdi
  je     L265
L56:
  movzbl (%rdx),%edi
  mov    %dil,(%rax)
  cmp    $0x1,%rsi
  je     L265
  movzbl 0x1(%rdx),%edi
  mov    %dil,0x1(%rax)
  cmp    $0x2,%rsi
  je     L265
  movzbl 0x2(%rdx),%edi
  mov    %dil,0x2(%rax)
  cmp    $0x3,%rsi
  je     L265
  movzbl 0x3(%rdx),%edi
  mov    %dil,0x3(%rax)
  cmp    $0x4,%rsi
  je     L265
  movzbl 0x4(%rdx),%edi
  mov    %dil,0x4(%rax)
  cmp    $0x5,%rsi
  je     L265
  movzbl 0x5(%rdx),%edi
  mov    %dil,0x5(%rax)
  cmp    $0x6,%rsi
  je     L265
  movzbl 0x6(%rdx),%edx
  mov    %dl,0x6(%rax)
L265:
  mov    %r12,%rax
  mov    %r13,%r14
  mov    %r13,%rbx
  shr    %rax
  imul   %r12,%r14
  imul   %rax,%rbx
  add    %rbp,%r14
  add    %rbp,%rbx
  cmp    $0x1,%r12
  je     L196
  mov    %rax,%r12
  jmp    L528
  nop
L94:
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L75:
  movzbl (%rbx,%rax,1),%edx
  mov    %dl,(%r14,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%r13
  jne    L75
  jmp    L265
  nopl   0x0(%rax,%rax,1)
L196:
  mov    %rbp,%r12
  mov    %r15,%rbp
L255:
  mov    0x40(%rsp),%rsi
  mov    %r13,%rdx
  mov    %r14,%rdi
  call   <memcpy@plt>
  mov    0x70(%rsp),%rax
  sub    %r13,0x78(%rsp)
  sub    $0x1,%rax
  mov    %rax,0x70(%rsp)
  jmp    L502
L72:
  mov    %r13,%rsi
  mov    %r14,%rax
  mov    %rbx,%rdx
  xor    %r11d,%r11d
  mov    %r13,%rdi
  jmp    L487
L664:
  mov    %r12,%r11
  mov    %rbx,%rdx
  mov    %r12,%rdi
  xor    %esi,%esi
  jmp    L691
L773:
  mov    %r13,%r11
  xor    %ebx,%ebx
  mov    %r15,%rsi
  mov    %r13,%rdi
  jmp    L318
L523:
  mov    0x20(%rsp),%rdi
  jmp    L374
L37:
  mov    0x38(%rsp),%rsi
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L422:
  movzbl (%rsi,%rax,1),%edx
  mov    %dl,(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%r13
  jne    L422
  mov    0x70(%rsp),%r8
  cmp    $0x1,%r8
  jne    L122
L660:
  mov    0x40(%rsp),%rbx
  mov    0x38(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  mov    %rbx,%rdi
  call   <free@plt>
  xor    %eax,%eax
L836:
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L455:
  mov    0x38(%rsp),%rcx
  mov    0x78(%rsp),%rdx
  mov    %r13,%rdi
  xor    %r10d,%r10d
  mov    %r13,%rsi
  mov    %rcx,%rax
  add    %rcx,%rdx
  jmp    L818
L754:
  mov    0x88(%rsp),%rax
  mov    0x20(%rsp),%rsi
  jmp    L613
L537:
  or     $0xffffffff,%eax
  jmp    L836
  nopl   (%rax)
L555:
  mov    D17(%rip),%rax
  mov    (%rax),%edx
  mov    D3(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L836
```

assistant: ```c
int heapsort(void *vbase, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) {
  size_t cnt, i, j, l;
  char tmp, *tmp1, *tmp2;
  char *base, *k, *p, *t;
  if (nmemb <= 1)
    return (0);
  if (!size) {
    errno = EINVAL;
    return (-1);
  }
  if ((k = malloc(size)) == NULL)
    return (-1);
  base = (char *)vbase - size;
  for (l = nmemb / 2 + 1; --l;) {
    for (i = l; (j = i * 2) <= nmemb; i = j) {
      p = base + j * size;
      if (j < nmemb && compar(p, p + size) < 0) {
        p += size;
        ++j;
      }
      t = base + i * size;
      if (compar(p, t) <= 0)
        break;
      {
        cnt = size;
        do {
          tmp = *t;
          *t++ = *p;
          *p++ = tmp;
        } while (--cnt);
      };
    }
  };
  while (nmemb > 1) {
    {
      cnt = size;
      tmp1 = k;
      tmp2 = base + nmemb * size;
      do {
        *tmp1++ = *tmp2++;
      } while (--cnt);
    };
    {
      cnt = size;
      tmp1 = base + nmemb * size;
      tmp2 = base + size;
      do {
        *tmp1++ = *tmp2++;
      } while (--cnt);
    };
    --nmemb;
    {
      for (i = 1; (j = i * 2) <= nmemb; i = j) {
        p = base + j * size;
        if (j < nmemb && compar(p, p + size) < 0) {
          p += size;
          ++j;
        }
        t = base + i * size;
        {
          cnt = size;
          tmp1 = t;
          tmp2 = p;
          do {
            *tmp1++ = *tmp2++;
          } while (--cnt);
        };
      }
      for (;;) {
        j = i;
        i = j / 2;
        p = base + j * size;
        t = base + i * size;
        if (j == 1 || compar(k, t) < 0) {
          {
            cnt = size;
            tmp1 = p;
            tmp2 = k;
            do {
              *tmp1++ = *tmp2++;
            } while (--cnt);
          };
          break;
        }
        {
          cnt = size;
          tmp1 = p;
          tmp2 = t;
          do {
            *tmp1++ = *tmp2++;
          } while (--cnt);
        };
      }
    };
  }
  free(k);
  return (0);
}
```