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

```asm
<sort_typeBstar>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8d,-0x64(%rbp)
  movl   $0x0,-0x38(%rbp)
  jmp    L153
L165:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x38(%rbp)
L153:
  cmpl   $0xff,-0x38(%rbp)
  jle    L165
  movl   $0x0,-0x38(%rbp)
  jmp    L334
L316:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x38(%rbp)
L334:
  cmpl   $0xffff,-0x38(%rbp)
  jle    L316
  mov    -0x64(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x64(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x64(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L199
L127:
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  subl   $0x1,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  js     L21
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jge    L127
L21:
  cmpl   $0x0,-0x38(%rbp)
  js     L199
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  subl   $0x1,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L186
L358:
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L186:
  cmpl   $0x0,-0x38(%rbp)
  js     L199
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L358
L199:
  cmpl   $0x0,-0x38(%rbp)
  jns    L127
  mov    -0x64(%rbp),%eax
  sub    -0x2c(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0x0,-0x38(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L302
L61:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x38(%rbp),%ecx
  mov    -0x34(%rbp),%edx
  add    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x24(%rbp)
  jmp    L130
L303:
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x34(%rbp)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x38(%rbp)
  addl   $0x1,-0x24(%rbp)
L130:
  cmpl   $0xff,-0x24(%rbp)
  jle    L303
  addl   $0x1,-0x28(%rbp)
L302:
  cmpl   $0xff,-0x28(%rbp)
  jle    L61
  cmpl   $0x0,-0x2c(%rbp)
  jle    L45
  mov    -0x64(%rbp),%eax
  cltq
  mov    -0x2c(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x38(%rbp)
  jmp    L251
L219:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  sub    $0x1,%edx
  mov    %edx,(%rax)
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
L251:
  cmpl   $0x0,-0x38(%rbp)
  jns    L219
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  sub    $0x1,%edx
  mov    %edx,(%rax)
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    -0x2c(%rbp),%edx
  sub    $0x1,%edx
  mov    %edx,(%rax)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x64(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0xfe,-0x28(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L324
L461:
  movl   $0xff,-0x24(%rbp)
  jmp    L258
L379:
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x34(%rbp),%eax
  sub    -0x38(%rbp),%eax
  cmp    $0x1,%eax
  jle    L7
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x2c(%rbp),%edx
  sub    $0x1,%edx
  cmp    %edx,%eax
  sete   %al
  movzbl %al,%edi
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%r9d
  mov    -0x8(%rbp),%r8
  mov    -0x18(%rbp),%rsi
  mov    -0x48(%rbp),%rax
  sub    $0x8,%rsp
  push   %rdi
  mov    -0x64(%rbp),%edi
  push   %rdi
  push   $0x2
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sssort@plt>
  add    $0x20,%rsp
L7:
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  subl   $0x1,-0x24(%rbp)
L258:
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L379
  subl   $0x1,-0x28(%rbp)
L324:
  cmpl   $0x0,-0x34(%rbp)
  jg     L461
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  jmp    L462
L318:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L376
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x34(%rbp)
L283:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  js     L139
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jns    L283
L139:
  mov    -0x38(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  sub    -0x34(%rbp),%eax
  mov    %eax,(%rdx)
  cmpl   $0x0,-0x38(%rbp)
  jle    L276
L376:
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x34(%rbp)
L290:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  not    %edx
  mov    %edx,(%rax)
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  js     L290
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
L462:
  cmpl   $0x0,-0x38(%rbp)
  jns    L318
  jmp    L44
L276:
  nop
L44:
  mov    -0x2c(%rbp),%edx
  mov    -0x50(%rbp),%rsi
  mov    -0x10(%rbp),%rax
  mov    $0x1,%ecx
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <trsort@plt>
  mov    -0x64(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x64(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L444
L483:
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L8
L168:
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L8:
  cmpl   $0x0,-0x38(%rbp)
  js     L310
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jge    L168
L310:
  cmpl   $0x0,-0x38(%rbp)
  js     L444
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L253
L477:
  subl   $0x1,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L253:
  cmpl   $0x0,-0x38(%rbp)
  js     L47
  mov    -0x38(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L477
L47:
  cmpl   $0x0,-0x20(%rbp)
  je     L448
  mov    -0x20(%rbp),%eax
  sub    -0x38(%rbp),%eax
  cmp    $0x1,%eax
  jg     L448
  mov    -0x20(%rbp),%eax
  not    %eax
  jmp    L292
L448:
  mov    -0x20(%rbp),%eax
L292:
  subl   $0x1,-0x34(%rbp)
  mov    -0x34(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x50(%rbp),%rdx
  add    %rcx,%rdx
  mov    %eax,(%rdx)
L444:
  cmpl   $0x0,-0x38(%rbp)
  jns    L483
  mov    -0x60(%rbp),%rax
  lea    0x3fffc(%rax),%rdx
  mov    -0x64(%rbp),%eax
  mov    %eax,(%rdx)
  movl   $0xfe,-0x28(%rbp)
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x30(%rbp)
  jmp    L410
L382:
  mov    -0x28(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  movl   $0xff,-0x24(%rbp)
  jmp    L244
L270:
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x38(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L202
L278:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    -0x38(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x50(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x38(%rbp)
  subl   $0x1,-0x30(%rbp)
L202:
  mov    -0x34(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jle    L278
  subl   $0x1,-0x24(%rbp)
L244:
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L270
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x38(%rbp),%eax
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  or     %ecx,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x60(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%eax
  shl    $0x8,%eax
  or     -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x28(%rbp)
L410:
  cmpl   $0x0,-0x28(%rbp)
  jns    L382
L45:
  mov    -0x2c(%rbp),%eax
  leave
  ret
```

assistant: ```c
int sort_typeBstar(const unsigned char *T, int *SA, int *bucket_A, int *bucket_B, int n) {
  int *PAb, *ISAb, *buf;
  int i, j, k, t, m, bufsize;
  int c0, c1;
  for (i = 0; i < ((256)); ++i) {
    bucket_A[i] = 0;
  }
  for (i = 0; i < ((256) * (256)); ++i) {
    bucket_B[i] = 0;
  }
  for (i = n - 1, m = n, c0 = T[n - 1]; 0 <= i;) {
    do {
      ++bucket_A[(c1 = c0)];
    } while ((0 <= --i) && ((c0 = T[i]) >= c1));
    if (0 <= i) {
      ++(bucket_B[((c0) << 8) | (c1)]);
      SA[--m] = i;
      for (--i, c1 = c0; (0 <= i) && ((c0 = T[i]) <= c1); --i, c1 = c0) {
        ++(bucket_B[((c1) << 8) | (c0)]);
      }
    }
  }
  m = n - m;
  for (c0 = 0, i = 0, j = 0; c0 < (256); ++c0) {
    t = i + bucket_A[(c0)];
    bucket_A[(c0)] = i + j;
    i = t + (bucket_B[((c0) << 8) | (c0)]);
    for (c1 = c0 + 1; c1 < (256); ++c1) {
      j += (bucket_B[((c0) << 8) | (c1)]);
      (bucket_B[((c0) << 8) | (c1)]) = j;
      i += (bucket_B[((c1) << 8) | (c0)]);
    }
  }
  if (0 < m) {
    PAb = SA + n - m;
    ISAb = SA + m;
    for (i = m - 2; 0 <= i; --i) {
      t = PAb[i], c0 = T[t], c1 = T[t + 1];
      SA[--(bucket_B[((c0) << 8) | (c1)])] = i;
    }
    t = PAb[m - 1], c0 = T[t], c1 = T[t + 1];
    SA[--(bucket_B[((c0) << 8) | (c1)])] = m - 1;
    buf = SA + m, bufsize = n - (2 * m);
    for (c0 = (256) - 2, j = m; 0 < j; --c0) {
      for (c1 = (256) - 1; c0 < c1; j = i, --c1) {
        i = (bucket_B[((c0) << 8) | (c1)]);
        if (1 < (j - i)) {
          sssort(T, PAb, SA + i, SA + j, buf, bufsize, 2, n, *(SA + i) == (m - 1));
        }
      }
    }
    for (i = m - 1; 0 <= i; --i) {
      if (0 <= SA[i]) {
        j = i;
        do {
          ISAb[SA[i]] = i;
        } while ((0 <= --i) && (0 <= SA[i]));
        SA[i + 1] = i - j;
        if (i <= 0) {
          break;
        }
      }
      j = i;
      do {
        ISAb[SA[i] = ~SA[i]] = j;
      } while (SA[--i] < 0);
      ISAb[SA[i]] = j;
    }
    trsort(ISAb, SA, m, 1);
    for (i = n - 1, j = m, c0 = T[n - 1]; 0 <= i;) {
      for (--i, c1 = c0; (0 <= i) && ((c0 = T[i]) >= c1); --i, c1 = c0) {
      }
      if (0 <= i) {
        t = i;
        for (--i, c1 = c0; (0 <= i) && ((c0 = T[i]) <= c1); --i, c1 = c0) {
        }
        SA[ISAb[--j]] = ((t == 0) || (1 < (t - i))) ? t : ~t;
      }
    }
    (bucket_B[(((256) - 1) << 8) | ((256) - 1)]) = n;
    for (c0 = (256) - 2, k = m - 1; 0 <= c0; --c0) {
      i = bucket_A[(c0 + 1)] - 1;
      for (c1 = (256) - 1; c0 < c1; --c1) {
        t = i - (bucket_B[((c1) << 8) | (c0)]);
        (bucket_B[((c1) << 8) | (c0)]) = i;
        for (i = t, j = (bucket_B[((c0) << 8) | (c1)]); j <= k; --i, --k) {
          SA[i] = SA[k];
        }
      }
      (bucket_B[((c0) << 8) | (c0 + 1)]) = i - (bucket_B[((c0) << 8) | (c0)]) + 1;
      (bucket_B[((c0) << 8) | (c0)]) = i;
    }
  }
  return m;
}
```