// File: /workspace/github_cpp_makefile_star2_O1/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 0x1cffa
movl $0x7fffffff, (%rsp)     # imm = 0x7FFFFFFF
movq %r14, %rdi
movl %ebx, %ecx
callq 0x1e058
testl %ebx, %ebx
js 0x1cfdf
leal 0x1(%rbx), %eax
xorl %ecx, %ecx
movq (%r14), %rdx
movl %ecx, (%rdx,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x1cfd1
movl $0x0, 0x14(%r14)
movq (%r14), %rsi
leal 0x1(%rbx), %edx
movq %r14, %rdi
callq 0x1e2f8
jmp 0x1d0bd
movl %ebx, (%rsp)
movq %r14, %rdi
movl %ebx, %ecx
callq 0x1e058
movq (%r14), %r15
movq 0x8(%r14), %r12
cltq
leaq (%r15,%rax,4), %r13
testl %eax, %eax
jle 0x1d041
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 0x1d062
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 0x1d04a
addq $-0x4, %r13
cmpq %r15, %r13
jb 0x1d0bd
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 0x1d0aa
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 0x1d08e
jmp 0x1d0b2
movl $0xffffffff, (%r15,%rdi,4) # imm = 0xFFFFFFFF
addq $-0x4, %r13
movl %ecx, %eax
cmpq %r15, %r13
jae 0x1d06d
movl 0x10(%r14), %eax
movl %ebx, %ebp
negl %ebp
movl %eax, 0x14(%r14)
movq (%r14), %rsi
cmpl %ebp, (%rsi)
jl 0x1d148
movslq %ebx, %r15
xorl %eax, %eax
shlq $0x2, %r15
movslq (%rsi), %rcx
testq %rcx, %rcx
js 0x1d117
testl %eax, %eax
je 0x1d0eb
movslq %eax, %rdx
movl %eax, (%rsi,%rdx,4)
movq (%r14), %rax
movq 0x8(%r14), %rdx
movslq (%rdx,%rcx,4), %rcx
leaq (%rax,%rcx,4), %r12
addq $0x4, %r12
movq %r12, %rdx
subq %rsi, %rdx
shrq $0x2, %rdx
movq %r14, %rdi
callq 0x1e2f8
xorl %eax, %eax
movq %r12, %rsi
jmp 0x1d123
movq %rcx, %rdx
shlq $0x2, %rdx
subq %rdx, %rsi
addl %ecx, %eax
movq (%r14), %rcx
addq %r15, %rcx
cmpq %rcx, %rsi
jbe 0x1d0d9
testl %eax, %eax
je 0x1d138
movslq %eax, %rcx
movl %eax, (%rsi,%rcx,4)
shll 0x14(%r14)
movq (%r14), %rsi
movl $0x0, %eax
cmpl %ebp, (%rsi)
jge 0x1d0d9
testl %ebx, %ebx
js 0x1d166
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 0x1d150
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop