// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/./ls.h
// Function: LarssonSadakane<int>::suffixsort(int*, int*, int, int, int)
void suffixsort(T *x, T *p, T n, T k, T l)
	{
	   T *pi, *pk;
	   T i, j, s, sl;

	   V=x;                         /* set global values.*/
	   I=p;

	   if (n>=k-l) {                /* if bucketing possible,*/
		  j=transform(V, I, n, k, l, n);
		  bucketsort(V, I, n, j);   /* bucketsort on first r positions.*/
	   } else {
		  transform(V, I, n, k, l, std::numeric_limits<T>::max());
		  for (i=0; i<=n; ++i)
			 I[i]=i;                /* initialize I with suffix numbers.*/
		  h=0;
		  sort_split(I, n+1);       /* quicksort on first r positions.*/
	   }
	   h=r;                         /* number of symbols aggregated by transform.*/

	   while (*I>=-n) {
		  pi=I;                     /* pi is first position of group.*/
		  sl=0;                     /* sl is negated length of sorted groups.*/
		  do {
			 if ((s=*pi) <= 0 && (s=*pi) != 0) {
				pi-=s;              /* skip over sorted group.*/
				sl+=s;              /* add negated length to sl.*/
			 } else {
				if (sl) {
				   *(pi+sl)=sl;     /* combine sorted groups before pi.*/
				   sl=0;
				}
				pk=I+V[s]+1;        /* pk-1 is last position of unsorted group.*/
				sort_split(pi, (T)(pk-pi));
				pi=pk;              /* next group.*/
			 }
		  } while (pi<=I+n);
		  if (sl)                   /* if the array ends with a sorted group.*/
			 *(pi+sl)=sl;           /* combine sorted groups at end of I.*/
		  h=2*h;                    /* double sorted-depth.*/
	   }

	   for (i=0; i<=n; ++i)         /* reconstruct suffix array from inverse.*/
		  I[V[i]]=i;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdi, %r14
movq %rsi, 0x8(%rdi)
movq %rdx, (%rdi)
movl %r8d, %eax
subl %r9d, %eax
cmpl %ecx, %eax
jle 0x1ce21
movl $0x7fffffff, (%rsp)     # imm = 0x7FFFFFFF
movq %r14, %rdi
movl %ebx, %ecx
callq 0x1de12
leal 0x1(%rbx), %edx
testl %ebx, %ebx
js 0x1ce09
movl %edx, %eax
xorl %ecx, %ecx
movq (%r14), %rsi
movl %ecx, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1cdfb
movl $0x0, 0x14(%r14)
movq (%r14), %rsi
movq %r14, %rdi
callq 0x1e0b2
jmp 0x1cee4
movl %ebx, (%rsp)
movq %r14, %rdi
movl %ebx, %ecx
callq 0x1de12
movq (%r14), %r15
movq 0x8(%r14), %r12
cltq
leaq (%r15,%rax,4), %r13
testl %eax, %eax
jle 0x1ce68
leaq 0x4(%r15), %rax
cmpq %rax, %r13
cmovaq %r13, %rax
movq %r15, %rdx
notq %rdx
addq %rax, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
movq %r15, %rdi
movl $0xff, %esi
callq 0x51b0
testl %ebx, %ebx
js 0x1ce89
leal 0x1(%rbx), %eax
xorl %ecx, %ecx
movslq (%r12,%rcx,4), %rdx
movl (%r15,%rdx,4), %esi
movl %esi, (%r12,%rcx,4)
movl %ecx, (%r15,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1ce71
addq $-0x4, %r13
cmpq %r15, %r13
jb 0x1cee4
movl %ebx, %eax
movslq (%r13), %rsi
movl (%r12,%rsi,4), %edx
movl %eax, (%r12,%rsi,4)
leal -0x1(%rax), %ecx
movslq %eax, %rdi
testl %edx, %edx
js 0x1ced1
movl %esi, (%r15,%rdi,4)
movslq %ecx, %rsi
leaq (%r15,%rsi,4), %rsi
movl %edx, %edi
movl (%r12,%rdi,4), %r8d
movl %eax, (%r12,%rdi,4)
movl %edx, (%rsi)
addq $-0x4, %rsi
decl %ecx
movl %r8d, %edx
testl %r8d, %r8d
jns 0x1ceb5
jmp 0x1ced9
movl $0xffffffff, (%r15,%rdi,4) # imm = 0xFFFFFFFF
addq $-0x4, %r13
movl %ecx, %eax
cmpq %r15, %r13
jae 0x1ce94
movl 0x10(%r14), %eax
movl %ebx, %ebp
negl %ebp
movl %eax, 0x14(%r14)
movq (%r14), %rax
movl (%rax), %edx
cmpl %ebp, %edx
jge 0x1cf26
testl %ebx, %ebx
js 0x1cf17
incl %ebx
xorl %eax, %eax
movq (%r14), %rcx
movq 0x8(%r14), %rdx
movslq (%rdx,%rax,4), %rdx
movl %eax, (%rcx,%rdx,4)
incq %rax
cmpq %rax, %rbx
jne 0x1cf01
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %ebx, %r15
xorl %ecx, %ecx
movq %rax, %rsi
testl %edx, %edx
js 0x1cf76
testl %ecx, %ecx
je 0x1cf3f
movslq %ecx, %rax
movl %ecx, (%rsi,%rax,4)
movq (%r14), %rax
movq 0x8(%r14), %rcx
movl %edx, %edx
movslq (%rcx,%rdx,4), %rcx
leaq (%rax,%rcx,4), %r12
addq $0x4, %r12
movq %r12, %rdx
subq %rsi, %rdx
shrq $0x2, %rdx
movq %r14, %rdi
callq 0x1e0b2
movq (%r14), %rax
leaq (%rax,%r15,4), %rdx
xorl %ecx, %ecx
movq %r12, %rsi
cmpq %rdx, %r12
ja 0x1cf98
jmp 0x1cfaf
movslq %edx, %rdi
shlq $0x2, %rdi
subq %rdi, %rsi
addl %edx, %ecx
leaq (%rax,%r15,4), %rdx
cmpq %rdx, %rsi
jbe 0x1cfaf
testl %ecx, %ecx
je 0x1cf98
movslq %ecx, %rax
movl %ecx, (%rsi,%rax,4)
movq (%r14), %rax
shll 0x14(%r14)
movl (%rax), %edx
movq %rax, %rsi
movl $0x0, %ecx
cmpl %ebp, %edx
jge 0x1cf2e
jmp 0x1cef9
movl (%rsi), %edx
jmp 0x1cf2e