// File: /workspace/github_c_makefile_star2_O1/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 %r9, 0x10(%rsp)
movq %rcx, %r12
movq %rdx, 0x18(%rsp)
movq 0x90(%rsp), %rax
leaq -0x1(%rax), %rcx
cmpq 0x88(%rsp), %rcx
jb 0x1fff0e
movq %rdi, 0x28(%rsp)
movq %rsi, 0x8(%rsp)
movq $0x0, 0x30(%rsi)
cmpq $0x0, 0x80(%rsp)
je 0x1ffe8a
movq %r8, %r15
movq %rax, %rcx
subq 0x88(%rsp), %rcx
testq %rax, %rax
cmoveq %rax, %rcx
movq %rcx, 0x38(%rsp)
movq 0x8(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movq 0x80(%rsp), %r13
movq %r8, 0x40(%rsp)
movq %r15, %rdi
callq 0x2083a2
movq (%r15), %rcx
testb %al, %al
je 0x1ffde0
cmpq %r14, %rcx
ja 0x1ffefa
movq %r14, %rsi
subq %rcx, %rsi
cmpq 0x8(%r15), %rsi
jae 0x1fff04
movq %r13, %rbp
movq 0x20(%r15), %rdi
callq 0xe80ec
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0xefc48
movq %rax, %r13
movq %r12, %rdi
movq %rax, %rsi
callq 0xefce0
subq %rax, %r15
movq 0x18(%rsp), %rdi
movq %r13, 0x20(%rsp)
movq %r13, %rsi
movq %r15, %rdx
callq 0x1ec4d0
movq %r12, %rdx
movq %rax, %r12
jmp 0x1ffe31
cmpq %r14, %rcx
ja 0x1ffeff
movq %r14, %rsi
subq %rcx, %rsi
cmpq 0x8(%r15), %rsi
jae 0x1fff09
movq %r13, %rbp
movq %r12, %r13
movq 0x20(%r15), %rdi
callq 0xe80ec
movq %rax, %r12
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0x1ec4be
movq %rax, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1ec4c8
movq %rax, %r15
movq %r13, %rdx
movq %rbp, %r13
movq 0x8(%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 0x20(%rsp), %rdx
movq %r15, %rcx
movq 0x38(%rsp), %r8
callq 0xf1427
movq (%rbp), %rcx
movl %eax, 0xc(%rcx,%rbx)
addq $0x10, %rbx
incq %r14
decq %r13
movq 0x40(%rsp), %r15
jne 0x1ffd70
movq 0x8(%rsp), %rbx
movq 0x30(%rbx), %rax
addq %rax, 0x48(%rbx)
movq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq 0x88(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x1feeb8
testq %r14, %r14
je 0x1ffed8
movq (%rbx), %rax
movq 0x18(%rbx), %rcx
xorl %edx, %edx
movq (%rax), %rsi
movq %rsi, (%rcx,%rdx,8)
incq %rdx
addq $0x10, %rax
cmpq %rdx, %r14
jne 0x1ffec5
movdqu 0x10(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movq 0x28(%rsp), %rax
movdqu %xmm0, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x7dc7b
callq 0x7dc0d
callq 0x7dc44
callq 0x7dbd6
callq 0x7dcb2