// File: /workspace/github_c_makefile_star2_O0/fukunagatsu[P]RIblast/sais.c
// Function: computeBWT
static
sais_index_type
computeBWT(const void *T, sais_index_type *SA,
           sais_index_type *C, sais_index_type *B,
           sais_index_type n, sais_index_type k, int cs) {
  sais_index_type *b, i, j, pidx = -1;
  sais_index_type c0, c1;
  /* compute SAl */
  if(C == B) { getCounts(T, C, n, k, cs); }
  getBuckets(C, B, k, 0); /* find starts of buckets */
  j = n - 1;
  b = SA + B[c1 = chr(j)];
  *b++ = ((0 < j) && (chr(j - 1) < c1)) ? ~j : j;
  for(i = 0; i < n; ++i) {
    if(0 < (j = SA[i])) {
      --j;
      assert(chr(j) >= chr(j + 1));
      SA[i] = ~((sais_index_type)(c0 = chr(j)));
      if(c0 != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; }
      assert(i < (b - SA));
      *b++ = ((0 < j) && (chr(j - 1) < c1)) ? ~j : j;
    } else if(j != 0) {
      SA[i] = ~j;
    }
  }
  /* compute SAs */
  if(C == B) { getCounts(T, C, n, k, cs); }
  getBuckets(C, B, k, 1); /* find ends of buckets */
  for(i = n - 1, b = SA + B[c1 = 0]; 0 <= i; --i) {
    if(0 < (j = SA[i])) {
      --j;
      assert(chr(j) <= chr(j + 1));
      SA[i] = (c0 = chr(j));
      if(c0 != c1) { B[c1] = b - SA; b = SA + B[c1 = c0]; }
      assert((b - SA) <= i);
      *--b = ((0 < j) && (chr(j - 1) > c1)) ? ~((sais_index_type)chr(j - 1)) : j;
    } else if(j != 0) {
      SA[i] = ~j;
    } else {
      pidx = i;
    }
  }
  return pidx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x3799e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
movl 0x10(%rbp), %r8d
callq 0x35f40
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x28(%rbp), %edx
xorl %ecx, %ecx
callq 0x35fe0
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x379e3
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x5c(%rbp)
jmp 0x379f2
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movq -0x50(%rbp), %rcx
movl -0x5c(%rbp), %edx
movl %edx, -0x44(%rbp)
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
jge 0x37a5f
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37a38
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x60(%rbp)
jmp 0x37a4c
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x37a5f
movl -0x38(%rbp), %eax
xorl $-0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x37a65
movl -0x38(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %ecx
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x30(%rbp)
movl %ecx, (%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x37c86
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movl %ecx, -0x38(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jge 0x37c5d
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37ac7
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
jmp 0x37ad6
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x6c(%rbp)
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37afb
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x70(%rbp)
jmp 0x37b0f
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
movl -0x70(%rbp), %ecx
cmpl %ecx, %eax
jl 0x37b1b
jmp 0x37b3a
leaq 0x133e(%rip), %rdi      # 0x38e60
leaq 0x1253(%rip), %rsi      # 0x38d7c
movl $0x130, %edx            # imm = 0x130
leaq 0x145f(%rip), %rcx      # 0x38f94
callq 0x31c0
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37b54
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x74(%rbp)
jmp 0x37b63
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %edx
movl %edx, -0x40(%rbp)
xorl $-0x1, %edx
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x37bbb
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x40(%rbp), %edx
movl %edx, -0x44(%rbp)
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movslq -0x34(%rbp), %rax
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq %rdx, %rcx
sarq $0x2, %rcx
cmpq %rcx, %rax
jge 0x37bd5
jmp 0x37bf4
leaq 0x1299(%rip), %rdi      # 0x38e75
leaq 0x1199(%rip), %rsi      # 0x38d7c
movl $0x133, %edx            # imm = 0x133
leaq 0x13a5(%rip), %rcx      # 0x38f94
callq 0x31c0
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
jge 0x37c41
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37c1a
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x78(%rbp)
jmp 0x37c2e
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x37c41
movl -0x38(%rbp), %eax
xorl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x37c47
movl -0x38(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %ecx
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x4, %rdx
movq %rdx, -0x30(%rbp)
movl %ecx, (%rax)
jmp 0x37c76
cmpl $0x0, -0x38(%rbp)
je 0x37c74
movl -0x38(%rbp), %edx
xorl $-0x1, %edx
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x37c76
jmp 0x37c78
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x37a80
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x37ca7
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
movl 0x10(%rbp), %r8d
callq 0x35f40
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x28(%rbp), %edx
movl $0x1, %ecx
callq 0x35fe0
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movl $0x0, -0x44(%rbp)
movslq (%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpl -0x34(%rbp), %eax
jg 0x37f57
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movl %ecx, -0x38(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jge 0x37f26
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37d28
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x80(%rbp)
jmp 0x37d37
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x84(%rbp)
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37d62
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x88(%rbp)
jmp 0x37d79
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x88(%rbp)
movl -0x84(%rbp), %eax
movl -0x88(%rbp), %ecx
cmpl %ecx, %eax
jg 0x37d8b
jmp 0x37daa
leaq 0x10f0(%rip), %rdi      # 0x38e82
leaq 0xfe3(%rip), %rsi       # 0x38d7c
movl $0x13f, %edx            # imm = 0x13F
leaq 0x11ef(%rip), %rcx      # 0x38f94
callq 0x31c0
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37dc7
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x8c(%rbp)
jmp 0x37dd9
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %edx
movl %edx, -0x40(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x40(%rbp), %eax
cmpl -0x44(%rbp), %eax
je 0x37e31
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movl -0x40(%rbp), %edx
movl %edx, -0x44(%rbp)
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jg 0x37e4b
jmp 0x37e6a
leaq 0x1045(%rip), %rdi      # 0x38e97
leaq 0xf23(%rip), %rsi       # 0x38d7c
movl $0x142, %edx            # imm = 0x142
leaq 0x112f(%rip), %rcx      # 0x38f94
callq 0x31c0
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
jge 0x37f03
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37e97
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x90(%rbp)
jmp 0x37eae
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
cmpl -0x44(%rbp), %eax
jle 0x37f03
movslq 0x10(%rbp), %rax
cmpq $0x4, %rax
jne 0x37edb
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x94(%rbp)
jmp 0x37ef2
movq -0x8(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
xorl $-0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x37f0c
movl -0x38(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %ecx
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $-0x4, %rdx
movq %rdx, -0x30(%rbp)
movl %ecx, -0x4(%rax)
jmp 0x37f47
cmpl $0x0, -0x38(%rbp)
je 0x37f3f
movl -0x38(%rbp), %edx
xorl $-0x1, %edx
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x37f45
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0x37f47
jmp 0x37f49
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x37ce2
movl -0x3c(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq