user: What would the C source look like for the assembly code provided here:

```asm
<filesort_heapsort>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    $0x2,%r13d
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  lea    -0x8(%rdi),%rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,(%rsp)
  cmp    $0x1,%rsi
  jbe    L14
  xchg   %ax,%ax
L47:
  mov    0x10(%rsp),%rax
  mov    %r13d,%ebp
  mov    -0x8(%rax,%r13,8),%rdi
  nopl   (%rax)
L148:
  movslq %ebp,%rax
  sar    %ebp
  movslq %ebp,%rdx
  lea    (%rbx,%rax,8),%r14
  lea    (%rbx,%rdx,8),%r15
  mov    (%r15),%rsi
  call   *%r12
  test   %eax,%eax
  jle    L67
  mov    (%r14),%rdi
  mov    (%r15),%rax
  mov    %rax,(%r14)
  mov    %rdi,(%r15)
  cmp    $0x1,%ebp
  jne    L148
L67:
  add    $0x1,%r13
  cmp    %r13,(%rsp)
  jae    L47
L14:
  mov    (%rsp),%rax
  cmp    $0x1,%eax
  jle    L101
  mov    %eax,%r14d
  sub    $0x1,%r14d
  movslq %r14d,%rax
  mov    %rax,0x18(%rsp)
  nopl   0x0(%rax)
L54:
  mov    0x10(%rsp),%rcx
  mov    0x18(%rsp),%rsi
  mov    (%rcx),%rax
  mov    (%rcx,%rsi,8),%rdx
  mov    %esi,0xc(%rsp)
  mov    %rdx,(%rcx)
  mov    %rax,(%rcx,%rsi,8)
  cmp    $0x2,%esi
  jle    L111
  movl   $0x1,(%rsp)
  mov    $0x2,%r14d
  jmp    L46
  nopl   0x0(%rax)
L55:
  mov    (%r15),%rax
  mov    0x0(%rbp),%rcx
  lea    0x0(%r13,%r13,1),%r14d
  mov    %rcx,(%r15)
  mov    %rax,0x0(%rbp)
  cmp    0xc(%rsp),%r14d
  jge    L61
  mov    %r13d,(%rsp)
L46:
  lea    0x1(%r14),%r13d
  movslq %r13d,%rax
  shl    $0x3,%rax
  lea    (%rbx,%rax,1),%rbp
  lea    -0x8(%rbx,%rax,1),%r15
  mov    0x0(%rbp),%rsi
  mov    (%r15),%rdi
  call   *%r12
  test   %eax,%eax
  cmovle %rbp,%r15
  movslq (%rsp),%rbp
  cmovg  %r14d,%r13d
  lea    (%rbx,%rbp,8),%rbp
  mov    (%r15),%rsi
  mov    0x0(%rbp),%rdi
  call   *%r12
  test   %eax,%eax
  js     L55
L83:
  subq   $0x1,0x18(%rsp)
  jmp    L54
  nopw   0x0(%rax,%rax,1)
L61:
  jne    L83
  movslq %r14d,%rbp
  shl    $0x3,%rbp
L117:
  add    %rbx,%rbp
  mov    (%r15),%rdi
  mov    0x0(%rbp),%rsi
  call   *%r12
  test   %eax,%eax
  jns    L83
  mov    0x0(%rbp),%rax
  mov    (%r15),%rcx
  subq   $0x1,0x18(%rsp)
  mov    %rcx,0x0(%rbp)
  mov    %rax,(%r15)
  jmp    L54
L101:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L111:
  jne    L101
  mov    0x10(%rsp),%r15
  mov    $0x10,%ebp
  jmp    L117
```

assistant: ```c
void filesort_heapsort(void **datap, size_t nitems, int (*compare)(const void *, const void *)) {
  void **datap1 = &datap[-1];
  int i;
  for (i = 2; i <= nitems; i++) {
    int index = i;
    while (index > 1) {
      int newindex;
      void *temp;
      newindex = index / 2;
      if (compare(datap1[index], datap1[newindex]) <= 0)
        break;
      temp = datap1[index];
      datap1[index] = datap1[newindex];
      datap1[newindex] = temp;
      index = newindex;
    }
  }
  for (i = nitems; i > 1; i--) {
    int index = 1;
    void *temp;
    temp = datap1[index];
    datap1[index] = datap1[i];
    datap1[i] = temp;
    while ((2 * index) < (i - 1)) {
      int newindex;
      void *temp;
      newindex = 2 * index;
      if (compare(datap1[newindex], datap1[newindex + 1]) <= 0)
        newindex = newindex + 1;
      if (compare(datap1[index], datap1[newindex]) >= 0)
        break;
      temp = datap1[newindex];
      datap1[newindex] = datap1[index];
      datap1[index] = temp;
      index = newindex;
    }
    if ((2 * index) == (i - 1)) {
      int newindex;
      void *temp;
      newindex = 2 * index;
      if (compare(datap1[index], datap1[newindex]) >= 0)
        ;
      else {
        temp = datap1[newindex];
        datap1[newindex] = datap1[index];
        datap1[index] = temp;
      }
    }
  }
}
```