// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/sfx-bentsedg.c
// Function: sarrcountingsort
static void sarrcountingsort(GtBentsedgresources *bsr,
                             GtUword subbucketleft,
                             GtUword width,
                             const GtSfxcmp *pivotcmpbits,
                             GtUword pivotidx,
                             GtUword depth)
{
  int cmp;
  unsigned int maxsmallerwithlcp = 0, maxlargerwithlcp = 0;
  GtCommonunits commonunits;
  GtEndofTwobitencoding etbecurrent;
  GtUword idx, smaller = 0, larger = 0,
                insertindex, end, equaloffset, currentwidth;
  GtCountingsortinfo *csiptr;
  /* const bool cmpcharbychar = false; */

  bsr->countcountingsort++;
  for (idx = 0; idx < width; idx++)
  {
    if (idx != pivotidx)
    {
      PTR2INTSTOREPOS(etbecurrent,subbucketleft,idx,
                      bsr->countingsortinfo[idx].suffix = pos);
      cmp = gt_encseq_compare_pairof_twobitencodings(bsr->fwd,
                                                     bsr->complement,
                                                     &commonunits,
                                                     &etbecurrent,
                                                     pivotcmpbits);
      gt_assert(commonunits.common <= (unsigned int) GT_UNITSIN2BITENC);
      bsr->countingsortinfo[idx].lcpwithpivot = commonunits.common;
      if (cmp > 0)
      {
        gt_assert(commonunits.common < (unsigned int) GT_UNITSIN2BITENC);
        bsr->rightlcpdist[commonunits.common]++;
        if (maxlargerwithlcp < commonunits.common)
        {
          maxlargerwithlcp = commonunits.common;
        }
        bsr->countingsortinfo[idx].cmpresult = (char) 1;
        larger++;
      } else
      {
        if (cmp < 0)
        {
          gt_assert(commonunits.common < (unsigned int) GT_UNITSIN2BITENC);
          bsr->leftlcpdist[commonunits.common]++;
          if (maxsmallerwithlcp < commonunits.common)
          {
            maxsmallerwithlcp = commonunits.common;
          }
          bsr->countingsortinfo[idx].cmpresult = (char) -1;
          smaller++;
        } else
        {
          gt_assert(commonunits.common == (unsigned int) GT_UNITSIN2BITENC);
          bsr->countingsortinfo[idx].cmpresult = 0;
        }
      }
    } else
    {
      bsr->countingsortinfo[idx].suffix
        = gt_suffixsortspace_get(bsr->sssp,subbucketleft,idx);
      bsr->countingsortinfo[idx].lcpwithpivot = (unsigned char)
                                                GT_UNITSIN2BITENC;
      bsr->countingsortinfo[idx].cmpresult = (char) 0;
    }
  }
  for (idx = 1UL; idx <= (GtUword) maxsmallerwithlcp; idx++)
  {
    bsr->leftlcpdist[idx] += bsr->leftlcpdist[idx-1];
  }
  for (idx = 1UL; idx <= (GtUword) maxlargerwithlcp; idx++)
  {
    bsr->rightlcpdist[idx] += bsr->rightlcpdist[idx-1];
  }
  equaloffset = width - larger;
  for (csiptr = bsr->countingsortinfo + width -1;
       csiptr >= bsr->countingsortinfo;
       csiptr--)
  {
    switch (csiptr->cmpresult)
    {
      case -1:
        insertindex = --(bsr->leftlcpdist[csiptr->lcpwithpivot]);
        gt_suffixsortspace_set(bsr->sssp,subbucketleft,insertindex,
                               csiptr->suffix);
        break;
      case 0:
        gt_suffixsortspace_set(bsr->sssp,subbucketleft,--equaloffset,
                               csiptr->suffix);
        break;
      case 1:
        insertindex = --(bsr->rightlcpdist[csiptr->lcpwithpivot]);
        gt_suffixsortspace_set(bsr->sssp,subbucketleft,
                               width - 1 - insertindex,
                               csiptr->suffix);
        break;
    }
  }
  for (idx = 0; idx <= (GtUword) maxsmallerwithlcp; idx++)
  {
    if (idx < (GtUword) maxsmallerwithlcp)
    {
      end = bsr->leftlcpdist[idx+1];
    } else
    {
      end = smaller;
    }
    if (bsr->leftlcpdist[idx] + 1 < end) /* at least two elements */
    {
      currentwidth = end - bsr->leftlcpdist[idx];
      subsort_bentleysedgewick(bsr,
                               subbucketleft + bsr->leftlcpdist[idx],
                               currentwidth,
                               depth + idx);
    }
    if (bsr->tableoflcpvalues != NULL && bsr->leftlcpdist[idx] < end)
    { /* at least one element */
      gt_lcptab_update(bsr->tableoflcpvalues,subbucketleft,end,depth + idx);
    }
    bsr->leftlcpdist[idx] = 0;
  }
  if (width - smaller - larger > 1UL)
  {
    currentwidth = width - smaller - larger;
    subsort_bentleysedgewick(bsr,
                             subbucketleft + smaller,
                             currentwidth,
                             depth + GT_UNITSIN2BITENC);
  }
  for (idx = 0; idx <= (GtUword) maxlargerwithlcp; idx++)
  {
    if (idx < (GtUword) maxlargerwithlcp)
    {
      end = bsr->rightlcpdist[idx+1];
    } else
    {
      end = larger;
    }
    if (bsr->rightlcpdist[idx] + 1 < end) /* at least two elements */
    {
      currentwidth = end - bsr->rightlcpdist[idx];
      subsort_bentleysedgewick(bsr,
                               /* for largest idx use first bucket */
                               subbucketleft + width - end,
                               currentwidth,
                               depth + idx);
    }
    if (bsr->tableoflcpvalues != NULL && bsr->rightlcpdist[idx] < end)
    { /* at least one element */
      gt_assert(width >= end);
      gt_lcptab_update(bsr->tableoflcpvalues,subbucketleft,width - end,
                    depth + idx);
    }
    bsr->rightlcpdist[idx] = 0;
  }
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
movq %r8, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movl $0x0, 0x80(%rsp)
movl $0x0, 0x7c(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x38(%rsp)
movq 0xb0(%rsp), %rax
movq 0x88(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x88(%rax)
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jae 0x2b50a5
movq 0x48(%rsp), %rax
cmpq 0x90(%rsp), %rax
je 0x2b5013
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x2e9ec0
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x8(%rsp), %rax
addq 0x88(%rsp), %rax
movq 0xb0(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x2b4d88
movq 0x88(%rsp), %rax
addq 0x8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xb0(%rsp), %rax
movq 0x8(%rax), %rsi
movq 0xb0(%rsp), %rax
movq (%rax), %rdx
movq 0xb0(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x8(%rsp), %r8
leaq 0x50(%rsp), %rdi
callq 0xb34d0
jmp 0x2b4d99
movq $0x0, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movq 0xb0(%rsp), %rax
movb 0x1c(%rax), %sil
movq 0xb0(%rsp), %rax
movb 0x1d(%rax), %al
movq 0x98(%rsp), %r8
leaq 0x68(%rsp), %rdx
leaq 0x50(%rsp), %rcx
andb $0x1, %sil
andb $0x1, %al
movzbl %sil, %edi
movzbl %al, %esi
callq 0xb4420
movl %eax, 0x84(%rsp)
cmpl $0x20, 0x68(%rsp)
jbe 0x2b4e1a
movq 0x3871b7(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x261220(%rip), %rsi    # 0x516013
leaq 0x2d3a9f(%rip), %rdx    # 0x588899
leaq 0x2d3acf(%rip), %rcx    # 0x5888d0
leaq 0x2d3768(%rip), %r8     # 0x588570
movl $0x3b5, %r9d            # imm = 0x3B5
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b4e1c
movl 0x68(%rsp), %eax
movb %al, %cl
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movb %cl, 0x8(%rax)
cmpl $0x0, 0x84(%rsp)
jle 0x2b4ef5
jmp 0x2b4e50
cmpl $0x20, 0x68(%rsp)
jb 0x2b4e8f
movq 0x387142(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2611ab(%rip), %rsi    # 0x516013
leaq 0x2d3a72(%rip), %rdx    # 0x5888e1
leaq 0x2d3a5a(%rip), %rcx    # 0x5888d0
leaq 0x2d36f3(%rip), %r8     # 0x588570
movl $0x3b9, %r9d            # imm = 0x3B9
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b4e91
movq 0xb0(%rsp), %rax
movl 0x68(%rsp), %ecx
movq 0x1c0(%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, 0x1c0(%rax,%rcx,8)
movl 0x7c(%rsp), %eax
cmpl 0x68(%rsp), %eax
jae 0x2b4ec3
movl 0x68(%rsp), %eax
movl %eax, 0x7c(%rsp)
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x1, 0x9(%rax)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0x2b5011
cmpl $0x0, 0x84(%rsp)
jge 0x2b4fad
jmp 0x2b4f05
cmpl $0x20, 0x68(%rsp)
jb 0x2b4f44
movq 0x38708d(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2610f6(%rip), %rsi    # 0x516013
leaq 0x2d39bd(%rip), %rdx    # 0x5888e1
leaq 0x2d39a5(%rip), %rcx    # 0x5888d0
leaq 0x2d363e(%rip), %r8     # 0x588570
movl $0x3c5, %r9d            # imm = 0x3C5
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b4f46
movq 0xb0(%rsp), %rax
movl 0x68(%rsp), %ecx
movq 0xc0(%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, 0xc0(%rax,%rcx,8)
movl 0x80(%rsp), %eax
cmpl 0x68(%rsp), %eax
jae 0x2b4f7e
movl 0x68(%rsp), %eax
movl %eax, 0x80(%rsp)
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $-0x1, 0x9(%rax)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
jmp 0x2b500f
jmp 0x2b4faf
cmpl $0x20, 0x68(%rsp)
je 0x2b4fee
movq 0x386fe3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x26104c(%rip), %rsi    # 0x516013
leaq 0x2d3949(%rip), %rdx    # 0x588917
leaq 0x2d38fb(%rip), %rcx    # 0x5888d0
leaq 0x2d3594(%rip), %r8     # 0x588570
movl $0x3cf, %r9d            # imm = 0x3CF
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b4ff0
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x0, 0x9(%rax)
jmp 0x2b5011
jmp 0x2b5090
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x2e9ec0
movq %rax, %rcx
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x20, 0x8(%rax)
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0x48(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x0, 0x9(%rax)
jmp 0x2b5092
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2b4caf
movq $0x1, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x80(%rsp), %ecx
cmpq %rcx, %rax
ja 0x2b5105
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
subq $0x1, %rcx
movq 0xc0(%rax,%rcx,8), %rdx
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
addq 0xc0(%rax,%rcx,8), %rdx
movq %rdx, 0xc0(%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2b50ae
movq $0x1, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x7c(%rsp), %ecx
cmpq %rcx, %rax
ja 0x2b5162
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
subq $0x1, %rcx
movq 0x1c0(%rax,%rcx,8), %rdx
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
addq 0x1c0(%rax,%rcx,8), %rdx
movq %rdx, 0x1c0(%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2b510e
movq 0xa0(%rsp), %rax
subq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xb0(%rsp), %rax
movq 0x2d8(%rax), %rax
movq 0xa0(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
addq $-0x10, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0xb0(%rsp), %rcx
cmpq 0x2d8(%rcx), %rax
jb 0x2b52e0
movq 0x10(%rsp), %rax
movsbl 0x9(%rax), %eax
movl %eax, 0x4(%rsp)
subl $-0x1, %eax
je 0x2b51e5
jmp 0x2b51c9
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x2b523c
jmp 0x2b51d3
movl 0x4(%rsp), %eax
subl $0x1, %eax
je 0x2b526d
jmp 0x2b52cb
movq 0xb0(%rsp), %rcx
movq 0x10(%rsp), %rax
movzbl 0x8(%rax), %eax
movl %eax, %edx
movq 0xc0(%rcx,%rdx,8), %rax
addq $-0x1, %rax
movq %rax, 0xc0(%rcx,%rdx,8)
movq %rax, 0x30(%rsp)
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rax
movq (%rax), %rcx
callq 0x2ea0a0
jmp 0x2b52cb
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq $-0x1, %rdx
movq %rdx, 0x20(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rcx
callq 0x2ea0a0
jmp 0x2b52cb
movq 0xb0(%rsp), %rcx
movq 0x10(%rsp), %rax
movzbl 0x8(%rax), %eax
movl %eax, %edx
movq 0x1c0(%rcx,%rdx,8), %rax
addq $-0x1, %rax
movq %rax, 0x1c0(%rcx,%rdx,8)
movq %rax, 0x30(%rsp)
movq 0xb0(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
subq $0x1, %rdx
subq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rax
movq (%rax), %rcx
callq 0x2ea0a0
jmp 0x2b52cd
movq 0x10(%rsp), %rax
addq $-0x10, %rax
movq %rax, 0x10(%rsp)
jmp 0x2b519b
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x80(%rsp), %ecx
cmpq %rcx, %rax
ja 0x2b5432
movq 0x48(%rsp), %rax
movl 0x80(%rsp), %ecx
cmpq %rcx, %rax
jae 0x2b532b
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0xc8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
jmp 0x2b5335
movq 0x40(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0xc0(%rax,%rcx,8), %rax
addq $0x1, %rax
cmpq 0x28(%rsp), %rax
jae 0x2b53b0
movq 0x28(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq 0xc0(%rcx,%rdx,8), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
addq 0xc0(%rax,%rcx,8), %rsi
movq 0x18(%rsp), %rdx
movq 0x88(%rsp), %rcx
addq 0x48(%rsp), %rcx
callq 0x2b4530
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x2b5406
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0xc0(%rax,%rcx,8), %rax
cmpq 0x28(%rsp), %rax
jae 0x2b5406
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x88(%rsp), %rcx
addq 0x48(%rsp), %rcx
callq 0x2b5700
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq $0x0, 0xc0(%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2b52e9
movq 0xa0(%rsp), %rax
subq 0x40(%rsp), %rax
subq 0x38(%rsp), %rax
cmpq $0x1, %rax
jbe 0x2b548c
movq 0xa0(%rsp), %rax
subq 0x40(%rsp), %rax
subq 0x38(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
addq 0x40(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x88(%rsp), %rcx
addq $0x20, %rcx
callq 0x2b4530
movq $0x0, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x7c(%rsp), %ecx
cmpq %rcx, %rax
ja 0x2b5627
movq 0x48(%rsp), %rax
movl 0x7c(%rsp), %ecx
cmpq %rcx, %rax
jae 0x2b54d1
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x1c8(%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
jmp 0x2b54db
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x1c0(%rax,%rcx,8), %rax
addq $0x1, %rax
cmpq 0x28(%rsp), %rax
jae 0x2b554e
movq 0x28(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq 0x48(%rsp), %rdx
subq 0x1c0(%rcx,%rdx,8), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
addq 0xa0(%rsp), %rsi
subq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x88(%rsp), %rcx
addq 0x48(%rsp), %rcx
callq 0x2b4530
movq 0xb0(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x2b55fb
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x1c0(%rax,%rcx,8), %rax
cmpq 0x28(%rsp), %rax
jae 0x2b55fb
jmp 0x2b557f
movq 0xa0(%rsp), %rax
cmpq 0x28(%rsp), %rax
jae 0x2b55c6
movq 0x386a0b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x260a74(%rip), %rsi    # 0x516013
leaq 0x2d33a8(%rip), %rdx    # 0x58894e
leaq 0x2d3323(%rip), %rcx    # 0x5888d0
leaq 0x2d2fbc(%rip), %r8     # 0x588570
movl $0x42f, %r9d            # imm = 0x42F
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b55c8
movq 0xb0(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0xa8(%rsp), %rsi
movq 0xa0(%rsp), %rdx
subq 0x28(%rsp), %rdx
movq 0x88(%rsp), %rcx
addq 0x48(%rsp), %rcx
callq 0x2b5700
movq 0xb0(%rsp), %rax
movq 0x48(%rsp), %rcx
movq $0x0, 0x1c0(%rax,%rcx,8)
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
jmp 0x2b5495
addq $0xb8, %rsp
retq
nop