// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/sfx-shortreadsort.c
// Function: gt_shortreadsort_firstcodes_sort
void gt_shortreadsort_firstcodes_sort(GtShortreadsortresult *srsresult,
                                      GtShortreadsortworkinfo *srsw,
                                      const GtSeqnumrelpos *snrp,
                                      const GtEncseq *encseq,
                                      const GtSpmsuftab *spmsuftab,
                                      GtUword subbucketleft,
                                      GtUword width,
                                      GtUword depth,
                                      GtUword maxdepth)
{
  GtUword idx, pos, seqnum, relpos, seqnum_relpos;
  gt_assert(maxdepth == 0 || maxdepth > depth);

  srsw->tbereservoir.nextfreeGtTwobitencoding = 0;
  for (idx = 0; idx < width; idx++)
  {
    if (gt_spmsuftab_usebitsforpositions(spmsuftab))
    {
      pos = gt_spmsuftab_get(spmsuftab,subbucketleft + idx);
      seqnum = gt_encseq_seqnum(encseq,pos);
      relpos = pos - gt_encseq_seqstartpos(encseq,seqnum);
      srsw->shortreadsorttable[idx].suffixrepresentation
        = gt_seqnumrelpos_encode(snrp, seqnum, relpos);
    } else
    {
      seqnum_relpos = gt_spmsuftab_get(spmsuftab,subbucketleft + idx);
      seqnum = gt_seqnumrelpos_decode_seqnum(snrp,seqnum_relpos);
      relpos = gt_seqnumrelpos_decode_relpos(snrp,seqnum_relpos);
      srsw->shortreadsorttable[idx].suffixrepresentation = seqnum_relpos;
    }
    srsw->shortreadsorttable[idx].tbeidx
      = (uint32_t) srsw->tbereservoir.nextfreeGtTwobitencoding;
    srsw->shortreadsorttable[idx].unitsnotspecial
      = gt_encseq_relpos_extract2bitencvector(&srsw->tbereservoir,
                                              encseq,
                                              seqnum,
                                              relpos + depth,
                                              (maxdepth > 0) ?
                                              maxdepth - depth : 0);
  }
  srsw->sumofstoredvalues += srsw->tbereservoir.nextfreeGtTwobitencoding;
  QSORTNAME(gt_inlinedarr_qsort_r) (6UL, false, width, srsw, depth,
                                    subbucketleft);
  for (idx = 0; idx < width; idx++)
  {
    srsw->seqnum_relpos_bucket[idx]
      = srsw->shortreadsorttable[idx].suffixrepresentation;
  }
  srsresult->suftab_bucket = srsw->seqnum_relpos_bucket;
  srsresult->lcptab_bucket = srsw->mediumsizelcpvalues;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, (%rsp)
movq %rdi, 0x30(%rsp)
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rbp
leaq -0x1(%rax), %rcx
cmpq %rbp, %rcx
jb 0x1a8cbd
movq 0x90(%rsp), %r15
andq $0x0, 0x30(%rsi)
movq %rsi, 0x18(%rsp)
leaq 0x20(%rsi), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, %rcx
subq %rbp, %rcx
testq %rax, %rax
cmoveq %rax, %rcx
movq %rcx, 0x38(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
cmpq %rbx, %r15
je 0x1a8c5e
movq %r13, 0x28(%rsp)
movq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x1b2640
movl %eax, %r12d
movq 0x10(%rsp), %rax
movq %rbx, 0x50(%rsp)
leaq (%rax,%rbx), %rsi
movq %r14, %rdi
callq 0x1a8cf5
movq %rax, %rbp
testb %r12b, %r12b
je 0x1a8bdf
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x74c9d
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x74d9c
movq %rbp, %r12
subq %rax, %r12
movq (%rsp), %rdi
movq %r14, 0x20(%rsp)
movq %r14, %rsi
movq %r12, %rdx
callq 0x191cae
movq %rax, %rbp
jmp 0x1a8c06
movq (%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x191c9c
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x191ca6
movq %rax, %r12
movq 0x8(%rsp), %rbx
movq 0x28(%rsp), %r13
movq 0x18(%rsp), %r14
movq (%r14), %rax
movq %rbp, (%rax,%r13)
movl 0x30(%r14), %ecx
movl %ecx, 0x8(%rax,%r13)
movq 0x98(%rsp), %rbp
addq %rbp, %r12
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
movq 0x20(%rsp), %rdx
movq %r12, %rcx
movq 0x38(%rsp), %r8
callq 0x76c48
movq (%r14), %rcx
movl %eax, 0xc(%rcx,%r13)
movq 0x50(%rsp), %rbx
incq %rbx
addq $0x10, %r13
jmp 0x1a8b66
movq 0x18(%rsp), %rbx
movq 0x30(%rbx), %rax
addq %rax, 0x48(%rbx)
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
callq 0x1a7d04
xorl %eax, %eax
subq $0x1, %r15
jb 0x1a8c9b
movq (%rbx), %rcx
movq 0x18(%rbx), %rdx
movq (%rcx,%rax,2), %rcx
movq %rcx, (%rdx,%rax)
addq $0x8, %rax
jmp 0x1a8c80
movdqu 0x10(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movq 0x30(%rsp), %rax
movdqu %xmm0, (%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28f2a4(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x13c345(%rip), %rsi    # 0x2e5013
leaq 0x1b17ad(%rip), %rdx    # 0x35a482
leaq 0x1b17c8(%rip), %rcx    # 0x35a4a4
leaq 0x1b171d(%rip), %r8     # 0x35a400
movl $0x2b9, %r9d            # imm = 0x2B9
xorl %eax, %eax
callq 0x17a50
callq 0x17390