// File: /workspace/github_c_makefile_star2_O3/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 $0xa8, %rsp
movl 0x140(%rsp), %eax
movq %rax, 0x40(%rsp)
cmpq $0x2, %rax
jb 0x1c59c7
leaq 0x130(%rsp), %rax
leaq 0xe0(%rsp), %rdx
movq (%rax), %r11
movq 0x8(%rax), %r9
leaq (%r11,%r9,4), %rbx
movl 0xc(%rdx), %ecx
movq %rcx, 0x20(%rsp)
leal (%rcx,%rcx), %ebp
movq 0x18(%rdx), %rsi
movq 0x20(%rdx), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %r10
movq (%rdx), %rax
movq %rax, 0x98(%rsp)
movq 0x10(%rdx), %rax
movq %rax, 0x38(%rsp)
movl $0x1, %edx
movq %rsi, 0x18(%rsp)
movq %rbx, 0x50(%rsp)
movl %ebp, 0x34(%rsp)
movq %r11, 0x68(%rsp)
movq %r9, 0x60(%rsp)
movq %r10, 0x58(%rsp)
movl (%rbx,%rdx,4), %eax
movl %eax, %ebx
notl %ebx
addl %ebp, %ebx
cmpl 0x20(%rsp), %eax
movl %eax, 0x2c(%rsp)
cmovbl %eax, %ebx
testq %rsi, %rsi
je 0x1c56dc
xorl %r15d, %r15d
jmp 0x1c56ff
testl %ebx, %ebx
je 0x1c56f4
movl %ebx, %eax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %r15
leal -0x1(%rbx), %eax
subq (%rcx,%rax,8), %r15
jmp 0x1c56ff
movq 0x10(%rsp), %rax
movq (%rax), %r15
incq %r15
movq %rdx, 0x8(%rsp)
movq %rdx, %r14
movq %rbx, 0x78(%rsp)
movq %r15, 0x70(%rsp)
leaq (%r11,%r14,4), %r12
movl -0x4(%r12,%r9,4), %eax
movl %eax, %r13d
notl %r13d
addl %ebp, %r13d
cmpl 0x20(%rsp), %eax
movl %eax, 0x30(%rsp)
cmovbl %eax, %r13d
movl %ebp, %r8d
testq %rsi, %rsi
je 0x1c5745
movq %rsi, %rbp
movq $0x0, 0x48(%rsp)
jmp 0x1c5777
testl %r13d, %r13d
je 0x1c5760
movl %r13d, %eax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rbp
leal -0x1(%r13), %eax
subq (%rcx,%rax,8), %rbp
jmp 0x1c576b
movq 0x10(%rsp), %rax
movq (%rax), %rbp
incq %rbp
cmpq %rbp, %r15
movq %rbp, 0x48(%rsp)
cmovbq %r15, %rbp
xorl %edi, %edi
movl $0x0, %esi
movl $0x0, %ecx
movl $0x0, %edx
movl $0x0, %eax
movq %rbp, 0xa0(%rsp)
cmpq %rbp, %r10
movl %r8d, %ebp
jae 0x1c5867
movq %r13, 0x80(%rsp)
movq %r12, 0x88(%rsp)
movq %r14, 0x90(%rsp)
movq %r10, %rbp
movq 0x98(%rsp), %r15
movq %r15, %rdi
movl 0x2c(%rsp), %esi
movq %rbp, %rdx
movq 0x20(%rsp), %r12
movl %r12d, %ecx
movq 0x18(%rsp), %r14
movq %r14, %r8
movq 0x10(%rsp), %r13
movq %r13, %r9
callq 0x1c5368
movl %eax, %ebx
movq %r15, %rdi
movl 0x30(%rsp), %esi
movq %rbp, %rdx
movl %r12d, %ecx
movq %r14, %r8
movq %r13, %r9
callq 0x1c5368
movl %eax, %edx
movl $0xff, %ecx
andl %ecx, %edx
movl %ebx, %esi
andl %ecx, %esi
movl %edx, %edi
subl %esi, %edi
jne 0x1c5826
addq $0x4, %rbp
cmpq 0xa0(%rsp), %rbp
jb 0x1c57bc
movzwl %bx, %ecx
shrl $0x8, %ecx
movzwl %ax, %eax
shrl $0x8, %eax
movl 0x34(%rsp), %ebp
movq 0x68(%rsp), %r11
movq 0x60(%rsp), %r9
movq 0x58(%rsp), %r10
movq 0x78(%rsp), %rbx
movq 0x90(%rsp), %r14
movq 0x70(%rsp), %r15
movq 0x88(%rsp), %r12
movq 0x80(%rsp), %r13
cmpq 0x48(%rsp), %r15
jbe 0x1c5880
subl %ecx, %eax
addl %eax, %eax
movl %eax, %ecx
shrl %cl, %edx
shrl %cl, %esi
subl %esi, %edx
movl %edx, %edi
jne 0x1c5890
jmp 0x1c58c2
jae 0x1c5890
subl %eax, %ecx
addl %ecx, %ecx
shrl %cl, %edx
shrl %cl, %esi
subl %esi, %edx
movl %edx, %edi
je 0x1c58c5
testl %edi, %edi
js 0x1c58b6
movq 0x18(%rsp), %rsi
jne 0x1c58a0
cmpl %r13d, %ebx
ja 0x1c58ca
movl 0x30(%rsp), %eax
movl %eax, (%r12,%r9,4)
decq %r14
jne 0x1c5711
xorl %r14d, %r14d
jmp 0x1c58bb
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
jmp 0x1c58ea
movl %r13d, %ebx
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movl %ebx, %ecx
shrq %cl, %rax
shrl $0x6, %ebx
movq 0x38(%rsp), %rcx
orq %rax, (%rcx,%rbx,8)
movq 0x50(%rsp), %rbx
movl 0x2c(%rsp), %eax
movl %eax, (%rbx,%r14,4)
incq %rdx
cmpq 0x40(%rsp), %rdx
jne 0x1c56be
movl (%rbx), %ecx
movl %ecx, %eax
notl %eax
addl %ebp, %eax
cmpl 0x20(%rsp), %ecx
cmovbl %ecx, %eax
leaq 0xe0(%rsp), %rcx
movq 0x40(%rcx), %rsi
movl $0x1, %edi
movabsq $-0x8000000000000000, %r11 # imm = 0x8000000000000000
movq 0x38(%rsp), %r14
movl (%rbx,%rdi,4), %ecx
movl %ecx, %edx
notl %edx
addl %ebp, %edx
cmpl 0x20(%rsp), %ecx
cmovbl %ecx, %edx
movl %edx, %r8d
shrl $0x6, %r8d
movq (%r14,%r8,8), %r9
movq %r11, %r10
movl %edx, %ecx
shrq %cl, %r10
testq %r9, %r10
je 0x1c59a4
orq %r9, %r10
movq %r10, (%r14,%r8,8)
testq %rsi, %rsi
je 0x1c59a6
movq %r11, %r8
movl %eax, %ecx
shrq %cl, %r8
movl %eax, %ecx
shrl $0x6, %ecx
testq %r8, (%r14,%rcx,8)
jne 0x1c59c2
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 0x1c599e
addb %r8b, %r9b
movb %r9b, (%rsi,%rcx)
movb $0x0, (%rsi,%rdx)
jmp 0x1c59a6
movl %edx, %eax
incq %rdi
cmpq %rdi, 0x40(%rsp)
jne 0x1c5934
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x69c2e
callq 0x69bf5