// File: /workspace/github_c_makefile_star2_O1/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, 0x38(%rsp)
cmpq $0x2, %rax
jb 0x1cec70
leaq 0x140(%rsp), %rcx
leaq 0xf0(%rsp), %rax
movq (%rcx), %rdi
movq 0x8(%rcx), %r8
leaq (%rdi,%r8,4), %r9
movl 0xc(%rax), %edx
movq %rdx, 0x28(%rsp)
leal (%rdx,%rdx), %r10d
movq 0x18(%rax), %rsi
movq 0x20(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq 0x18(%rcx), %r13
movq (%rax), %rcx
movq %rcx, 0xa8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %r11d
movq %rsi, 0x20(%rsp)
movq %rdi, 0x78(%rsp)
movq %r8, 0x70(%rsp)
movq %r9, 0x60(%rsp)
movl %r10d, 0x34(%rsp)
movq %r13, 0x68(%rsp)
movl (%r9,%r11,4), %eax
movl %eax, %ebx
notl %ebx
addl %r10d, %ebx
cmpl 0x28(%rsp), %eax
movl %eax, 0x10(%rsp)
cmovbl %eax, %ebx
testq %rsi, %rsi
je 0x1ce912
xorl %r14d, %r14d
jmp 0x1ce935
testl %ebx, %ebx
je 0x1ce92a
movl %ebx, %eax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %r14
leal -0x1(%rbx), %eax
subq (%rcx,%rax,8), %r14
jmp 0x1ce935
movq 0x8(%rsp), %rax
movq (%rax), %r14
incq %r14
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movl %ebx, %ecx
shrq %cl, %rax
movq %rax, 0x48(%rsp)
movl %ebx, %eax
shrl $0x6, %eax
movq %rax, 0x40(%rsp)
movq %r11, %r15
movq %r11, 0x90(%rsp)
movq %rbx, 0x88(%rsp)
movq %r14, 0x80(%rsp)
leaq (%rdi,%r15,4), %r12
movl -0x4(%r12,%r8,4), %eax
movl %eax, %edx
notl %edx
addl %r10d, %edx
cmpl 0x28(%rsp), %eax
movl %eax, 0x14(%rsp)
cmovbl %eax, %edx
testq %rsi, %rsi
movq %rdx, 0x50(%rsp)
je 0x1ce9a1
movq %rsi, %r9
movq $0x0, 0x58(%rsp)
jmp 0x1ce9d0
testl %edx, %edx
je 0x1ce9b9
movl %edx, %eax
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %r9
leal -0x1(%rdx), %eax
subq (%rcx,%rax,8), %r9
jmp 0x1ce9c4
movq 0x8(%rsp), %rax
movq (%rax), %r9
incq %r9
cmpq %r9, %r14
movq %r9, 0x58(%rsp)
cmovbq %r14, %r9
xorl %esi, %esi
movl $0x0, %ebp
movl $0x0, %ecx
movl $0x0, %eax
movl $0x0, %edx
movq %r9, 0xb0(%rsp)
cmpq %r9, %r13
jae 0x1ceac0
movq %r12, 0x98(%rsp)
movq %r15, 0xa0(%rsp)
movq 0xa8(%rsp), %r15
movq %r15, %rdi
movl 0x10(%rsp), %esi
movq %r13, %rdx
movq 0x28(%rsp), %r12
movl %r12d, %ecx
movq 0x20(%rsp), %r14
movq %r14, %r8
movq 0x8(%rsp), %rbx
movq %rbx, %r9
callq 0x1ce50f
movl %eax, %ebp
movq %r15, %rdi
movl 0x14(%rsp), %esi
movq %r13, %rdx
movl %r12d, %ecx
movq %r14, %r8
movq %rbx, %r9
callq 0x1ce50f
movl %eax, %esi
movl $0xff, %edx
andl %edx, %esi
movl %ebp, %ecx
andl %edx, %ecx
subl %ecx, %esi
jne 0x1cea6f
addq $0x4, %r13
cmpq 0xb0(%rsp), %r13
jb 0x1cea07
movzwl %bp, %ecx
shrl $0x8, %ecx
movzwl %ax, %edx
shrl $0x8, %edx
movl $0xff, %edi
andl %edi, %eax
andl %edi, %ebp
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %r8
movl 0x34(%rsp), %r10d
movq 0x68(%rsp), %r13
movq 0x90(%rsp), %r11
movq 0x88(%rsp), %rbx
movq 0x80(%rsp), %r14
movq 0xa0(%rsp), %r15
movq 0x98(%rsp), %r12
cmpq 0x58(%rsp), %r14
jbe 0x1ceaf9
subl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
shrl %cl, %eax
shrl %cl, %ebp
xorl %ecx, %ecx
movl %eax, %esi
subl %ebp, %esi
jne 0x1ceb23
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq 0x50(%rsp), %rcx
shrq %cl, %rax
shrl $0x6, %ecx
movq 0x18(%rsp), %rdx
orq %rax, (%rdx,%rcx,8)
jmp 0x1ceb1e
jae 0x1ceb27
subl %edx, %ecx
addl %ecx, %ecx
shrl %cl, %eax
shrl %cl, %ebp
xorl %ecx, %ecx
movl %eax, %esi
subl %ebp, %esi
jne 0x1ceb23
movq 0x18(%rsp), %rax
movq 0x48(%rsp), %rcx
movq 0x40(%rsp), %rdx
orq %rcx, (%rax,%rdx,8)
movl $0x7, %ecx
testl %esi, %esi
je 0x1ceb57
movl $0x7, %ecx
testl %esi, %esi
js 0x1ceb57
jne 0x1ceb4d
cmpl 0x50(%rsp), %ebx
jbe 0x1ceb4d
movq 0x18(%rsp), %rax
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rsi
orq %rdx, (%rax,%rsi,8)
jmp 0x1ceb57
movl 0x14(%rsp), %eax
movl %eax, (%r12,%r8,4)
xorl %ecx, %ecx
testl %ecx, %ecx
jne 0x1ceb6e
decq %r15
movq 0x20(%rsp), %rsi
jne 0x1ce96e
xorl %r15d, %r15d
jmp 0x1ceb73
movq 0x20(%rsp), %rsi
movl 0x10(%rsp), %eax
movq 0x60(%rsp), %r9
movl %eax, (%r9,%r15,4)
incq %r11
cmpq 0x38(%rsp), %r11
jne 0x1ce8f2
leaq 0x140(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
leaq 0xf0(%rsp), %rdx
movl 0xc(%rdx), %esi
leaq (%rax,%rcx,4), %rdi
movl (%rdi), %ecx
cmpl %esi, %ecx
movl %ecx, %eax
notl %eax
leal (%rax,%rsi,2), %eax
cmovbl %ecx, %eax
leal (%rsi,%rsi), %r8d
movq 0x10(%rdx), %r9
movq 0x40(%rdx), %r10
movl $0x1, %r11d
movl (%rdi,%r11,4), %ecx
movl %ecx, %edx
notl %edx
addl %r8d, %edx
cmpl %esi, %ecx
cmovbl %ecx, %edx
movl %edx, %ebx
shrl $0x6, %ebx
movq (%r9,%rbx,8), %r14
movabsq $-0x8000000000000000, %r15 # imm = 0x8000000000000000
movl %edx, %ecx
shrq %cl, %r15
testq %r14, %r15
je 0x1cec49
orq %r14, %r15
movq %r15, (%r9,%rbx,8)
testq %r10, %r10
je 0x1cec4b
movabsq $-0x8000000000000000, %rbx # imm = 0x8000000000000000
movl %eax, %ecx
shrq %cl, %rbx
movl %eax, %ecx
shrl $0x6, %ecx
testq %rbx, (%r9,%rcx,8)
jne 0x1cec6b
movl %eax, %ecx
movzbl (%r10,%rcx), %ebx
movl %edx, %edx
movzbl (%r10,%rdx), %ebp
movl $0x100, %r14d           # imm = 0x100
subl %ebp, %r14d
cmpl %ebx, %r14d
jbe 0x1cec42
addb %bl, %bpl
movb %bpl, (%r10,%rcx)
movb $0x0, (%r10,%rdx)
jmp 0x1cec4b
movl %edx, %eax
incq %r11
cmpq %r11, 0x38(%rsp)
jne 0x1cebcc
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6b4cf
callq 0x6b496