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

```asm
<tcbwtsortstrheap>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r13d
  mov    %edx,%ebx
  mov    %ecx,%r12d
  mov    %esi,%edi
  or     %edx,%edi
  not    %edi
  shr    $0x1f,%edi
  test   %rbp,%rbp
  setne  %al
  and    %eax,%edi
  call   <assert@plt>
  lea    -0x1(%r13),%r11d
  mov    %r11d,%r14d
  sar    %r14d
  lea    0x1(%r14),%r9d
  test   %r9d,%r9d
  jle    L290
  add    %r14d,%r14d
  jmp    L309
L287:
  movslq %edx,%rax
  add    $0x1,%rax
  mov    0x0(%rbp,%rax,8),%r15
  lea    -0x8(%rbp,%rax,8),%r8
  mov    (%r8),%rcx
  cmp    %r12d,%ebx
  jle    L75
  movslq %r12d,%rax
L18:
  movzbl (%r15,%rax,1),%r10d
  movzbl (%rcx,%rax,1),%esi
  cmp    %sil,%r10b
  jne    L344
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L18
  jmp    L191
L344:
  movzbl %r10b,%r10d
  movzbl %sil,%esi
  cmp    %esi,%r10d
  jle    L106
  add    $0x1,%edx
L191:
  movslq %edi,%rdi
  lea    0x0(%rbp,%rdi,8),%r10
  mov    (%r10),%rsi
  movslq %edx,%rax
  lea    0x0(%rbp,%rax,8),%r8
  mov    (%r8),%rcx
  mov    %edx,%edi
  jmp    L89
L120:
  movzbl %r15b,%r15d
  movzbl %dl,%edx
  cmp    %edx,%r15d
  jge    L75
  mov    %rcx,(%r10)
  mov    %rsi,(%r8)
  lea    (%rdi,%rdi,1),%edx
  cmp    %edx,%r11d
  jl     L75
L150:
  cmp    %edx,%r11d
  jg     L287
  movslq %edi,%rdi
  lea    0x0(%rbp,%rdi,8),%r10
  mov    (%r10),%rsi
  movslq %edx,%rax
  lea    0x0(%rbp,%rax,8),%r8
  mov    (%r8),%rcx
  cmp    %r12d,%ebx
  jle    L75
  mov    %edx,%edi
L89:
  movslq %r12d,%rax
L233:
  movzbl (%rsi,%rax,1),%r15d
  movzbl (%rcx,%rax,1),%edx
  cmp    %dl,%r15b
  jne    L120
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L233
L75:
  sub    $0x2,%r14d
  test   %r9d,%r9d
  je     L290
L309:
  sub    $0x1,%r9d
  mov    %r14d,%edx
  cmp    %r14d,%r11d
  jl     L75
  mov    %r9d,%edi
  jmp    L150
L290:
  test   %r11d,%r11d
  jle    L179
  lea    (%r9,%r9,1),%r14d
  lea    -0x2(%r13),%eax
  movslq %eax,%r12
  movslq %r13d,%r13
  sub    $0x3,%r13
  mov    %eax,%eax
  sub    %rax,%r13
  mov    %r9d,0xc(%rsp)
  mov    %ebx,%r10d
  jmp    L304
L162:
  movslq %edx,%rax
  add    $0x1,%rax
  mov    0x0(%rbp,%rax,8),%r15
  lea    -0x8(%rbp,%rax,8),%rdi
  mov    (%rdi),%rcx
  test   %ebx,%ebx
  jle    L55
  mov    $0x0,%eax
L56:
  movzbl (%r15,%rax,1),%r9d
  movzbl (%rcx,%rax,1),%esi
  cmp    %sil,%r9b
  jne    L236
  add    $0x1,%rax
  cmp    %r10,%rax
  jne    L56
  jmp    L330
L236:
  movzbl %r9b,%r9d
  movzbl %sil,%esi
  cmp    %esi,%r9d
  jle    L140
  add    $0x1,%edx
L330:
  movslq %r8d,%r8
  lea    0x0(%rbp,%r8,8),%r9
  mov    (%r9),%rsi
  movslq %edx,%rax
  lea    0x0(%rbp,%rax,8),%rdi
  mov    (%rdi),%rcx
  mov    %edx,%r8d
  jmp    L15
L16:
  movzbl %r15b,%r15d
  movzbl %dl,%edx
  cmp    %edx,%r15d
  jge    L55
  mov    %rcx,(%r9)
  mov    %rsi,(%rdi)
  lea    (%r8,%r8,1),%edx
  cmp    %r11d,%edx
  jg     L55
L61:
  cmp    %r11d,%edx
  jl     L162
  movslq %r8d,%r8
  lea    0x0(%rbp,%r8,8),%r9
  mov    (%r9),%rsi
  movslq %edx,%rax
  lea    0x0(%rbp,%rax,8),%rdi
  mov    (%rdi),%rcx
  test   %ebx,%ebx
  jle    L55
  mov    %edx,%r8d
L15:
  mov    $0x0,%eax
L67:
  movzbl (%rsi,%rax,1),%r15d
  movzbl (%rcx,%rax,1),%edx
  cmp    %dl,%r15b
  jne    L16
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L67
L55:
  sub    $0x1,%r12
  cmp    %r13,%r12
  je     L179
L304:
  mov    0x0(%rbp),%rax
  mov    0x8(%rbp,%r12,8),%rdx
  mov    %rdx,0x0(%rbp)
  mov    %rax,0x8(%rbp,%r12,8)
  mov    %r12d,%r11d
  cmp    %r12d,%r14d
  jg     L55
  mov    %r14d,%edx
  mov    0xc(%rsp),%r8d
  jmp    L61
L140:
  movslq %r8d,%r8
  lea    0x0(%rbp,%r8,8),%r9
  mov    (%r9),%rsi
  mov    %edx,%r8d
  jmp    L15
L106:
  movslq %edi,%rdi
  lea    0x0(%rbp,%rdi,8),%r10
  mov    (%r10),%rsi
  mov    %edx,%edi
  jmp    L89
L179:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void tcbwtsortstrheap(const char **arrays, int anum, int len, int skip) {
  assert(arrays && anum >= 0 && len >= 0);
  anum--;
  int bottom = (anum >> 1) + 1;
  int top = anum;
  while (bottom > 0) {
    bottom--;
    int mybot = bottom;
    int i = mybot * 2;
    while (i <= top) {
      if (i < top) {
        int cmp = 0;
        const unsigned char *ap = (unsigned char *)arrays[i + 1];
        const unsigned char *bp = (unsigned char *)arrays[i];
        for (int j = skip; j < len; j++) {
          if (ap[j] != bp[j]) {
            cmp = ap[j] - bp[j];
            break;
          }
        }
        if (cmp > 0)
          i++;
      }
      int cmp = 0;
      const unsigned char *ap = (unsigned char *)arrays[mybot];
      const unsigned char *bp = (unsigned char *)arrays[i];
      for (int j = skip; j < len; j++) {
        if (ap[j] != bp[j]) {
          cmp = ap[j] - bp[j];
          break;
        }
      }
      if (cmp >= 0)
        break;
      const char *swap = arrays[mybot];
      arrays[mybot] = arrays[i];
      arrays[i] = swap;
      mybot = i;
      i = mybot * 2;
    }
  }
  while (top > 0) {
    const char *swap = arrays[0];
    arrays[0] = arrays[top];
    arrays[top] = swap;
    top--;
    int mybot = bottom;
    int i = mybot * 2;
    while (i <= top) {
      if (i < top) {
        int cmp = 0;
        const unsigned char *ap = (unsigned char *)arrays[i + 1];
        const unsigned char *bp = (unsigned char *)arrays[i];
        for (int j = 0; j < len; j++) {
          if (ap[j] != bp[j]) {
            cmp = ap[j] - bp[j];
            break;
          }
        }
        if (cmp > 0)
          i++;
      }
      int cmp = 0;
      const unsigned char *ap = (unsigned char *)arrays[mybot];
      const unsigned char *bp = (unsigned char *)arrays[i];
      for (int j = 0; j < len; j++) {
        if (ap[j] != bp[j]) {
          cmp = ap[j] - bp[j];
          break;
        }
      }
      if (cmp >= 0)
        break;
      swap = arrays[mybot];
      arrays[mybot] = arrays[i];
      arrays[i] = swap;
      mybot = i;
      i = mybot * 2;
    }
  }
}
```