// File: /workspace/github_c_makefile_star2_O2/ToniWestbrook[P]paladin/is.c
// Function: induceSA
static void induceSA(const unsigned char *T, int64_t *SA, int64_t *C, int64_t *B, int64_t n, int64_t k, int64_t cs)
{
	int64_t *b, i, j;
	int64_t  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) {
		j = SA[i], SA[i] = ~j;
		if (0 < j) {
			--j;
			if ((c0 = chr(j)) != c1) {
				B[c1] = b - SA;
				b = SA + B[c1 = c0];
			}
			*b++ = ((0 < j) && (chr(j - 1) < c1)) ? ~j : 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;
			if ((c0 = chr(j)) != c1) {
				B[c1] = b - SA;
				b = SA + B[c1 = c0];
			}
			*--b = ((j == 0) || (chr(j - 1) > c1)) ? ~j : j;
		} else SA[i] = ~j;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbp
movq %r8, %r13
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x50(%rsp), %r12
cmpq %rcx, %rdx
movq %rdx, 0x8(%rsp)
jne 0x4012
movq %r15, %rdi
movq %rdx, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movq %r12, %r8
callq 0x3f4c
movq 0x8(%rsp), %rdx
movq %rdx, %rdi
movq %rbx, %rsi
movq %rbp, 0x10(%rsp)
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x3f8c
leaq -0x1(%r13), %rbp
cmpq $0x8, %r12
jne 0x404b
movq -0x8(%r15,%r13,8), %rcx
movq (%rbx,%rcx,8), %rax
leaq (%r14,%rax,8), %rax
cmpq $0x1, %r13
jle 0x4074
movq -0x10(%r15,%r13,8), %rdx
jmp 0x4065
movzbl -0x1(%r15,%r13), %ecx
movq (%rbx,%rcx,8), %rax
leaq (%r14,%rax,8), %rax
cmpq $0x1, %r13
jle 0x4074
movzbl -0x2(%r15,%r13), %edx
movq %r13, %rsi
negq %rsi
cmpq %rcx, %rdx
cmovgeq %rbp, %rsi
jmp 0x4077
movq %rbp, %rsi
movq %rsi, (%rax)
addq $0x8, %rax
xorl %edx, %edx
testq %r13, %r13
movl $0x0, %esi
cmovgq %r13, %rsi
cmpq %rdx, %rsi
je 0x4115
movq (%r14,%rdx,8), %rdi
movq %rdi, %r8
notq %r8
movq %r8, (%r14,%rdx,8)
testq %rdi, %rdi
jle 0x410d
leaq -0x1(%rdi), %r8
cmpq $0x8, %r12
jne 0x40b9
movq -0x8(%r15,%rdi,8), %r9
jmp 0x40be
movzbl (%r15,%r8), %r9d
cmpq %rcx, %r9
jne 0x40c8
movq %rcx, %r9
jmp 0x40db
subq %r14, %rax
sarq $0x3, %rax
movq %rax, (%rbx,%rcx,8)
movq (%rbx,%r9,8), %rax
leaq (%r14,%rax,8), %rax
cmpq $0x1, %rdi
jne 0x40e6
xorl %r8d, %r8d
jmp 0x4103
cmpq $0x8, %r12
jne 0x40f3
movq -0x10(%r15,%rdi,8), %rcx
jmp 0x40f9
movzbl -0x2(%r15,%rdi), %ecx
negq %rdi
cmpq %r9, %rcx
cmovlq %rdi, %r8
movq %r8, (%rax)
addq $0x8, %rax
movq %r9, %rcx
incq %rdx
jmp 0x408c
movq 0x8(%rsp), %rsi
cmpq %rbx, %rsi
jne 0x4137
movq %r15, %rdi
movq %r13, %rdx
movq 0x10(%rsp), %rcx
movq %r12, %r8
callq 0x3f4c
movq 0x8(%rsp), %rsi
pushq $0x1
popq %rcx
movq %rsi, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
callq 0x3f8c
movq (%rbx), %rax
leaq (%r14,%rax,8), %rax
xorl %edx, %edx
testq %rbp, %rbp
js 0x41d0
movq (%r14,%rbp,8), %rcx
testq %rcx, %rcx
jle 0x4172
leaq -0x1(%rcx), %rsi
cmpq $0x8, %r12
jne 0x417b
movq -0x8(%r15,%rcx,8), %rdi
jmp 0x4180
notq %rcx
movq %rcx, (%r14,%rbp,8)
jmp 0x41cb
movzbl (%r15,%rsi), %edi
cmpq %rdx, %rdi
jne 0x418a
movq %rdx, %rdi
jmp 0x419d
subq %r14, %rax
sarq $0x3, %rax
movq %rax, (%rbx,%rdx,8)
movq (%rbx,%rdi,8), %rax
leaq (%r14,%rax,8), %rax
testq %rsi, %rsi
je 0x41ba
cmpq $0x8, %r12
jne 0x41af
movq -0x10(%r15,%rcx,8), %rdx
jmp 0x41b5
movzbl -0x2(%r15,%rcx), %edx
cmpq %rdi, %rdx
jle 0x41c0
negq %rcx
movq %rcx, %rsi
movq %rsi, -0x8(%rax)
addq $-0x8, %rax
movq %rdi, %rdx
decq %rbp
jmp 0x4153
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop