// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/randomcodes.c
// Function: gt_randomcodes_sortremaining
static int gt_randomcodes_sortremaining(GtShortreadsortworkinfo *srsw,
                                       const GtEncseq *encseq,
                                       GtReadmode readmode,
                                       const GtSpmsuftab *spmsuftab,
                                       const GtSeqnumrelpos *snrp,
                                       const GtRandomcodestab *rct,
                                       const GtUword *allrandomcodes,
                                       GtUword minindex,
                                       GtUword maxindex,
                                       GtUword sumofwidth,
                                       unsigned int sortingdepth,
                                       unsigned int bucketkeysize,
                                       GtRandomcodesintervalprocess itvprocess,
                                       GtRandomcodesintervalprocess_end
                                              itvprocess_end,
                                       void *itvprocessdata,
                                       bool withsuftabcheck,
                                       GtError *err)
{
  GtUword current,
                next = GT_UNDEF_UWORD,
                idx,
                width,
                GT_UNUSED sumwidth = 0,
                previoussuffix = 0;
  GtShortreadsortresult srsresult;
  bool previousdefined = false, haserr = false;

  gt_assert(allrandomcodes != NULL);
  current = gt_randomcodes_get_leftborder(rct, minindex);
  for (idx = minindex; idx <= maxindex; idx++)
  {
    if (idx < maxindex)
    {
      next = gt_randomcodes_get_leftborder(rct, idx+1);
      gt_assert(current <= next);
      width = next - current;
    } else
    {
      gt_assert(sumofwidth >= current);
      width = sumofwidth - current;
    }
    sumwidth += width;
    gt_assert(sumwidth <= spmsuftab->numofentries);
    if (width >= 2UL)
    {
      GtUword lcpvalue = 0;
      if (idx > minindex)
      {
        lcpvalue = gt_randomcodes_codelcp(allrandomcodes[idx - 1],
            allrandomcodes[idx]);
        gt_assert(lcpvalue >=
            (GtUword)(GT_UNITSIN2BITENC - bucketkeysize));
        lcpvalue -= (GT_UNITSIN2BITENC - (GtUword) bucketkeysize);
      }
      gt_assert(lcpvalue < (GtUword)GT_UNITSIN2BITENC);
      gt_shortreadsort_firstcodes_sort(&srsresult,
                                       srsw,
                                       snrp,
                                       encseq,
                                       spmsuftab,
                                       current,
                                       width,
                                       lcpvalue,
                                       (GtUword)sortingdepth);
      if (withsuftabcheck)
      {
        gt_randomcodes_checksuftab_bucket(encseq,
                                         readmode,
                                         NULL,
                                         NULL,
                                         previoussuffix,
                                         previousdefined,
                                         srsresult.suftab_bucket,
                                         snrp,
                                         srsresult.lcptab_bucket,
                                         width);
        previousdefined = true;
        previoussuffix
          = gt_seqnumrelpos_decode_pos(snrp, srsresult.suftab_bucket[width-1]);
      }
      if (itvprocess != NULL)
      {
        if (itvprocess(itvprocessdata,
                       srsresult.suftab_bucket,
                       snrp, srsresult.lcptab_bucket, width,
                       sortingdepth, err) != 0)
        {
          haserr = true;
          break;
        }
      }
    }
    else if (width == 1UL)
    {
      if (itvprocess != NULL)
      {
        GtUword suftab_value = gt_spmsuftab_get(spmsuftab, current);
        const uint16_t lcptab_value = 0;
        if (gt_spmsuftab_usebitsforpositions(spmsuftab))
        {
          GtUword seqnum, relpos;
          seqnum = gt_encseq_seqnum(encseq, suftab_value);
          relpos = suftab_value - gt_encseq_seqstartpos(encseq, seqnum);
          suftab_value = gt_seqnumrelpos_encode(snrp, seqnum, relpos);
        }
        if (itvprocess(itvprocessdata, &suftab_value, snrp, &lcptab_value, 1UL,
                       sortingdepth, err) != 0)
        {
          haserr = true;
          break;
        }
      }
    }
    gt_assert((minindex == maxindex) || next != GT_UNDEF_UWORD);
    current = next;
  }
  if (itvprocess_end != NULL)
  {
    itvprocess_end(itvprocessdata);
  }
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x38(%rsp)
movl %edx, 0x5c(%rsp)
movq %rdi, 0x90(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x171fa4
movq %rsi, %r12
movl 0x108(%rsp), %ebx
movq 0xf0(%rsp), %r15
movq 0xe8(%rsp), %r13
movq %r9, 0x98(%rsp)
movq %r9, %rdi
movq %r13, %rsi
callq 0x2c6299
movq %rax, %r14
movq %r15, %rax
pushq $0x20
popq %rcx
subl %ebx, %ecx
movq %rcx, 0x80(%rsp)
movl %ebx, %ecx
addq $-0x20, %rcx
movq %rcx, 0x78(%rsp)
pushq $-0x1
popq %rbp
movq %r13, %rdi
xorl %r15d, %r15d
movq $0x0, 0x40(%rsp)
xorl %r13d, %r13d
movq %r12, 0x50(%rsp)
cmpq %rax, %rdi
ja 0x171d5d
jae 0x1719df
leaq 0x1(%rdi), %rsi
movq %rdi, %rbx
movq 0x98(%rsp), %rdi
callq 0x2c6299
movq %rbx, %rdi
movq %rax, %r12
movq %rax, %rbp
cmpq %rax, %r14
jbe 0x1719f3
jmp 0x171e55
movq 0xf8(%rsp), %rax
movq %rax, %r12
cmpq %rax, %r14
ja 0x171e86
subq %r14, %r12
addq %r12, %r15
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
cmpq %rax, %r15
ja 0x171e24
cmpq $0x2, %r12
jb 0x171a5f
cmpq 0xe8(%rsp), %rdi
movq %rdi, 0x60(%rsp)
jbe 0x171b4d
movq 0xe0(%rsp), %rax
movq (%rax,%rdi,8), %rcx
xorq -0x8(%rax,%rdi,8), %rcx
xorl %eax, %eax
movabsq $-0x4000000000000000, %rdx # imm = 0xC000000000000000
testq %rdx, %rdx
je 0x171b51
movq %rdx, %rsi
andq %rcx, %rsi
jne 0x171b51
shrq $0x2, %rdx
incq %rax
jmp 0x171a41
cmpq $0x0, 0x110(%rsp)
je 0x171d03
cmpq $0x1, %r12
jne 0x171d03
movq %r15, 0x48(%rsp)
movq 0x38(%rsp), %rcx
subq (%rcx), %r14
movq 0x50(%rsp), %r12
jb 0x171ee1
cmpq %rax, %r14
jae 0x171eb7
movq %rbp, %r15
movq %rdi, %rbp
movq 0x38(%rsp), %rbx
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x6bb8d
movq %rax, 0x30(%rsp)
andw $0x0, 0x26(%rsp)
movq %rbx, %rdi
callq 0x1b2640
testb %al, %al
je 0x171aff
movq 0x30(%rsp), %rsi
movq %r12, %rdi
callq 0x74c9d
movq %rax, %rbx
movq 0x30(%rsp), %r14
movq %r12, %rdi
movq %rax, %rsi
callq 0x74d9c
subq %rax, %r14
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x191cae
movq %rax, 0x30(%rsp)
movq 0x130(%rsp), %rax
movq %rax, (%rsp)
movq 0x120(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x26(%rsp), %rcx
pushq $0x1
popq %r8
movl 0x100(%rsp), %r9d
callq *0x110(%rsp)
testl %eax, %eax
movq %rbp, %rdi
movq %r15, %rbp
movq 0x48(%rsp), %r15
je 0x171d03
jmp 0x171d61
xorl %eax, %eax
jmp 0x171b6e
cmpq 0x80(%rsp), %rax
jb 0x171f6c
addq 0x78(%rsp), %rax
cmpq $0x20, %rax
jae 0x171f3e
movl 0x100(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq %r12, (%rsp)
leaq 0x68(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x50(%rsp), %rbx
movq %rbx, %rcx
movq 0x38(%rsp), %r8
movq %r14, %r9
callq 0x1a8af1
cmpb $0x0, 0x128(%rsp)
je 0x171cb5
movq %r15, 0x48(%rsp)
movq %rbp, 0x88(%rsp)
movq 0x68(%rsp), %r15
movq 0x70(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
callq 0x7055e
movq %rax, %r14
cmpq 0x40(%rsp), %rax
setbe %al
testb %al, %r13b
jne 0x171f10
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x171c8c
movq (%r15,%rbp,8), %rsi
movq 0x28(%rsp), %rdi
callq 0x191c81
movq %rax, %rbx
cmpq %r14, %rbp
setb %al
andb %al, %r13b
cmpb $0x1, %r13b
jne 0x171c7c
cmpq %r14, %rbx
jae 0x171d91
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movq 0x40(%rsp), %rax
movq %rax, (%rsp)
movq 0x50(%rsp), %rdi
movl 0x5c(%rsp), %esi
leaq 0x30(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x77ebd
testl %eax, %eax
jg 0x171dc2
testq %rbp, %rbp
je 0x171c7c
movq 0xa0(%rsp), %rax
movzwl (%rax,%rbp,2), %eax
cmpq %rax, 0x30(%rsp)
jne 0x171df3
incq %rbp
movb $0x1, %r13b
movq %rbx, 0x40(%rsp)
jmp 0x171bf5
movq 0x68(%rsp), %rax
movq -0x8(%rax,%r12,8), %rsi
movq 0x28(%rsp), %rdi
callq 0x191c81
movq %rax, 0x40(%rsp)
movb $0x1, %r13b
movq 0x88(%rsp), %rbp
movq 0x48(%rsp), %r15
movq 0x110(%rsp), %r10
testq %r10, %r10
je 0x171cfe
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rcx
movq 0x130(%rsp), %rax
movq %rax, (%rsp)
movq 0x120(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq %r12, %r8
movl 0x100(%rsp), %r9d
callq *%r10
testl %eax, %eax
movq 0x60(%rsp), %rdi
je 0x171d03
jmp 0x171d61
movq 0x60(%rsp), %rdi
incq %rdi
movq %rbp, %r14
movq 0xf0(%rsp), %rax
cmpq %rax, 0xe8(%rsp)
je 0x1719ad
movq %rbp, %r14
cmpq $-0x1, %rbp
jne 0x1719ad
movq 0x2c6235(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1732d6(%rip), %rsi    # 0x2e5013
leaq 0x1dafdf(%rip), %rdx    # 0x34cd23
leaq 0x1daf36(%rip), %rcx    # 0x34cc81
leaq 0x1da69b(%rip), %r8     # 0x34c3ed
movl $0x23c, %r9d            # imm = 0x23C
jmp 0x171f98
xorl %ebx, %ebx
jmp 0x171d66
pushq $-0x1
popq %rax
movl %eax, %ebx
movq 0x118(%rsp), %rax
testq %rax, %rax
je 0x171d7d
movq 0x120(%rsp), %rdi
callq *%rax
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c61d0(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x173271(%rip), %rsi    # 0x2e5013
leaq 0x1d4aaa(%rip), %rdx    # 0x346853
leaq 0x1dafa4(%rip), %rcx    # 0x34cd54
leaq 0x1da636(%rip), %r8     # 0x34c3ed
movl $0x1a9, %r9d            # imm = 0x1A9
jmp 0x171f98
movq 0x2c619f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x173240(%rip), %rsi    # 0x2e5013
leaq 0x1d4a8f(%rip), %rdx    # 0x346869
leaq 0x1daf73(%rip), %rcx    # 0x34cd54
leaq 0x1da605(%rip), %r8     # 0x34c3ed
movl $0x1b4, %r9d            # imm = 0x1B4
jmp 0x171f98
movq 0x2c616e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17320f(%rip), %rsi    # 0x2e5013
leaq 0x1d4a67(%rip), %rdx    # 0x346872
leaq 0x1daf42(%rip), %rcx    # 0x34cd54
leaq 0x1da5d4(%rip), %r8     # 0x34c3ed
movl $0x1b5, %r9d            # imm = 0x1B5
jmp 0x171f98
movq 0x2c613d(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1731de(%rip), %rsi    # 0x2e5013
leaq 0x1d4994(%rip), %rdx    # 0x3467d0
leaq 0x1dae3e(%rip), %rcx    # 0x34cc81
leaq 0x1da5a3(%rip), %r8     # 0x34c3ed
movl $0x1f5, %r9d            # imm = 0x1F5
jmp 0x171f98
movq 0x2c610c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1731ad(%rip), %rsi    # 0x2e5013
leaq 0x1dae31(%rip), %rdx    # 0x34cc9e
leaq 0x1dae0d(%rip), %rcx    # 0x34cc81
leaq 0x1da572(%rip), %r8     # 0x34c3ed
movl $0x1ed, %r9d            # imm = 0x1ED
jmp 0x171f98
movq 0x2c60db(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17317c(%rip), %rsi    # 0x2e5013
leaq 0x1dae10(%rip), %rdx    # 0x34ccae
leaq 0x1daddc(%rip), %rcx    # 0x34cc81
leaq 0x1da541(%rip), %r8     # 0x34c3ed
movl $0x1f1, %r9d            # imm = 0x1F1
jmp 0x171f98
movq 0x2c60aa(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17314b(%rip), %rsi    # 0x2e5013
leaq 0x1daeb8(%rip), %rdx    # 0x34cd87
leaq 0x1daea0(%rip), %rcx    # 0x34cd76
leaq 0x1dac2f(%rip), %r8     # 0x34cb0c
pushq $0x31
jmp 0x171f09
movq 0x2c6080(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x173121(%rip), %rsi    # 0x2e5013
leaq 0x1d4620(%rip), %rdx    # 0x346519
leaq 0x1dae76(%rip), %rcx    # 0x34cd76
leaq 0x1dac05(%rip), %r8     # 0x34cb0c
pushq $0x2f
popq %r9
jmp 0x171f98
movq 0x2c6051(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1730f2(%rip), %rsi    # 0x2e5013
leaq 0x1d48d9(%rip), %rdx    # 0x346801
leaq 0x1dae25(%rip), %rcx    # 0x34cd54
leaq 0x1da4b7(%rip), %r8     # 0x34c3ed
movl $0x1a3, %r9d            # imm = 0x1A3
jmp 0x171f98
movq 0x2c6023(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1730c4(%rip), %rsi    # 0x2e5013
leaq 0x1dada7(%rip), %rdx    # 0x34ccfd
leaq 0x1dad24(%rip), %rcx    # 0x34cc81
leaq 0x1da489(%rip), %r8     # 0x34c3ed
movl $0x201, %r9d            # imm = 0x201
jmp 0x171f98
movq 0x2c5ff5(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x173096(%rip), %rsi    # 0x2e5013
leaq 0x1dad40(%rip), %rdx    # 0x34ccc4
leaq 0x1dacf6(%rip), %rcx    # 0x34cc81
leaq 0x1da45b(%rip), %r8     # 0x34c3ed
movl $0x1fe, %r9d            # imm = 0x1FE
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2c5fbd(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x17305e(%rip), %rsi    # 0x2e5013
leaq 0x1da4c3(%rip), %rdx    # 0x34c47f
leaq 0x1dacbe(%rip), %rcx    # 0x34cc81
leaq 0x1da423(%rip), %r8     # 0x34c3ed
movl $0x1e6, %r9d            # imm = 0x1E6
jmp 0x171f98