// File: /workspace/github_cpp_makefile_star2_O3/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, 0x16295(%rip)     # 0x54430
movq %rsi, 0x16296(%rip)     # 0x54438
movl %ecx, %eax
subl %r8d, %eax
cmpl %edx, %eax
jle 0x3e27c
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
callq 0x3e40b
leal 0x1(%rbx), %esi
movq 0x1626c(%rip), %rdi     # 0x54438
testl %ebx, %ebx
js 0x3e261
movl %esi, %ecx
leal 0x1(%rsi), %eax
andl $-0x2, %eax
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x605f(%rip), %xmm1     # 0x44250
xorl %ecx, %ecx
movdqa 0x1e45(%rip), %xmm2     # 0x40040
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x6055(%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, %edx
notl %edx
testb $0x1, %dl
je 0x3e23f
movl %ecx, (%rdi,%rcx,4)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x3e254
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rdi,%rcx,4)
addq $0x2, %rcx
paddq %xmm4, %xmm1
cmpq %rcx, %rax
jne 0x3e20b
movl $0x0, 0x161d5(%rip)     # 0x54440
callq 0x3e689
movq 0x161c1(%rip), %r14     # 0x54438
jmp 0x3e33b
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %r9d
callq 0x3e40b
cltq
leaq (%r14,%rax,4), %r12
testl %eax, %eax
jle 0x3e2bf
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 0x3e2e0
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 0x3e2c8
addq $-0x4, %r12
cmpq %r14, %r12
jb 0x3e33b
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 0x3e328
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 0x3e30c
jmp 0x3e330
movl $0xffffffff, (%r14,%rdi,4) # imm = 0xFFFFFFFF
addq $-0x4, %r12
movl %ecx, %eax
cmpq %r14, %r12
jae 0x3e2eb
movl 0x16103(%rip), %eax     # 0x54444
movl %ebx, %ebp
negl %ebp
movl %eax, 0x160f5(%rip)     # 0x54440
movl (%r14), %ecx
cmpl %ebp, %ecx
jge 0x3e37a
testl %ebx, %ebx
js 0x3e371
movq 0x160d3(%rip), %rax     # 0x54430
incl %ebx
xorl %ecx, %ecx
movslq (%rax,%rcx,4), %rdx
movl %ecx, (%r14,%rdx,4)
incq %rcx
cmpq %rcx, %rbx
jne 0x3e361
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movslq %ebx, %r15
xorl %eax, %eax
movq %r14, %rdi
testl %ecx, %ecx
js 0x3e3cb
testl %eax, %eax
je 0x3e390
movslq %eax, %rdx
movl %eax, (%rdi,%rdx,4)
movq 0x16099(%rip), %rax     # 0x54430
movl %ecx, %ecx
movslq (%rax,%rcx,4), %rax
leaq (%r14,%rax,4), %r12
addq $0x4, %r12
movq %r12, %rsi
subq %rdi, %rsi
shrq $0x2, %rsi
callq 0x3e689
movq 0x1607d(%rip), %r14     # 0x54438
leaq (%r14,%r15,4), %rcx
xorl %eax, %eax
movq %r12, %rdi
cmpq %rcx, %r12
ja 0x3e3ea
jmp 0x3e404
movslq %ecx, %rdx
shlq $0x2, %rdx
subq %rdx, %rdi
addl %ecx, %eax
leaq (%r14,%r15,4), %rcx
cmpq %rcx, %rdi
jbe 0x3e404
testl %eax, %eax
je 0x3e3ea
movslq %eax, %rcx
movl %eax, (%rdi,%rcx,4)
shll 0x16050(%rip)           # 0x54440
movl (%r14), %ecx
movq %r14, %rdi
movl $0x0, %eax
cmpl %ebp, %ecx
jge 0x3e382
jmp 0x3e352
movl (%rdi), %ecx
jmp 0x3e382