// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rcx, %r12
movq %rdx, 0x8(%rsp)
movq 0x90(%rsp), %rax
leaq -0x1(%rax), %rcx
cmpq 0x88(%rsp), %rcx
jb 0x1f6799
movq %rsi, %r14
movq %rdi, %rbx
movq 0x80(%rsp), %r13
movq $0x0, 0x30(%rsi)
testq %r13, %r13
je 0x1f6751
movq %r8, %r15
movq %rbx, 0x28(%rsp)
movq %rax, %rcx
subq 0x88(%rsp), %rcx
testq %rax, %rax
cmoveq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x20(%r14), %rax
movq %rax, 0x30(%rsp)
xorl %ebx, %ebx
movq %r9, 0x20(%rsp)
movq %r9, %r14
movq %r8, 0x40(%rsp)
movq %r15, %rdi
callq 0x1fec06
movq (%r15), %rcx
testb %al, %al
je 0x1f6654
cmpq %r14, %rcx
ja 0x1f6785
movq %r14, %rsi
subq %rcx, %rsi
cmpq 0x8(%r15), %rsi
jae 0x1f678f
movq %r13, %rbp
movq 0x20(%r15), %rdi
callq 0xe3c2c
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0xeb655
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
callq 0xeb6ee
subq %rax, %r15
movq 0x8(%rsp), %rdi
movq %r13, 0x18(%rsp)
movq %r13, %rsi
movq %r15, %rdx
callq 0x1e2c40
movq %r12, %rdx
movq %rax, %r12
jmp 0x1f66a5
cmpq %r14, %rcx
ja 0x1f678a
movq %r14, %rsi
subq %rcx, %rsi
cmpq 0x8(%r15), %rsi
jae 0x1f6794
movq %r13, %rbp
movq %r12, %r13
movq 0x20(%r15), %rdi
callq 0xe3c2c
movq %rax, %r12
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1e2c2e
movq %rax, 0x18(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1e2c38
movq %rax, %r15
movq %r13, %rdx
movq %rbp, %r13
movq 0x10(%rsp), %rbp
movq (%rbp), %rax
movq %r12, (%rax,%rbx)
movl 0x30(%rbp), %ecx
movl %ecx, 0x8(%rax,%rbx)
addq 0x88(%rsp), %r15
movq 0x30(%rsp), %rdi
movq %rdx, %r12
movq %rdx, %rsi
movq 0x18(%rsp), %rdx
movq %r15, %rcx
movq 0x38(%rsp), %r8
callq 0xece27
movq (%rbp), %rcx
movl %eax, 0xc(%rcx,%rbx)
addq $0x10, %rbx
incq %r14
decq %r13
movq 0x40(%rsp), %r15
jne 0x1f65e4
movq 0x10(%rsp), %r14
movq 0x30(%r14), %rax
addq %rax, 0x48(%r14)
movq 0x80(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq 0x88(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x1f573b
movq %rbx, %rdi
movq (%r14), %rcx
movq 0x18(%r14), %rax
xorl %edx, %edx
movq 0x28(%rsp), %rbx
movq (%rcx), %rsi
movq %rsi, (%rax,%rdx,8)
incq %rdx
addq $0x10, %rcx
cmpq %rdx, %rdi
jne 0x1f673c
jmp 0x1f676b
movq %r13, %rdi
movq %r14, %rsi
movq 0x88(%rsp), %rdx
movq %r9, %rcx
callq 0x1f573b
movq 0x18(%r14), %rax
movq %rax, (%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x8(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7bf1c
callq 0x7beae
callq 0x7bee5
callq 0x7be77
callq 0x7bf53