user: Demonstrate the C code that generates the assembly output below:

```asm
<heap_sort>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x58,%rsp
  test   %rdx,%rdx
  sete   %al
  test   %rcx,%rcx
  sete   %dl
  or     %dl,%al
  jne    L110
  mov    %rsi,%rbx
  cmp    $0x1,%rsi
  jbe    L110
  cmp    %rbp,%rsi
  mov    %rbp,%rax
  mov    %rcx,%r12
  mov    %r8,%rcx
  cmovbe %rsi,%rax
  mov    %r12,%rdx
  mov    %ebp,0x8(%rsp)
  mov    %rdi,%r15
  mov    %r8,%r14
  mov    %rax,0x48(%rsp)
  call   <heap_heapify@plt>
  test   %ebp,%ebp
  je     L113
  lea    -0x1(%rbx),%rax
  mov    %r12,%r13
  lea    -0x1(%r12),%rsi
  mov    %r12,%r8
  imul   %r12,%rax
  and    $0xfffffffffffffff0,%r13
  mov    %rsi,0x28(%rsp)
  mov    %r15,%rbx
  mov    %r14,0x18(%rsp)
  mov    %r15,%r14
  lea    (%r15,%rax,1),%rbp
  mov    %rax,0x10(%rsp)
  add    $0x10,%rax
  mov    %r13,%r15
  lea    0x0(%rbp,%r13,1),%rdi
  mov    %rax,0x20(%rsp)
  mov    %rdi,0x40(%rsp)
  mov    %r12,%rdi
  mov    0x8(%rsp),%r12d
  sub    %r13,%rdi
  lea    -0x1(%rdi),%rax
  mov    %rdi,0x30(%rsp)
  mov    %rax,0x38(%rsp)
  nopl   0x0(%rax)
L191:
  mov    0x20(%rsp),%rax
  lea    0x10(%rbx),%rdx
  add    %r14,%rax
  cmp    %rax,%rbx
  setae  %al
  cmp    %rdx,%rbp
  setae  %dl
  or     %dl,%al
  je     L20
  mov    0x28(%rsp),%rax
  cmp    $0x6,%rax
  jbe    L20
  cmp    $0xe,%rax
  jbe    L200
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L128:
  movdqu (%rbx,%rax,1),%xmm0
  movdqu 0x0(%rbp,%rax,1),%xmm2
  movups %xmm2,(%rbx,%rax,1)
  movups %xmm0,0x0(%rbp,%rax,1)
  add    $0x10,%rax
  cmp    %r15,%rax
  jne    L128
  lea    (%rbx,%r13,1),%rax
  cmp    %r13,%r8
  je     L179
  mov    0x30(%rsp),%rsi
  cmpq   $0x6,0x38(%rsp)
  mov    %rsi,%r11
  jbe    L122
  mov    0x40(%rsp),%rcx
  mov    %r13,%rdx
L53:
  lea    (%rbx,%rdx,1),%rdi
  add    0x10(%rsp),%rdx
  add    %r14,%rdx
  movq   (%rdi),%xmm0
  movq   (%rdx),%xmm1
  movq   %xmm1,(%rdi)
  movq   %xmm0,(%rdx)
  mov    %r11,%rdx
  and    $0xfffffffffffffff8,%rdx
  add    %rdx,%rax
  add    %rdx,%rcx
  sub    %rdx,%rsi
  cmp    %rdx,%r11
  je     L121
L195:
  movzbl (%rax),%edx
  movzbl (%rcx),%edi
  mov    %dil,(%rax)
  mov    %dl,(%rcx)
  cmp    $0x1,%rsi
  je     L121
  movzbl 0x1(%rax),%edx
  movzbl 0x1(%rcx),%edi
  mov    %dil,0x1(%rax)
  mov    %dl,0x1(%rcx)
  cmp    $0x2,%rsi
  je     L121
  movzbl 0x2(%rax),%edx
  movzbl 0x2(%rcx),%edi
  mov    %dil,0x2(%rax)
  mov    %dl,0x2(%rcx)
  cmp    $0x3,%rsi
  je     L121
  movzbl 0x3(%rax),%edx
  movzbl 0x3(%rcx),%edi
  mov    %dil,0x3(%rax)
  mov    %dl,0x3(%rcx)
  cmp    $0x4,%rsi
  je     L121
  movzbl 0x4(%rax),%edx
  movzbl 0x4(%rcx),%edi
  mov    %dil,0x4(%rax)
  mov    %dl,0x4(%rcx)
  cmp    $0x5,%rsi
  je     L121
  movzbl 0x5(%rax),%edx
  movzbl 0x5(%rcx),%edi
  mov    %dil,0x5(%rax)
  mov    %dl,0x5(%rcx)
  cmp    $0x6,%rsi
  je     L121
  movzbl 0x6(%rax),%edx
  movzbl 0x6(%rcx),%esi
  mov    %sil,0x6(%rax)
  mov    %dl,0x6(%rcx)
L121:
  lea    (%rbx,%r8,1),%rax
L179:
  mov    0x18(%rsp),%rcx
  mov    %r8,%rdx
  sub    $0x1,%r12d
  mov    %rax,%rsi
  mov    %rbp,%rdi
  mov    %r8,0x8(%rsp)
  mov    %rax,%rbx
  call   <siftup@plt>
  test   %r12d,%r12d
  mov    0x8(%rsp),%r8
  jne    L191
  mov    %r14,%r15
  mov    0x18(%rsp),%r14
  mov    %r8,%r12
L113:
  mov    0x48(%rsp),%rsi
  mov    %r15,%rdi
  mov    %r14,%rcx
  mov    %r12,%rdx
  call   <heap_issorted@plt>
  add    $0x58,%rsp
  pop    %rbx
  mov    %eax,%edi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <assert@plt>
L110:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L20:
  mov    %rbp,%rdx
  lea    (%rbx,%r8,1),%rax
  nopw   0x0(%rax,%rax,1)
L177:
  movzbl (%rdx),%esi
  movzbl (%rbx),%ecx
  add    $0x1,%rbx
  add    $0x1,%rdx
  mov    %sil,-0x1(%rbx)
  mov    %cl,-0x1(%rdx)
  cmp    %rax,%rbx
  jne    L177
  jmp    L179
L200:
  mov    %r8,%r11
  mov    %r8,%rsi
  mov    %rbp,%rcx
  mov    %rbx,%rax
  xor    %edx,%edx
  jmp    L53
L122:
  mov    0x40(%rsp),%rcx
  jmp    L195
```

assistant: ```c
void heap_sort(void *base, size_t nmemb, size_t sort, size_t size, int (*cmp)(const void *, const void *)) {
  unsigned char *head = (unsigned char *)base, *end = head + nmemb * size, *last = end - size;
  unsigned int tosort = sort;
  if (!sort || !size || (nmemb < 2)) {
    return;
  }
  if (sort > nmemb) {
    sort = nmemb;
  }
  heap_heapify(base, nmemb, size, cmp);
  while (tosort) {
    do {
      unsigned char SWAP_tmp, *SWAP_tone = (unsigned char *)head, *SWAP_ttwo = (unsigned char *)last;
      size_t SWAP_size = size;
      do {
        SWAP_tmp = *SWAP_tone;
        *SWAP_tone = *SWAP_ttwo;
        *SWAP_ttwo = SWAP_tmp;
        ++SWAP_tone;
        ++SWAP_ttwo;
      } while (--SWAP_size);
    } while (0);
    head += size;
    tosort--;
    siftup(last, head, size, cmp, size);
  }
  assert(heap_issorted(base, sort, size, cmp));
  return;
}
```