// File: /workspace/github_cpp_makefile_star2_O1/readmapping[P]alfalfa/src/qsufsort.c
// Function: suffixsort
void suffixsort(int *x, int *p, int n, int k, int l)
{
   int *pi, *pk;
   int 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, INT_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) {
            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, 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 %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movq %rdi, 0x1611d(%rip)     # 0x54430
movq %rsi, 0x1611e(%rip)     # 0x54438
movl %ecx, %eax
subl %r8d, %eax
cmpl %edx, %eax
jle 0x3e3f5
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
callq 0x3e580
testl %ebx, %ebx
js 0x3e3d7
movq 0x160ef(%rip), %rax     # 0x54438
movl %ebx, %ecx
andl $0x7ffffffe, %ecx       # imm = 0x7FFFFFFE
addl $0x2, %ecx
movd %ebx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x5eeb(%rip), %xmm1     # 0x44250
xorl %edx, %edx
movdqa 0x1cd1(%rip), %xmm2     # 0x40040
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x5ee1(%rip), %xmm4     # 0x44260
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0x3e3b4
movl %edx, (%rax,%rdx,4)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x3e3ca
leal 0x1(%rdx), %esi
movl %esi, 0x4(%rax,%rdx,4)
addq $0x2, %rdx
paddq %xmm4, %xmm1
cmpq %rdx, %rcx
jne 0x3e37f
movl $0x0, 0x1605f(%rip)     # 0x54440
movq 0x16050(%rip), %rdi     # 0x54438
leal 0x1(%rbx), %esi
callq 0x3e807
jmp 0x3e4b4
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %r9d
callq 0x3e580
cltq
leaq (%r14,%rax,4), %r12
testl %eax, %eax
jle 0x3e438
leaq 0x4(%r14), %rax
cmpq %rax, %r12
cmovaq %r12, %rax
movq %r14, %rdx
notq %rdx
addq %rax, %rdx
andq $-0x4, %rdx
addq $0x4, %rdx
movq %r14, %rdi
movl $0xff, %esi
callq 0x7180
testl %ebx, %ebx
js 0x3e459
leal 0x1(%rbx), %eax
xorl %ecx, %ecx
movslq (%r15,%rcx,4), %rdx
movl (%r14,%rdx,4), %esi
movl %esi, (%r15,%rcx,4)
movl %ecx, (%r14,%rdx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x3e441
addq $-0x4, %r12
cmpq %r14, %r12
jb 0x3e4b4
movl %ebx, %eax
movslq (%r12), %rsi
movl (%r15,%rsi,4), %edx
movl %eax, (%r15,%rsi,4)
leal -0x1(%rax), %ecx
movslq %eax, %rdi
testl %edx, %edx
js 0x3e4a1
movl %esi, (%r14,%rdi,4)
movslq %ecx, %rsi
leaq (%r14,%rsi,4), %rsi
movl %edx, %edi
movl (%r15,%rdi,4), %r8d
movl %eax, (%r15,%rdi,4)
movl %edx, (%rsi)
addq $-0x4, %rsi
decl %ecx
movl %r8d, %edx
testl %r8d, %r8d
jns 0x3e485
jmp 0x3e4a9
movl $0xffffffff, (%r14,%rdi,4) # imm = 0xFFFFFFFF
addq $-0x4, %r12
movl %ecx, %eax
cmpq %r14, %r12
jae 0x3e464
movl 0x15f8a(%rip), %eax     # 0x54444
movl %ebx, %ebp
negl %ebp
movl %eax, 0x15f7c(%rip)     # 0x54440
movq 0x15f6d(%rip), %rdi     # 0x54438
cmpl %ebp, (%rdi)
jl 0x3e559
movslq %ebx, %r14
xorl %eax, %eax
shlq $0x2, %r14
movslq (%rdi), %rcx
testq %rcx, %rcx
js 0x3e51e
testl %eax, %eax
je 0x3e4ee
movslq %eax, %rdx
movl %eax, (%rdi,%rdx,4)
movq 0x15f43(%rip), %rax     # 0x54438
movq 0x15f34(%rip), %rdx     # 0x54430
movslq (%rdx,%rcx,4), %rcx
leaq (%rax,%rcx,4), %r15
addq $0x4, %r15
movq %r15, %rsi
subq %rdi, %rsi
shrq $0x2, %rsi
callq 0x3e807
xorl %eax, %eax
movq %r15, %rdi
jmp 0x3e52a
movq %rcx, %rdx
shlq $0x2, %rdx
subq %rdx, %rdi
addl %ecx, %eax
movq 0x15f07(%rip), %rcx     # 0x54438
addq %r14, %rcx
cmpq %rcx, %rdi
jbe 0x3e4dc
testl %eax, %eax
je 0x3e543
movslq %eax, %rcx
movl %eax, (%rdi,%rcx,4)
shll 0x15ef7(%rip)           # 0x54440
movq 0x15ee8(%rip), %rdi     # 0x54438
movl $0x0, %eax
cmpl %ebp, (%rdi)
jge 0x3e4dc
testl %ebx, %ebx
js 0x3e577
movq 0x15ecc(%rip), %rax     # 0x54430
incl %ebx
xorl %ecx, %ecx
movslq (%rax,%rcx,4), %rdx
movl %ecx, (%rdi,%rdx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0x3e568
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq