// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/ltr/ltrharvest_stream.c
// Function: searchformotifonlyborders
static void searchformotifonlyborders(const GtLTRharvestStream *lo,
                                      LTRboundaries *boundaries,
                                      GtUword startleftLTR,
                                      GtUword endleftLTR,
                                      GtUword startrightLTR,
                                      GtUword endrightLTR,
                                      LTRMotifmismatches *motifmismatches)
{
  bool motif1 = false,
       motif2 = false;
  LTRMotifmismatches tmp_mm;
  unsigned int motifmismatches_frombestmatch = 0;
  GtUword idx,
         oldleftLTR_5  = boundaries->leftLTR_5,
         oldrightLTR_3 = boundaries->rightLTR_3,
         difffromoldboundary = 0;

  /**** search for left motif around leftLTR_5 ****/
  for (idx = startleftLTR; idx < endleftLTR; idx++)
  {
    tmp_mm.left = 0;
    if (gt_encseq_get_encoded_char(lo->encseq, idx, GT_READMODE_FORWARD)
          != lo->motif->firstleft)
    {
      tmp_mm.left++;
    }
    if (gt_encseq_get_encoded_char(lo->encseq, idx + 1, GT_READMODE_FORWARD)
          != lo->motif->secondleft)
    {
      tmp_mm.left++;
    }
    if (tmp_mm.left + motifmismatches->left <= lo->motif->allowedmismatches)
    {
       /* first hit */
       if (!motif1)
       {
         GtUword max, min;

         motifmismatches_frombestmatch = tmp_mm.left;
         boundaries->leftLTR_5 = idx;
         motif1 = true;
         max = GT_MAX(oldleftLTR_5, boundaries->leftLTR_5);
         min = GT_MIN(oldleftLTR_5, boundaries->leftLTR_5);
         difffromoldboundary = max - min;
       } else /* next hit */
       {
         GtUword maxval, minval, difffromnewboundary;

         /* test if hit is nearer to old boundaries than previous hit */
         maxval = GT_MAX(oldleftLTR_5, idx);
         minval = GT_MIN(oldleftLTR_5, idx);
         difffromnewboundary = maxval - minval;

         if (difffromnewboundary < difffromoldboundary)
         {
           motifmismatches_frombestmatch = tmp_mm.left;
           boundaries->leftLTR_5 = idx;
           difffromoldboundary = difffromnewboundary;
         }
       }
    }
  }
  motifmismatches->left += motifmismatches_frombestmatch;
  motifmismatches_frombestmatch = 0;

  for (idx = startrightLTR + 1; idx <= endrightLTR; idx++)
  {
    tmp_mm.right = 0;
    if (gt_encseq_get_encoded_char(lo->encseq, idx, GT_READMODE_FORWARD)
            != lo->motif->secondright)
    {
      tmp_mm.right++;
    }
    if (gt_encseq_get_encoded_char(lo->encseq, idx - 1, GT_READMODE_FORWARD)
            != lo->motif->firstright)
    {
      tmp_mm.right++;
    }
    if (tmp_mm.right + motifmismatches->right <= lo->motif->allowedmismatches)
    {
       /* first hit */
       if (!motif2)
       {
         GtUword max, min;

         motifmismatches_frombestmatch = tmp_mm.right;
         boundaries->rightLTR_3 = idx;
         motif2 = true;
         max = GT_MAX(oldrightLTR_3, boundaries->rightLTR_3);
         min = GT_MIN(oldrightLTR_3, boundaries->rightLTR_3);
         difffromoldboundary = max - min;
       } else /* next hit */
       {
         GtUword maxval, minval, difffromnewboundary;

         /* test if hit is nearer to old boundaries than previous hit */
         maxval = GT_MAX(oldrightLTR_3, idx);
         minval = GT_MIN(oldrightLTR_3, idx);
         difffromnewboundary = maxval - minval;
         if (difffromnewboundary < difffromoldboundary)
         {
           motifmismatches_frombestmatch = tmp_mm.right;
           boundaries->rightLTR_3 = idx;
           difffromoldboundary = difffromnewboundary;
         }
       }
    }
  }
  motifmismatches->right += motifmismatches_frombestmatch;
  if (motif1 && motif2)
  {
    boundaries->motif_near_tsd = true;
  } else
  {
    boundaries->motif_near_tsd = false;
  }
}

// Assembly:
subq $0xf8, %rsp
movq 0x100(%rsp), %rax
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq %rcx, 0xd8(%rsp)
movq %r8, 0xd0(%rsp)
movq %r9, 0xc8(%rsp)
movb $0x0, 0xc7(%rsp)
movb $0x0, 0xc6(%rsp)
movl $0x0, 0xb8(%rsp)
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0xa8(%rsp)
movq 0xe8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0xa0(%rsp)
movq $0x0, 0x98(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
cmpq 0xd8(%rsp), %rax
jae 0x312ecb
movl $0x0, 0xbc(%rsp)
movq 0xf0(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xb0(%rsp), %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
je 0x312c98
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
movq 0xf0(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xb0(%rsp), %rsi
addq $0x1, %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0x9(%rcx), %ecx
cmpl %ecx, %eax
je 0x312ce5
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
movq 0x100(%rsp), %rcx
addl (%rcx), %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
cmpl 0xc(%rcx), %eax
ja 0x312eb0
testb $0x1, 0xc7(%rsp)
jne 0x312de9
movl 0xbc(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x8(%rax)
movb $0x1, 0xc7(%rsp)
movq 0xa8(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x312d6b
movq 0xa8(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x312d7c
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xa8(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x312dae
movq 0xa8(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x312dbf
movq 0xe8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rax
subq 0x88(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x312eae
movq 0xa8(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jbe 0x312e0a
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x312e17
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xa8(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x312e45
movq 0xa8(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x312e52
movq 0xb0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rax
subq 0x78(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
cmpq 0x98(%rsp), %rax
jae 0x312eac
movl 0xbc(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x70(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x312eae
jmp 0x312eb0
jmp 0x312eb2
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0x312c2e
movl 0xb8(%rsp), %ecx
movq 0x100(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, 0xb8(%rsp)
movq 0xd0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
ja 0x313189
movl $0x0, 0xc0(%rsp)
movq 0xf0(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xb0(%rsp), %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0xb(%rcx), %ecx
cmpl %ecx, %eax
je 0x312f67
movl 0xc0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
movq 0xf0(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xb0(%rsp), %rsi
subq $0x1, %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0xa(%rcx), %ecx
cmpl %ecx, %eax
je 0x312fb4
movl 0xc0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
movl 0xc0(%rsp), %eax
movq 0x100(%rsp), %rcx
addl 0x4(%rcx), %eax
movq 0xf0(%rsp), %rcx
movq 0x88(%rcx), %rcx
cmpl 0xc(%rcx), %eax
ja 0x31316e
testb $0x1, 0xc6(%rsp)
jne 0x3130ad
movl 0xc0(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x20(%rax)
movb $0x1, 0xc6(%rsp)
movq 0xa0(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jbe 0x31303b
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x31304c
movq 0xe8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xa0(%rsp), %rax
movq 0xe8(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x31307b
movq 0xa0(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x31308c
movq 0xe8(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x31316c
movq 0xa0(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jbe 0x3130ce
movq 0xa0(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x3130db
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xa0(%rsp), %rax
cmpq 0xb0(%rsp), %rax
jae 0x313106
movq 0xa0(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x313113
movq 0xb0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq 0x98(%rsp), %rax
jae 0x31316a
movl 0xc0(%rsp), %eax
movl %eax, 0xb8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0xe8(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x48(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x31316c
jmp 0x31316e
jmp 0x313170
movq 0xb0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
jmp 0x312efd
movl 0xb8(%rsp), %ecx
movq 0x100(%rsp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
testb $0x1, 0xc7(%rsp)
je 0x3131c0
testb $0x1, 0xc6(%rsp)
je 0x3131c0
movq 0xe8(%rsp), %rax
movb $0x1, 0x39(%rax)
jmp 0x3131cc
movq 0xe8(%rsp), %rax
movb $0x0, 0x39(%rax)
addq $0xf8, %rsp
retq
nopw %cs:(%rax,%rax)