// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/rdj-contfinder.c
// Function: gt_contfinder_insertion_sort
static inline void gt_contfinder_insertion_sort(
    const GtContfinder contfinder, GtContfinderBucketInfo bucket)
{
  size_t i, j;
  gt_contfinder_seqnum_t u, v, container;
  int uvcmp;

  gt_assert(bucket.nofseqs > (gt_contfinder_seqnum_t)1);

  for (i = (size_t)1; i < bucket.nofseqs; i++)
  {
    gt_contfinder_seqnum_t ucorrected;
    size_t ulen = 0;
    u = GT_READJOINER_CONTFINDER_GET_SEQNUM(bucket.seqnums,
        i + bucket.seqnums_offset);
    ucorrected = u;
    if (ucorrected >= contfinder.nofseqs)
      ucorrected = (contfinder.nofseqs << 1) - 1 - ucorrected;
    if (contfinder.len == 0)
    {
      ulen = (ucorrected > 0) ? contfinder.seppos[ucorrected] -
        contfinder.seppos[ucorrected - 1] : contfinder.seppos[ucorrected] + 1;
    }
    for (j = i; j > 0; j--)
    {
      size_t len = contfinder.len;
      size_t pos;
      size_t vlen = 0;
      gt_contfinder_seqnum_t vcorrected;
      GtContfinderKmercodeWithOverflow unk = {0, 0}, vnk = {0, 0};
      v = GT_READJOINER_CONTFINDER_GET_SEQNUM(bucket.seqnums, j - 1 +
          bucket.seqnums_offset);
      vcorrected = v;
      if (vcorrected >= contfinder.nofseqs)
        vcorrected = (contfinder.nofseqs << 1) - 1 - vcorrected;
      if (len == 0)
      {
        vlen = (vcorrected > 0) ? contfinder.seppos[vcorrected] -
          contfinder.seppos[vcorrected - 1] : contfinder.seppos[vcorrected] + 1;
        len = GT_MIN(ulen, vlen);
      }
      for (pos = bucket.depth, uvcmp = 0; uvcmp == 0 && pos < len;
          pos += GT_CONTFINDER_KMERSIZE)
      {
        unk = gt_contfinder_get_code(contfinder.twobitencoding, u,
            pos, contfinder.nofseqs, contfinder.len,
            contfinder.seppos);
        vnk = gt_contfinder_get_code(contfinder.twobitencoding, v,
            pos, contfinder.nofseqs, contfinder.len,
            contfinder.seppos);
        uvcmp = (int)vnk.code - (int)unk.code;
      }
      if (ulen > vlen)
      {
        unsigned short shift = (unsigned short)
          ((vnk.overflow - unk.overflow) << 1);
        uvcmp = (int)(vnk.code >> shift) - (int)(unk.code >> shift);
        if (uvcmp == 0)
        {
          /* v is contained in u */
          GT_SETIBIT(contfinder.contained, vcorrected);
          break;
        }
      }
      else if (ulen < vlen)
      {
        unsigned short shift = (unsigned short)
          ((unk.overflow - vnk.overflow) << 1);
        uvcmp = (int)(vnk.code >> shift) - (int)(unk.code >> shift);
        if (uvcmp == 0)
        {
          /* u is contained in v */
          GT_SETIBIT(contfinder.contained, ucorrected);
          break;
        }
      }
      if (uvcmp < 0)
      {
        break;
      }
      if (uvcmp == 0)
      {
        if (ucorrected > vcorrected)
        {
          GT_SETIBIT(contfinder.contained, ucorrected);
          break;
        }
      }
      GT_READJOINER_CONTFINDER_SET_SEQNUM(bucket.seqnums,
          j + bucket.seqnums_offset, v);
    }
    GT_READJOINER_CONTFINDER_SET_SEQNUM(bucket.seqnums,
        j + bucket.seqnums_offset, u);
  }

  container = GT_READJOINER_CONTFINDER_GET_SEQNUM(bucket.seqnums,
        bucket.seqnums_offset);
  if (container >= contfinder.nofseqs)
    container = (contfinder.nofseqs << 1) - 1 - container;
  for (i = (size_t)1; i < bucket.nofseqs; i++)
  {
    u = GT_READJOINER_CONTFINDER_GET_SEQNUM(bucket.seqnums,
        i + bucket.seqnums_offset);
    if (u >= contfinder.nofseqs)
      u = (contfinder.nofseqs << 1) - 1 - u;
    if (GT_ISIBITSET(contfinder.contained, u))
    {
      GT_CONTFINDER_CONTAINS(&contfinder, container, u);
    }
    else
    {
      container = u;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl 0x150(%rsp), %eax
movq %rax, 0x60(%rsp)
cmpq $0x2, %rax
jb 0x175bf8
leaq 0x140(%rsp), %rax
leaq 0xf0(%rsp), %rdx
movq (%rax), %rcx
movq 0x8(%rax), %rsi
movq %rcx, 0x90(%rsp)
movq %rsi, 0x70(%rsp)
leaq (%rcx,%rsi,4), %rcx
movq %rcx, 0x38(%rsp)
movl 0xc(%rdx), %ecx
movq %rcx, 0x20(%rsp)
addl %ecx, %ecx
movl %ecx, 0xc(%rsp)
movq 0x18(%rdx), %r14
movq 0x20(%rdx), %rcx
movq %rcx, 0x18(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x88(%rsp)
movq (%rdx), %rax
movq %rax, 0xb0(%rsp)
movq 0x10(%rdx), %rax
movq %rax, 0x58(%rsp)
pushq $0x1
popq %rax
movq %r14, 0x50(%rsp)
movq 0xb0(%rsp), %r12
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r13
cmpq 0x60(%rsp), %rax
je 0x175aee
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %ecx
movq 0x10(%rsp), %rax
movl %ecx, %edx
notl %edx
addl 0xc(%rsp), %edx
cmpl 0x20(%rsp), %ecx
movl %ecx, 0x2c(%rsp)
cmovbl %ecx, %edx
testq %r14, %r14
movq %rdx, 0x48(%rsp)
je 0x1758cc
movq $0x0, 0x40(%rsp)
jmp 0x1758fe
testl %edx, %edx
je 0x1758e9
movl %edx, %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leal -0x1(%rdx), %eax
subq (%rcx,%rax,8), %rsi
movq %rsi, 0x40(%rsp)
jmp 0x1758f9
movq 0x18(%rsp), %rax
movq (%rax), %rax
incq %rax
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq %rax, %r8
movq %rax, %rcx
subq $0x1, %rcx
jb 0x175ad4
movq 0x90(%rsp), %rax
leaq (%rax,%r8,4), %rdx
movq 0x70(%rsp), %rax
movq %rdx, 0x98(%rsp)
movl -0x4(%rdx,%rax,4), %eax
movl %eax, %edx
notl %edx
addl 0xc(%rsp), %edx
cmpl 0x20(%rsp), %eax
movl %eax, 0x30(%rsp)
cmovbl %eax, %edx
testq %r14, %r14
movq %r8, 0xa8(%rsp)
movq %rcx, 0xa0(%rsp)
movq %rdx, 0x68(%rsp)
je 0x17596b
movq %r14, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
jmp 0x1759a7
testl %edx, %edx
je 0x175983
movl %edx, %eax
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leal -0x1(%rdx), %eax
subq (%rcx,%rax,8), %rsi
jmp 0x17598e
movq 0x18(%rsp), %rax
movq (%rax), %rsi
incq %rsi
movq 0x40(%rsp), %rax
cmpq %rsi, %rax
movq %rsi, 0x78(%rsp)
cmovbq %rax, %rsi
movq %rsi, 0x80(%rsp)
xorl %esi, %esi
movq 0x88(%rsp), %rbp
xorl %ebx, %ebx
movl $0x0, 0x34(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
testl %esi, %esi
jne 0x175a27
cmpq 0x80(%rsp), %rbp
jae 0x175a27
movq %r12, %rdi
movl 0x2c(%rsp), %esi
movq %rbp, %rdx
movl %r15d, %ecx
movq 0x50(%rsp), %r14
movq %r14, %r8
movq %r13, %r9
callq 0x1754e2
movl %eax, %ebx
movl %ebx, %eax
shrl $0x8, %eax
movl %eax, 0x34(%rsp)
movq %r12, %rdi
movl 0x30(%rsp), %esi
movq %rbp, %rdx
movl %r15d, %ecx
movq %r14, %r8
movq %r13, %r9
callq 0x1754e2
movl %eax, %ecx
shrl $0x8, %ecx
movl %eax, %esi
movl $0xff, %edi
andl %edi, %esi
movl %ebx, %edx
andl %edi, %edx
subl %edx, %esi
addq $0x4, %rbp
jmp 0x1759bf
movzbl %cl, %ecx
movzbl 0x34(%rsp), %edx
movzbl %al, %eax
movzbl %bl, %edi
movq 0x78(%rsp), %r8
cmpq %r8, 0x40(%rsp)
movq 0xa8(%rsp), %r8
jbe 0x175a5e
subl %edx, %ecx
addl %ecx, %ecx
shrl %cl, %eax
shrl %cl, %edi
subl %edi, %eax
movl %eax, %esi
movq 0x50(%rsp), %r14
jne 0x175a75
jmp 0x175aaa
movq 0x50(%rsp), %r14
jae 0x175a75
subl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
shrl %cl, %eax
shrl %cl, %edi
subl %edi, %eax
movl %eax, %esi
je 0x175ab4
testl %esi, %esi
movq 0xa0(%rsp), %rcx
js 0x175ad4
jne 0x175a8e
movq 0x68(%rsp), %rax
cmpl %eax, 0x48(%rsp)
ja 0x175ab4
movq 0x70(%rsp), %rax
movq 0x98(%rsp), %rdx
movl 0x30(%rsp), %esi
movl %esi, (%rdx,%rax,4)
movq %rcx, %r8
jmp 0x175904
movq 0x68(%rsp), %rax
movq %rax, 0x48(%rsp)
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq 0x48(%rsp), %rdx
movl %edx, %ecx
shrq %cl, %rax
shrl $0x6, %edx
movq 0x58(%rsp), %rcx
orq %rax, (%rcx,%rdx,8)
movq 0x38(%rsp), %rax
movl 0x2c(%rsp), %ecx
movl %ecx, (%rax,%r8,4)
movq 0x10(%rsp), %rax
incq %rax
jmp 0x175882
movq 0x38(%rsp), %rax
movl (%rax), %ecx
movl %ecx, %eax
notl %eax
addl 0xc(%rsp), %eax
cmpl 0x20(%rsp), %ecx
cmovbl %ecx, %eax
leaq 0xf0(%rsp), %rcx
movq 0x40(%rcx), %rsi
pushq $0x1
popq %rdi
movabsq $-0x8000000000000000, %r11 # imm = 0x8000000000000000
movq 0x58(%rsp), %rbx
cmpq %rdi, 0x60(%rsp)
je 0x175bae
movq 0x38(%rsp), %rcx
movl (%rcx,%rdi,4), %ecx
movl %ecx, %edx
notl %edx
addl 0xc(%rsp), %edx
cmpl 0x20(%rsp), %ecx
cmovbl %ecx, %edx
movl %edx, %r8d
shrl $0x6, %r8d
movq (%rbx,%r8,8), %r9
movq %r11, %r10
movl %edx, %ecx
shrq %cl, %r10
testq %r9, %r10
je 0x175ba4
orq %r9, %r10
movq %r10, (%rbx,%r8,8)
testq %rsi, %rsi
je 0x175ba6
movq %r11, %r8
movl %eax, %ecx
shrq %cl, %r8
movl %eax, %ecx
shrl $0x6, %ecx
testq %r8, (%rbx,%rcx,8)
jne 0x175bc0
movl %eax, %ecx
movzbl (%rsi,%rcx), %r8d
movl %edx, %edx
movzbl (%rsi,%rdx), %r9d
movl $0x100, %r10d           # imm = 0x100
subl %r9d, %r10d
cmpl %r8d, %r10d
jbe 0x175b9e
addb %r8b, %r9b
movb %r9b, (%rsi,%rcx)
movb $0x0, (%rsi,%rdx)
jmp 0x175ba6
movl %edx, %eax
incq %rdi
jmp 0x175b22
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c23a1(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x16f442(%rip), %rsi    # 0x2e5013
leaq 0x1d7857(%rip), %rdx    # 0x34d42f
leaq 0x1d78ae(%rip), %rcx    # 0x34d48d
leaq 0x1d76ef(%rip), %r8     # 0x34d2d5
movl $0x175, %r9d            # imm = 0x175
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2c2369(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x16f40a(%rip), %rsi    # 0x2e5013
leaq 0x1d7852(%rip), %rdx    # 0x34d462
leaq 0x1d7876(%rip), %rcx    # 0x34d48d
leaq 0x1d76b7(%rip), %r8     # 0x34d2d5
movl $0x111, %r9d            # imm = 0x111
jmp 0x175bec