user: Converte this assembly snippet into its equivalent C code:

```asm
<LMSsort1>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r13
  mov    %rsi,%rbx
  mov    %rdx,0x18(%rsp)
  mov    %rcx,%r15
  mov    %r8d,0x24(%rsp)
  mov    %r9d,0x28(%rsp)
  cmp    %rcx,%rdx
  je     L15
L244:
  mov    $0x0,%ecx
  mov    0x28(%rsp),%edx
  mov    %r15,%rsi
  mov    0x18(%rsp),%rdi
  call   <getBuckets@plt>
  mov    0x24(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x2c(%rsp)
  cmpl   $0x4,0x70(%rsp)
  je     L230
  movslq 0x2c(%rsp),%rax
  movzbl 0x0(%r13,%rax,1),%eax
  movzbl %al,%esi
  mov    %esi,0x20(%rsp)
  movzbl %al,%eax
  movslq (%r15,%rax,4),%rax
  lea    (%rbx,%rax,4),%rdx
  mov    0x24(%rsp),%eax
  sub    $0x2,%eax
  movslq %eax,%rcx
  movzbl 0x0(%r13,%rcx,1),%esi
L55:
  mov    %eax,%ecx
  not    %ecx
  cmp    0x20(%rsp),%esi
  cmovl  %ecx,%eax
  lea    0x4(%rdx),%rsi
  mov    %rsi,0x8(%rsp)
  mov    %eax,(%rdx)
  mov    0x24(%rsp),%eax
  test   %eax,%eax
  jle    L97
  mov    %eax,%eax
  mov    %rax,0x10(%rsp)
  mov    $0x0,%r12d
  jmp    L217
L15:
  mov    0x70(%rsp),%r8d
  mov    %r9d,%ecx
  mov    0x24(%rsp),%edx
  mov    0x18(%rsp),%rsi
  call   <getCounts@plt>
  jmp    L244
L230:
  movslq %eax,%rcx
  mov    0x0(%r13,%rcx,4),%eax
  mov    %eax,0x20(%rsp)
  cltq
  movslq (%r15,%rax,4),%rax
  lea    (%rbx,%rax,4),%rdx
  mov    0x24(%rsp),%eax
  sub    $0x2,%eax
  mov    -0x4(%r13,%rcx,4),%esi
  jmp    L55
L2:
  movslq %ebp,%rax
  shl    $0x2,%rax
  lea    0x0(%r13,%rax,1),%r14
  mov    0x4(%r13,%rax,1),%eax
  cmp    %eax,(%r14)
  setge  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    (%r14),%r14d
  jmp    L235
L132:
  movslq %eax,%rdx
  mov    0x0(%r13,%rdx,4),%edx
L21:
  neg    %ebp
  cmp    %edx,%r14d
  cmovg  %ebp,%eax
  mov    0x8(%rsp),%rsi
  lea    0x4(%rsi),%rdx
  mov    %rdx,0x8(%rsp)
  mov    %eax,(%rsi)
  movl   $0x0,(%rbx,%r12,4)
  mov    %r14d,0x20(%rsp)
L185:
  add    $0x1,%r12
  cmp    %r12,0x10(%rsp)
  je     L97
L217:
  mov    (%rbx,%r12,4),%ebp
  test   %ebp,%ebp
  jle    L124
  cmpl   $0x4,0x70(%rsp)
  je     L2
  movslq %ebp,%rax
  lea    0x0(%r13,%rax,1),%r14
  movzbl 0x1(%r13,%rax,1),%eax
  cmp    %al,(%r14)
  setae  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzbl (%r14),%r14d
L235:
  mov    0x8(%rsp),%rax
  mov    0x20(%rsp),%ecx
  cmp    %ecx,%r14d
  je     L247
  movslq %ecx,%rdx
  sub    %rbx,%rax
  sar    $0x2,%rax
  mov    %eax,(%r15,%rdx,4)
  movslq %r14d,%rax
  movslq (%r15,%rax,4),%rax
  lea    (%rbx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
L247:
  mov    0x8(%rsp),%rax
  sub    %rbx,%rax
  sar    $0x2,%rax
  cmp    %r12,%rax
  setg   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  lea    -0x1(%rbp),%eax
  cmpl   $0x4,0x70(%rsp)
  je     L132
  movslq %eax,%rdx
  movzbl 0x0(%r13,%rdx,1),%edx
  jmp    L21
L124:
  jns    L185
  not    %ebp
  mov    %ebp,(%rbx,%r12,4)
  jmp    L185
L97:
  cmp    %r15,0x18(%rsp)
  je     L4
L1:
  mov    $0x1,%ecx
  mov    0x28(%rsp),%edx
  mov    %r15,%rsi
  mov    0x18(%rsp),%rdi
  call   <getBuckets@plt>
  movslq (%r15),%rax
  lea    (%rbx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  mov    0x2c(%rsp),%eax
  test   %eax,%eax
  js     L122
  movslq %eax,%r12
  movl   $0x0,0x20(%rsp)
  jmp    L175
L4:
  mov    0x70(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  mov    0x24(%rsp),%edx
  mov    0x18(%rsp),%rsi
  mov    %r13,%rdi
  call   <getCounts@plt>
  jmp    L1
L12:
  movslq %ebp,%rax
  lea    0x0(%r13,%rax,1),%r14
  movzbl 0x1(%r13,%rax,1),%eax
  cmp    %al,(%r14)
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzbl (%r14),%r14d
L209:
  mov    0x8(%rsp),%rax
  mov    0x20(%rsp),%ecx
  cmp    %ecx,%r14d
  je     L59
  movslq %ecx,%rdx
  sub    %rbx,%rax
  sar    $0x2,%rax
  mov    %eax,(%r15,%rdx,4)
  movslq %r14d,%rax
  movslq (%r15,%rax,4),%rax
  lea    (%rbx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
L59:
  mov    0x8(%rsp),%rax
  sub    %rbx,%rax
  sar    $0x2,%rax
  cmp    %r12,%rax
  setle  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  sub    $0x1,%ebp
  cmpl   $0x4,0x70(%rsp)
  je     L242
  movslq %ebp,%rax
  movzbl 0x0(%r13,%rax,1),%edx
L120:
  mov    $0xfffffffe,%eax
  sub    %ebp,%eax
  cmp    %edx,%r14d
  cmovl  %eax,%ebp
  mov    0x8(%rsp),%rax
  lea    -0x4(%rax),%rsi
  mov    %rsi,0x8(%rsp)
  mov    %ebp,-0x4(%rax)
  movl   $0x0,(%rbx,%r12,4)
  mov    %r14d,0x20(%rsp)
L147:
  sub    $0x1,%r12
  test   %r12d,%r12d
  js     L122
L175:
  mov    (%rbx,%r12,4),%ebp
  test   %ebp,%ebp
  jle    L147
  cmpl   $0x4,0x70(%rsp)
  jne    L12
  movslq %ebp,%rax
  shl    $0x2,%rax
  lea    0x0(%r13,%rax,1),%r14
  mov    0x4(%r13,%rax,1),%eax
  cmp    %eax,(%r14)
  setle  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    (%r14),%r14d
  jmp    L209
L242:
  movslq %ebp,%rax
  mov    0x0(%r13,%rax,4),%edx
  jmp    L120
L122:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void LMSsort1(const void *T, off_t *SA, off_t *C, off_t *B, off_t n, off_t k, int cs) {
  off_t *b, i, j;
  off_t c0, c1;
  if (C == B) {
    getCounts(T, C, n, k, cs);
  }
  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;
  *b++ = ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) < c1) ? ~j : j;
  for (i = 0; i < n; ++i) {
    if (0 < (j = SA[i])) {
      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;
      *b++ = ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) < c1) ? ~j : j;
      SA[i] = 0;
    } else if (j < 0) {
      SA[i] = ~j;
    }
  }
  if (C == B) {
    getCounts(T, C, n, k, cs);
  }
  getBuckets(C, B, k, 1);
  for (i = n - 1, b = SA + B[c1 = 0]; 0 <= i; --i) {
    if (0 < (j = SA[i])) {
      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;
      *--b = ((cs == sizeof(off_t) ? ((off_t *)T)[(j)] : ((unsigned char *)T)[(j)]) > c1) ? ~(j + 1) : j;
      SA[i] = 0;
    }
  }
}
```