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

```asm
<LMSsort2>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdi,%r14
  xor    %edi,%edi
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %r9d,%ebp
  push   %rbx
  sub    $0x58,%rsp
  cmp    %rcx,%rdx
  mov    0x98(%rsp),%ebx
  setne  %dil
  mov    %rdx,0x38(%rsp)
  mov    0x90(%rsp),%r13d
  mov    %rcx,0x18(%rsp)
  mov    %ebx,0x20(%rsp)
  mov    %rdx,%rbx
  mov    %r8,(%rsp)
  mov    %r13d,0x40(%rsp)
  call   <assert@plt>
  xor    %ecx,%ecx
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <getBuckets@plt>
  lea    -0x1(%rbp),%edx
  cmpl   $0x4,0x20(%rsp)
  movslq %edx,%rax
  mov    %rax,0x30(%rsp)
  mov    %rax,%r12
  lea    -0x2(%rbp),%eax
  je     L75
  mov    0x30(%rsp),%rbx
  movslq %eax,%rsi
  movzbl (%r14,%rsi,1),%edi
  movzbl (%r14,%rbx,1),%r9d
  mov    0x18(%rsp),%rbx
  movslq (%rbx,%r9,4),%rcx
  lea    (%r15,%rcx,4),%rcx
L256:
  add    %ebp,%eax
  cmp    %r9d,%edi
  lea    0x4(%rcx),%r11
  mov    %eax,%esi
  not    %esi
  cmovl  %esi,%eax
  mov    %eax,(%rcx)
  test   %ebp,%ebp
  jle    L96
  movslq %ebp,%rax
  mov    %r12,0x48(%rsp)
  xor    %r13d,%r13d
  mov    %r15,%r12
  mov    %rax,0x28(%rsp)
  mov    %r9d,%r15d
  movl   $0x0,0x24(%rsp)
  mov    %edx,0x44(%rsp)
  mov    %r11,0x8(%rsp)
  jmp    L31
  cs nopw 0x0(%rax,%rax,1)
L98:
  cmp    %ebx,%ebp
  jg     L197
  addl   $0x1,0x24(%rsp)
  sub    %ebp,%ebx
L197:
  lea    0x1(%rbx),%eax
  cmpl   $0x4,0x20(%rsp)
  movslq %ebx,%rsi
  cltq
  je     L235
  add    %r14,%rsi
  movzbl (%r14,%rax,1),%eax
  cmp    %al,(%rsi)
  mov    %rsi,0x10(%rsp)
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%rsi
  movzbl (%rsi),%r10d
L12:
  mov    0x8(%rsp),%rsi
  cmp    %r10d,%r15d
  je     L319
  mov    0x18(%rsp),%rcx
  sub    %r12,%rsi
  movslq %r15d,%r9
  movslq %r10d,%rax
  sar    $0x2,%rsi
  mov    %esi,(%rcx,%r9,4)
  movslq (%rcx,%rax,4),%rax
  lea    (%r12,%rax,4),%rsi
L319:
  mov    %rsi,%rax
  xor    %edi,%edi
  mov    %r10d,0x10(%rsp)
  sub    %r12,%rax
  mov    %rsi,0x8(%rsp)
  sar    $0x2,%rax
  cmp    %r13,%rax
  setg   %dil
  call   <assert@plt>
  mov    0x10(%rsp),%r10d
  lea    -0x1(%rbx),%edx
  cmpl   $0x4,0x20(%rsp)
  mov    0x8(%rsp),%rsi
  movslq %edx,%rax
  lea    (%r10,%r10,1),%edi
  je     L318
  movzbl (%r14,%rax,1),%eax
L209:
  cmp    %eax,%r10d
  mov    (%rsp),%rbx
  setg   %al
  movzbl %al,%eax
  or     %edi,%eax
  movslq %eax,%rdi
  lea    (%rbx,%rdi,4),%rdi
  mov    0x24(%rsp),%ebx
  cmp    %ebx,(%rdi)
  je     L155
  mov    %ebx,(%rdi)
  add    %ebp,%edx
L155:
  mov    %edx,%edi
  test   $0x1,%al
  lea    0x4(%rsi),%rax
  mov    %r10d,%r15d
  not    %edi
  mov    %rax,0x8(%rsp)
  cmovne %edi,%edx
  mov    %edx,(%rsi)
  movl   $0x0,(%r12,%r13,4)
L41:
  add    $0x1,%r13
  cmp    %r13,0x28(%rsp)
  je     L0
L31:
  mov    (%r12,%r13,4),%ebx
  test   %ebx,%ebx
  jg     L98
  je     L41
  not    %ebx
  mov    %ebx,(%r12,%r13,4)
  add    $0x1,%r13
  cmp    %r13,0x28(%rsp)
  jne    L31
L0:
  mov    %r12,%r15
  mov    0x44(%rsp),%edx
  mov    0x48(%rsp),%r12
L201:
  test   %edx,%edx
  js     L191
  mov    0x30(%rsp),%rax
  jmp    L265
  nopw   0x0(%rax,%rax,1)
L236:
  sub    $0x1,%edx
  js     L145
L10:
  movslq %edx,%rax
L265:
  shl    $0x2,%rax
  lea    (%r15,%rax,1),%rsi
  mov    (%rsi),%ecx
  test   %ecx,%ecx
  jle    L236
  cmp    %ebp,%ecx
  jge    L236
  add    %ebp,%ecx
  sub    $0x1,%edx
  mov    %ecx,(%rsi)
  lea    -0x4(%r15,%rax,1),%rsi
  movslq %edx,%rdi
  mov    (%rsi),%ecx
  cmp    %ecx,%ebp
  jle    L229
  lea    -0x4(%r15,%rdi,4),%rax
  nopl   0x0(%rax)
L172:
  mov    %rax,%rsi
  mov    (%rax),%ecx
  sub    $0x4,%rax
  sub    $0x1,%edx
  cmp    %ebp,%ecx
  jl     L172
L229:
  sub    %ebp,%ecx
  mov    %ecx,(%rsi)
  sub    $0x1,%edx
  jns    L10
  nopl   0x0(%rax)
L145:
  mov    0x18(%rsp),%r13
  mov    0x40(%rsp),%edx
  mov    $0x1,%ecx
  mov    0x38(%rsp),%rdi
  mov    %r13,%rsi
  call   <getBuckets@plt>
  movslq 0x0(%r13),%rax
  mov    0x24(%rsp),%ebx
  xor    %edx,%edx
  mov    %r12,%r13
  mov    %ebp,0x24(%rsp)
  mov    %r15,%r12
  lea    (%r15,%rax,4),%r9
  add    $0x1,%ebx
  mov    %edx,%r15d
  mov    %r9,0x8(%rsp)
  jmp    L247
  nopl   0x0(%rax,%rax,1)
L162:
  movzbl (%r14,%rax,1),%eax
L215:
  cmp    %eax,%r10d
  mov    (%rsp),%rdi
  setl   %al
  movzbl %al,%eax
  or     %edx,%eax
  movslq %eax,%rdx
  lea    (%rdi,%rdx,4),%rdx
  cmp    %ebx,(%rdx)
  je     L132
  mov    %ebx,(%rdx)
  add    0x24(%rsp),%ecx
L132:
  mov    $0xfffffffe,%edx
  mov    %r10d,%r15d
  sub    %ecx,%edx
  test   $0x1,%al
  lea    -0x4(%r8),%rax
  cmovne %edx,%ecx
  mov    %rax,0x8(%rsp)
  mov    %ecx,-0x4(%r8)
  movl   $0x0,(%r12,%r13,4)
L129:
  sub    $0x1,%r13
  test   %r13d,%r13d
  js     L333
L247:
  mov    (%r12,%r13,4),%ebp
  test   %ebp,%ebp
  jle    L129
  mov    0x24(%rsp),%eax
  cmp    %ebp,%eax
  jg     L44
  add    $0x1,%ebx
  sub    %eax,%ebp
L44:
  cmpl   $0x4,0x20(%rsp)
  movslq %ebp,%rax
  je     L176
  lea    (%r14,%rax,1),%r8
  movzbl 0x1(%r14,%rax,1),%eax
  cmp    %al,(%r8)
  mov    %r8,0x10(%rsp)
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%r8
  movzbl (%r8),%r10d
L148:
  mov    0x8(%rsp),%r8
  cmp    %r10d,%r15d
  je     L233
  mov    0x18(%rsp),%rsi
  sub    %r12,%r8
  movslq %r15d,%rdx
  movslq %r10d,%rax
  sar    $0x2,%r8
  mov    %r8d,(%rsi,%rdx,4)
  movslq (%rsi,%rax,4),%rax
  lea    (%r12,%rax,4),%r8
L233:
  mov    %r8,%rax
  xor    %edi,%edi
  mov    %r10d,0x10(%rsp)
  sub    %r12,%rax
  mov    %r8,0x8(%rsp)
  sar    $0x2,%rax
  cmp    %r13,%rax
  setle  %dil
  call   <assert@plt>
  mov    0x10(%rsp),%r10d
  lea    -0x1(%rbp),%ecx
  cmpl   $0x4,0x20(%rsp)
  mov    0x8(%rsp),%r8
  movslq %ecx,%rax
  lea    (%r10,%r10,1),%edx
  jne    L162
  mov    (%r14,%rax,4),%eax
  jmp    L215
  nopl   0x0(%rax,%rax,1)
L318:
  mov    (%r14,%rax,4),%eax
  jmp    L209
  nopl   0x0(%rax)
L235:
  shl    $0x2,%rsi
  lea    (%r14,%rsi,1),%r10
  mov    0x4(%r14,%rsi,1),%eax
  cmp    %eax,(%r10)
  mov    %r10,0x10(%rsp)
  setge  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%r10
  mov    (%r10),%r10d
  jmp    L12
  nopw   0x0(%rax,%rax,1)
L176:
  shl    $0x2,%rax
  lea    (%r14,%rax,1),%r8
  mov    0x4(%r14,%rax,1),%eax
  cmp    %eax,(%r8)
  mov    %r8,0x10(%rsp)
  setle  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    0x10(%rsp),%r8
  mov    (%r8),%r10d
  jmp    L148
  nop
L333:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L75:
  movslq (%r14,%r12,4),%rcx
  mov    0x18(%rsp),%rdi
  mov    %rcx,%r9
  movslq (%rdi,%rcx,4),%rcx
  mov    -0x4(%r14,%r12,4),%edi
  lea    (%r15,%rcx,4),%rcx
  jmp    L256
L191:
  mov    0x40(%rsp),%edx
  mov    0x18(%rsp),%rsi
  mov    $0x1,%ecx
  mov    0x38(%rsp),%rdi
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <getBuckets@plt>
L96:
  movl   $0x0,0x24(%rsp)
  jmp    L201
```

assistant: ```c
void LMSsort2(const void *T, off_t *SA, off_t *C, off_t *B, off_t *D, off_t n, off_t k, int cs) {
  off_t *b, i, j, t, d;
  off_t c0, c1;
  assert(C != B);
  getBuckets(C, B, k, 0);
  j = n - 1;
  b = SA + B[c1 = (cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)])];
  --j;
  t = ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) < c1);
  j += n;
  *b++ = (t & 1) ? ~j : j;
  for (i = 0, d = 0; i < n; ++i) {
    if (0 < (j = SA[i])) {
      if (n <= j) {
        d += 1;
        j -= n;
      }
      assert((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) >= (cs == sizeof(off_t) ? ((off_t *)T)[(j + 1)] : ((unsigned char *)T)[(j + 1)]));
      if ((c0 = (cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)])) != c1) {
        B[c1] = b - SA;
        b = SA + B[c1 = c0];
      }
      assert(i < (b - SA));
      --j;
      t = c0;
      t = (t << 1) | ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) < c1);
      if (D[t] != d) {
        j += n;
        D[t] = d;
      }
      *b++ = (t & 1) ? ~j : j;
      SA[i] = 0;
    } else if (j < 0) {
      SA[i] = ~j;
    }
  }
  for (i = n - 1; 0 <= i; --i) {
    if (0 < SA[i]) {
      if (SA[i] < n) {
        SA[i] += n;
        for (j = i - 1; SA[j] < n; --j) {
        }
        SA[j] -= n;
        i = j;
      }
    }
  }
  getBuckets(C, B, k, 1);
  for (i = n - 1, d += 1, b = SA + B[c1 = 0]; 0 <= i; --i) {
    if (0 < (j = SA[i])) {
      if (n <= j) {
        d += 1;
        j -= n;
      }
      assert((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) <= (cs == sizeof(off_t) ? ((off_t *)T)[(j + 1)] : ((unsigned char *)T)[(j + 1)]));
      if ((c0 = (cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)])) != c1) {
        B[c1] = b - SA;
        b = SA + B[c1 = c0];
      }
      assert((b - SA) <= i);
      --j;
      t = c0;
      t = (t << 1) | ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) > c1);
      if (D[t] != d) {
        j += n;
        D[t] = d;
      }
      *--b = (t & 1) ? ~(j + 1) : j;
      SA[i] = 0;
    }
  }
}
```