user: Please show me the C implementation that matches the assembly code listed below:

```asm
<heapSort>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x8(%rsp)
  lea    0x4(%rsp),%rbp
  mov    $0x3b,%edi
  mov    %esi,0x4(%rsp)
  mov    $0x2,%esi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <__CrestCall@plt>
  mov    %rbp,%rsi
  mov    $0x3a,%edi
  call   <__CrestStore@plt>
  lea    0x8(%rsp),%rdi
  call   <__CrestInt@plt>
  mov    %rbp,%rdi
  call   <__CrestInt@plt>
  movslq 0x4(%rsp),%rdx
  mov    %rbp,%rsi
  mov    $0x3c,%edi
  call   <__CrestLoad@plt>
  mov    0x4(%rsp),%esi
  mov    0x8(%rsp),%rdi
  call   <heapify@plt>
  mov    $0x3d,%edi
  call   <__CrestClearStack@plt>
  movslq 0x4(%rsp),%rdx
  mov    %rbp,%rsi
  mov    $0x40,%edi
  lea    0x10(%rsp),%rbp
  call   <__CrestLoad@plt>
  xor    %esi,%esi
  mov    $0x1,%edx
  mov    $0x3f,%edi
  call   <__CrestLoad@plt>
  mov    0x4(%rsp),%eax
  mov    $0x1,%esi
  mov    $0x3e,%edi
  lea    -0x1(%rax),%edx
  movslq %edx,%rdx
  call   <__CrestApply2@plt>
  mov    %rbp,%rsi
  mov    $0x41,%edi
  call   <__CrestStore@plt>
  mov    0x4(%rsp),%eax
  mov    %rbp,%rsi
  mov    $0x44,%edi
  lea    -0x1(%rax),%edx
  mov    %edx,0x10(%rsp)
  movslq %edx,%rdx
  call   <__CrestLoad@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x43,%edi
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%ecx
  xor    %edx,%edx
  mov    $0xe,%esi
  mov    $0x42,%edi
  test   %ecx,%ecx
  setg   %dl
  call   <__CrestApply2@plt>
  mov    0x10(%rsp),%esi
  test   %esi,%esi
  jle    L26
  mov    $0x1,%edx
  mov    $0x17,%esi
  mov    $0x45,%edi
  call   <__CrestBranch@plt>
  mov    0x8(%rsp),%rbx
  mov    $0x47,%edi
  lea    0x14(%rsp),%r13
  movslq (%rbx),%rdx
  mov    %rbx,%rsi
  call   <__CrestLoad@plt>
  mov    %r13,%rsi
  mov    $0x48,%edi
  call   <__CrestStore@plt>
  mov    (%rbx),%eax
  mov    0x8(%rsp),%rbx
  mov    $0x49,%edi
  mov    %eax,0x14(%rsp)
  movslq 0x10(%rsp),%rax
  lea    (%rbx,%rax,4),%r12
  movslq (%r12),%rdx
  mov    %r12,%rsi
  call   <__CrestLoad@plt>
  mov    %rbx,%rsi
  mov    $0x4a,%edi
  call   <__CrestStore@plt>
  mov    (%r12),%eax
  mov    %r13,%rsi
  mov    $0x4b,%edi
  mov    %eax,(%rbx)
  mov    0x8(%rsp),%rax
  movslq 0x10(%rsp),%rdx
  lea    (%rax,%rdx,4),%rbx
  movslq 0x14(%rsp),%rdx
  call   <__CrestLoad@plt>
  mov    %rbx,%rsi
  mov    $0x4c,%edi
  call   <__CrestStore@plt>
  mov    0x14(%rsp),%eax
  mov    %rbp,%rsi
  mov    $0x4d,%edi
  mov    %eax,(%rbx)
  movslq 0x10(%rsp),%rdx
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%esi
  mov    0x8(%rsp),%rdi
  call   <adjust@plt>
  mov    $0x4e,%edi
  call   <__CrestClearStack@plt>
  movslq 0x10(%rsp),%rdx
  mov    %rbp,%rsi
  mov    $0x51,%edi
  call   <__CrestLoad@plt>
  mov    $0x1,%edx
  xor    %esi,%esi
  mov    $0x50,%edi
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%eax
  mov    $0x1,%esi
  mov    $0x4f,%edi
  lea    -0x1(%rax),%edx
  movslq %edx,%rdx
  call   <__CrestApply2@plt>
  mov    %rbp,%rsi
  mov    $0x52,%edi
  call   <__CrestStore@plt>
  mov    0x10(%rsp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,0x10(%rsp)
L41:
  movslq %edx,%rdx
  mov    %rbp,%rsi
  mov    $0x55,%edi
  call   <__CrestLoad@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  mov    $0x54,%edi
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%eax
  xor    %edx,%edx
  mov    $0xe,%esi
  mov    $0x53,%edi
  test   %eax,%eax
  setg   %dl
  call   <__CrestApply2@plt>
  mov    0x10(%rsp),%edx
  test   %edx,%edx
  jle    L3
  mov    $0x1,%edx
  mov    $0x1a,%esi
  mov    $0x56,%edi
  call   <__CrestBranch@plt>
  mov    0x8(%rsp),%rbx
  mov    $0x58,%edi
  lea    0x14(%rsp),%r13
  movslq (%rbx),%rdx
  mov    %rbx,%rsi
  call   <__CrestLoad@plt>
  mov    %r13,%rsi
  mov    $0x59,%edi
  call   <__CrestStore@plt>
  mov    (%rbx),%eax
  mov    0x8(%rsp),%rbx
  mov    $0x5a,%edi
  mov    %eax,0x14(%rsp)
  movslq 0x10(%rsp),%rax
  lea    (%rbx,%rax,4),%r12
  movslq (%r12),%rdx
  mov    %r12,%rsi
  call   <__CrestLoad@plt>
  mov    %rbx,%rsi
  mov    $0x5b,%edi
  call   <__CrestStore@plt>
  mov    (%r12),%eax
  mov    %r13,%rsi
  mov    $0x5c,%edi
  mov    %eax,(%rbx)
  mov    0x8(%rsp),%rax
  movslq 0x10(%rsp),%rdx
  lea    (%rax,%rdx,4),%rbx
  movslq 0x14(%rsp),%rdx
  call   <__CrestLoad@plt>
  mov    %rbx,%rsi
  mov    $0x5d,%edi
  call   <__CrestStore@plt>
  mov    0x14(%rsp),%eax
  mov    %rbp,%rsi
  mov    $0x5e,%edi
  mov    %eax,(%rbx)
  movslq 0x10(%rsp),%rdx
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%esi
  mov    0x8(%rsp),%rdi
  call   <adjust@plt>
  mov    $0x5f,%edi
  call   <__CrestClearStack@plt>
  movslq 0x10(%rsp),%rdx
  mov    %rbp,%rsi
  mov    $0x62,%edi
  call   <__CrestLoad@plt>
  mov    $0x1,%edx
  xor    %esi,%esi
  mov    $0x61,%edi
  call   <__CrestLoad@plt>
  mov    0x10(%rsp),%eax
  mov    $0x1,%esi
  mov    $0x60,%edi
  lea    -0x1(%rax),%edx
  movslq %edx,%rdx
  call   <__CrestApply2@plt>
  mov    %rbp,%rsi
  mov    $0x63,%edi
  call   <__CrestStore@plt>
  subl   $0x1,0x10(%rsp)
L10:
  mov    $0x64,%edi
  call   <__CrestReturn@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L26:
  xor    %edx,%edx
  mov    $0x18,%esi
  mov    $0x46,%edi
  call   <__CrestBranch@plt>
  mov    0x10(%rsp),%edx
  jmp    L41
  nopw   0x0(%rax,%rax,1)
L3:
  xor    %edx,%edx
  mov    $0x1b,%esi
  mov    $0x57,%edi
  call   <__CrestBranch@plt>
  jmp    L10
L11:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void heapSort(int *a, int n) {
  int i;
  int t;
  int *mem_5;
  int *mem_6;
  int *mem_7;
  int *mem_8;
  int *mem_9;
  int *mem_10;
  int *mem_11;
  int *mem_12;
  {
    __CrestCall(59, 2);
    __CrestStore(58, (unsigned long)(&n));
    __CrestInt((int *)(&a));
    __CrestInt(&n);
    __CrestLoad(60, (unsigned long)(&n), (long long)n);
    heapify(a, n);
    __CrestClearStack(61);
    __CrestLoad(64, (unsigned long)(&n), (long long)n);
    __CrestLoad(63, (unsigned long)0, (long long)1);
    __CrestApply2(62, 1, (long long)(n - 1));
    __CrestStore(65, (unsigned long)(&i));
    i = n - 1;
    {{__CrestLoad(68, (unsigned long)(&i), (long long)i);
    __CrestLoad(67, (unsigned long)0, (long long)0);
    __CrestApply2(66, 14, (long long)(i > 0));
    if (i > 0) {
      __CrestBranch(69, 23, 1);
      mem_5 = a + 0;
      __CrestLoad(71, (unsigned long)mem_5, (long long)*mem_5);
      __CrestStore(72, (unsigned long)(&t));
      t = *mem_5;
      mem_6 = a + 0;
      mem_7 = a + i;
      __CrestLoad(73, (unsigned long)mem_7, (long long)*mem_7);
      __CrestStore(74, (unsigned long)mem_6);
      *mem_6 = *mem_7;
      mem_8 = a + i;
      __CrestLoad(75, (unsigned long)(&t), (long long)t);
      __CrestStore(76, (unsigned long)mem_8);
      *mem_8 = t;
      __CrestLoad(77, (unsigned long)(&i), (long long)i);
      adjust(a, i);
      __CrestClearStack(78);
      __CrestLoad(81, (unsigned long)(&i), (long long)i);
      __CrestLoad(80, (unsigned long)0, (long long)1);
      __CrestApply2(79, 1, (long long)(i - 1));
      __CrestStore(82, (unsigned long)(&i));
      i--;
    } else {
      __CrestBranch(70, 24, 0);
    }
  }
  {
    __CrestLoad(85, (unsigned long)(&i), (long long)i);
    __CrestLoad(84, (unsigned long)0, (long long)0);
    __CrestApply2(83, 14, (long long)(i > 0));
    if (i > 0) {
      __CrestBranch(86, 26, 1);
      mem_9 = a + 0;
      __CrestLoad(88, (unsigned long)mem_9, (long long)*mem_9);
      __CrestStore(89, (unsigned long)(&t));
      t = *mem_9;
      mem_10 = a + 0;
      mem_11 = a + i;
      __CrestLoad(90, (unsigned long)mem_11, (long long)*mem_11);
      __CrestStore(91, (unsigned long)mem_10);
      *mem_10 = *mem_11;
      mem_12 = a + i;
      __CrestLoad(92, (unsigned long)(&t), (long long)t);
      __CrestStore(93, (unsigned long)mem_12);
      *mem_12 = t;
      __CrestLoad(94, (unsigned long)(&i), (long long)i);
      adjust(a, i);
      __CrestClearStack(95);
      __CrestLoad(98, (unsigned long)(&i), (long long)i);
      __CrestLoad(97, (unsigned long)0, (long long)1);
      __CrestApply2(96, 1, (long long)(i - 1));
      __CrestStore(99, (unsigned long)(&i));
      i--;
    } else {
      __CrestBranch(87, 27, 0);
    }
  }
}
{
  __CrestReturn(100);
  return;
}
}
}
```