// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/sfx-bentsedg.c
// Function: bs_insertionsort
static void bs_insertionsort(GtBentsedgresources *bsr,
                             GtUword subbucketleft,
                             GtUword width,
                             GtUword offset)
{
  GtUword sval1, sval2, pm, pl, startpos1, startpos2, lcplen = 0;
  int retval;
  GtCommonunits commonunits;

  bsr->countinsertionsort++;
  for (pm = 1UL; pm < width; pm++)
  {
    for (pl = pm; pl > 0; pl--)
    {
      sval1 = gt_suffixsortspace_get(bsr->sssp,subbucketleft,pl-1);
      sval2 = gt_suffixsortspace_get(bsr->sssp,subbucketleft,pl);
      if (bsr->sfxstrategy->cmpcharbychar)
      {
        startpos1 = sval1 + offset;
        if (startpos1 < bsr->totallength)
        {
          gt_encseq_reader_reinit_with_readmode(bsr->esr1, bsr->encseq,
                                                bsr->readmode, startpos1);
        }
        startpos2 = sval2 + offset;
        if (startpos2 < bsr->totallength)
        {
          gt_encseq_reader_reinit_with_readmode(bsr->esr2, bsr->encseq,
                                                bsr->readmode, startpos2);
        }
        for (;;)
        {
          GtUword ccs, cct;
          GtUchar tmp1, tmp2;

          ccs = DEREFSEQ(tmp1,startpos1,bsr->esr1);
          cct = DEREFSEQ(tmp2,startpos2,bsr->esr2);
          if (ccs != cct)
          {
            lcplen = startpos2 - sval2;
            retval = (ccs < cct) ? -1 : 1;
            break;
          }
          startpos1++;
          startpos2++;
        }
      } else
      {
#ifdef SKDEBUG
        printf("%s["GT_WU","GT_WU"] at offset"
               GT_WU"\n",__func__,sval1,sval2,offset);
        gt_encseq_showatstartpos(stdout,
                                 bsr->fwd,
                                 bsr->complement,
                                 bsr->encseq,
                                 sval1);
        gt_encseq_showatstartpos(stdout,
                                 bsr->fwd,
                                 bsr->complement,
                                 bsr->encseq,
                                 sval2);
#endif
        retval = gt_encseq_compare_viatwobitencoding(&commonunits,
                                                     bsr->encseq,
                                                     bsr->encseq,
                                                     bsr->readmode,
                                                     bsr->esr1,
                                                     bsr->esr2,
                                                     sval1,
                                                     sval2,
                                                     offset,
                                                     0);
        lcplen = commonunits.finaldepth;
      }
      gt_assert(retval != 0);
      if (bsr->tableoflcpvalues != NULL)
      {
        if (pl < pm && retval > 0)
        {
          gt_lcptab_update(bsr->tableoflcpvalues,subbucketleft,pl+1,
                           gt_lcptab_getvalue(bsr->tableoflcpvalues,
                                              subbucketleft,pl));
        }
        gt_lcptab_update(bsr->tableoflcpvalues,subbucketleft,pl,lcplen);
      }
      if (retval < 0)
      {
        break;
      }
      gt_suffixsortspace_set(bsr->sssp,subbucketleft,pl-1,sval2);
      gt_suffixsortspace_set(bsr->sssp,subbucketleft,pl,sval1);
    }
  }
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, 0xc8(%rsp)
movq %rsi, 0xc0(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rcx, 0xb0(%rsp)
movq $0x0, 0x78(%rsp)
movq 0xc8(%rsp), %rax
movq 0x68(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x68(%rax)
movq $0x1, 0x98(%rsp)
movq 0x98(%rsp), %rax
cmpq 0xb8(%rsp), %rax
jae 0x2b5eba
movq 0x98(%rsp), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x90(%rsp)
jbe 0x2b5e9f
movq 0xc8(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
callq 0x2e9ec0
movq %rax, 0xa8(%rsp)
movq 0xc8(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x2e9ec0
movq %rax, 0xa0(%rsp)
movq 0xc8(%rsp), %rax
movq 0x40(%rax), %rax
testb $0x1, 0x2c(%rax)
je 0x2b5ca9
movq 0xa8(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x2b5b12
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rdi
movq 0xc8(%rsp), %rax
movq (%rax), %rsi
movq 0xc8(%rsp), %rax
movl 0x18(%rax), %edx
movq 0x88(%rsp), %rcx
callq 0xabdb0
movq 0xa0(%rsp), %rax
addq 0xb0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x2b5b72
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0xc8(%rsp), %rax
movq (%rax), %rsi
movq 0xc8(%rsp), %rax
movl 0x18(%rax), %edx
movq 0x80(%rsp), %rcx
callq 0xabdb0
jmp 0x2b5b74
movq 0x88(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x2b5bb8
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0xaae30
movb %al, 0x4f(%rsp)
movzbl %al, %eax
cmpl $0xfe, %eax
jge 0x2b5bb8
movzbl 0x4f(%rsp), %eax
movq %rax, 0x40(%rsp)
jmp 0x2b5bcb
movq 0x88(%rsp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x80(%rsp), %rax
movq 0xc8(%rsp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x2b5c19
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0xaae30
movb %al, 0x4e(%rsp)
movzbl %al, %eax
cmpl $0xfe, %eax
jge 0x2b5c19
movzbl 0x4e(%rsp), %eax
movq %rax, 0x38(%rsp)
jmp 0x2b5c2c
movq 0x80(%rsp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
cmpq 0x50(%rsp), %rax
je 0x2b5c77
movq 0x80(%rsp), %rax
subq 0xa0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rsi
movl $0x1, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rsi, %rdx
cmovbl %ecx, %eax
movl %eax, 0x74(%rsp)
jmp 0x2b5ca4
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x2b5b74
jmp 0x2b5d2b
movq 0xc8(%rsp), %rax
movq (%rax), %rsi
movq 0xc8(%rsp), %rax
movq (%rax), %rdx
movq 0xc8(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0xc8(%rsp), %rax
movq 0x8(%rax), %r8
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %r9
movq 0xa8(%rsp), %r11
movq 0xa0(%rsp), %r10
movq 0xb0(%rsp), %rax
leaq 0x60(%rsp), %rdi
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
callq 0xb53f0
movl %eax, 0x74(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x78(%rsp)
jmp 0x2b5d2d
cmpl $0x0, 0x74(%rsp)
jne 0x2b5d6c
movq 0x386265(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2602ce(%rip), %rsi    # 0x516013
leaq 0x2d2987(%rip), %rdx    # 0x5886d3
leaq 0x2d298c(%rip), %rcx    # 0x5886df
leaq 0x2d2816(%rip), %r8     # 0x588570
movl $0x15a, %r9d            # imm = 0x15A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x2b5d6e
movq 0xc8(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x2b5e27
movq 0x90(%rsp), %rax
cmpq 0x98(%rsp), %rax
jae 0x2b5e01
cmpl $0x0, 0x74(%rsp)
jle 0x2b5e01
movq 0xc8(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
movq 0xc8(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x2b6840
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %rax, %rcx
callq 0x2b5700
movq 0xc8(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0x2b5700
cmpl $0x0, 0x74(%rsp)
jge 0x2b5e30
jmp 0x2b5e9f
movq 0xc8(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
subq $0x1, %rdx
movq 0xa0(%rsp), %rcx
callq 0x2ea0a0
movq 0xc8(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0xc0(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq 0xa8(%rsp), %rcx
callq 0x2ea0a0
movq 0x90(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x2b5a37
jmp 0x2b5ea1
movq 0x98(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x98(%rsp)
jmp 0x2b5a11
addq $0xd0, %rsp
popq %rbx
retq
nopw %cs:(%rax,%rax)