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

  /* Search vicinity of 3' border of left LTR.
     Do not align over 5' border of left LTR,
     in case of need decrease alignment length */
  if ((boundaries->leftLTR_3 < lo->vicinityforcorrectboundaries)
      || (startleftLTR = boundaries->leftLTR_3 -
         lo->vicinityforcorrectboundaries + 1) <
      boundaries->leftLTR_5 + 2)
  {
    startleftLTR = boundaries->leftLTR_5 + 2;
  }
  /* do not align over 5' border of right LTR */
  if ((endleftLTR = boundaries->leftLTR_3 +
       lo->vicinityforcorrectboundaries - 1) >
      boundaries->rightLTR_5 - 1)
  {
    endleftLTR = boundaries->rightLTR_5 - 1;
  }
  /* Search vicinity of 5' border of right LTR.
     Do not align over 3' border of left LTR */
  if ((startrightLTR = boundaries->rightLTR_5 -
         lo->vicinityforcorrectboundaries + 1)
       < boundaries->leftLTR_3 + 1)
  {
    startrightLTR = boundaries->leftLTR_3 + 1;
  }
  /* do not align over 3' border of right LTR */
  if ((endrightLTR = boundaries->rightLTR_5 +
       lo->vicinityforcorrectboundaries - 1) >
      boundaries->rightLTR_3 - 2)
  {
    endrightLTR = boundaries->rightLTR_3 - 2;
  }

  /* Search for right motif around leftLTR_3 */
  for (idx = startleftLTR + 1; idx <= endleftLTR; idx++)
  {
    tmp_mm.left = 0;
    if (gt_encseq_get_encoded_char(lo->encseq, idx, GT_READMODE_FORWARD)
              != lo->motif->secondright)
    {
      tmp_mm.left++;
    }
    if (gt_encseq_get_encoded_char(lo->encseq, idx - 1, GT_READMODE_FORWARD)
              != lo->motif->firstright)
    {
      tmp_mm.left++;
    }
    if (tmp_mm.left + motifmismatches->left <= lo->motif->allowedmismatches)
    {
       /* first hit */
       if (!motif1)
       {
         GtUword maxval, minval;

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

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

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

  /* Search for left motif around rightLTR_5 */
  for (idx = startrightLTR ; idx < endrightLTR; idx++)
  {
    tmp_mm.right = 0;
    if (gt_encseq_get_encoded_char(lo->encseq, idx, GT_READMODE_FORWARD)
               != lo->motif->firstleft)
    {
      tmp_mm.right++;
    }
    if (gt_encseq_get_encoded_char(lo->encseq, idx + 1, GT_READMODE_FORWARD)
               != lo->motif->secondleft)
    {
      tmp_mm.right++;
    }
    if (tmp_mm.right + motifmismatches->right <= lo->motif->allowedmismatches)
    {
       /* first hit */
       if (!motif2)
       {
         GtUword maxval, minval;

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

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

         if (difffromnewboundary < difffromoldboundary)
         {
           motifmismatches_frombestmatch = tmp_mm.right;
           boundaries->rightLTR_5 = idx;
           difffromoldboundary = difffromnewboundary;
         }
       }
    }
  }
  motifmismatches->right += motifmismatches_frombestmatch;
  if (motif1 && motif2)
  {
    boundaries->motif_far_tsd = true;
  } else
  {
    boundaries->motif_far_tsd = false;
  }
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq %rdx, 0xf0(%rsp)
movb $0x0, 0xef(%rsp)
movb $0x0, 0xee(%rsp)
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xc0(%rsp)
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0xb8(%rsp)
movq $0x0, 0xb0(%rsp)
movl $0x0, 0x9c(%rsp)
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x100(%rsp), %rcx
cmpq 0xa8(%rcx), %rax
jb 0x311b77
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x100(%rsp), %rcx
subq 0xa8(%rcx), %rax
addq $0x1, %rax
movq %rax, 0xe0(%rsp)
movq 0xf8(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq $0x2, %rcx
cmpq %rcx, %rax
jae 0x311b8f
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rax
addq $0x2, %rax
movq %rax, 0xe0(%rsp)
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x100(%rsp), %rcx
addq 0xa8(%rcx), %rax
subq $0x1, %rax
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rcx
movq 0x18(%rcx), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jbe 0x311be3
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
subq $0x1, %rax
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x100(%rsp), %rcx
subq 0xa8(%rcx), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
movq 0xf8(%rsp), %rcx
movq 0x10(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x311c37
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x1, %rax
movq %rax, 0xd0(%rsp)
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x100(%rsp), %rcx
addq 0xa8(%rcx), %rax
subq $0x1, %rax
movq %rax, 0xc8(%rsp)
movq 0xf8(%rsp), %rcx
movq 0x20(%rcx), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jbe 0x311c8b
movq 0xf8(%rsp), %rax
movq 0x20(%rax), %rax
subq $0x2, %rax
movq %rax, 0xc8(%rsp)
movq 0xe0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
cmpq 0xd8(%rsp), %rax
ja 0x311f3c
movl $0x0, 0xa0(%rsp)
movq 0x100(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xa8(%rsp), %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0xb(%rcx), %ecx
cmpl %ecx, %eax
je 0x311d09
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
movq 0x100(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xa8(%rsp), %rsi
subq $0x1, %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0xa(%rcx), %ecx
cmpl %ecx, %eax
je 0x311d56
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
movq 0xf0(%rsp), %rcx
addl (%rcx), %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
cmpl 0xc(%rcx), %eax
ja 0x311f21
testb $0x1, 0xef(%rsp)
jne 0x311e5a
movl 0xa0(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0xa8(%rsp), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x10(%rax)
movb $0x1, 0xef(%rsp)
movq 0xc0(%rsp), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x311ddc
movq 0xc0(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x311ded
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0xc0(%rsp), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x311e1f
movq 0xc0(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x311e30
movq 0xf8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rax
subq 0x88(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x311f1f
movq 0xc0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jbe 0x311e7b
movq 0xc0(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x311e88
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x311eb6
movq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
jmp 0x311ec3
movq 0xa8(%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 0xb0(%rsp), %rax
jae 0x311f1d
movl 0xa0(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0xa8(%rsp), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x70(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x311f1f
jmp 0x311f21
jmp 0x311f23
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x311c9f
movl 0x9c(%rsp), %ecx
movq 0xf0(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, 0x9c(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jae 0x3121f6
movl $0x0, 0xa4(%rsp)
movq 0x100(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xa8(%rsp), %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
je 0x311fd4
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
movq 0x100(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xa8(%rsp), %rsi
addq $0x1, %rsi
xorl %edx, %edx
callq 0xa9da0
movzbl %al, %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
movzbl 0x9(%rcx), %ecx
cmpl %ecx, %eax
je 0x312021
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
movq 0xf0(%rsp), %rcx
addl 0x4(%rcx), %eax
movq 0x100(%rsp), %rcx
movq 0x88(%rcx), %rcx
cmpl 0xc(%rcx), %eax
ja 0x3121db
testb $0x1, 0xee(%rsp)
jne 0x31211a
movl 0xa4(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0xa8(%rsp), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x18(%rax)
movb $0x1, 0xee(%rsp)
movq 0xb8(%rsp), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jbe 0x3120a8
movq 0xb8(%rsp), %rax
movq %rax, 0x20(%rsp)
jmp 0x3120b9
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xb8(%rsp), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x3120e8
movq 0xb8(%rsp), %rax
movq %rax, 0x18(%rsp)
jmp 0x3120f9
movq 0xf8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
subq 0x60(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x3121d9
movq 0xb8(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jbe 0x31213b
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
jmp 0x312148
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xb8(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jae 0x312173
movq 0xb8(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x312180
movq 0xa8(%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 0xb0(%rsp), %rax
jae 0x3121d7
movl 0xa4(%rsp), %eax
movl %eax, 0x9c(%rsp)
movq 0xa8(%rsp), %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
jmp 0x3121d9
jmp 0x3121db
jmp 0x3121dd
movq 0xa8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa8(%rsp)
jmp 0x311f6a
movl 0x9c(%rsp), %ecx
movq 0xf0(%rsp), %rax
addl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
testb $0x1, 0xef(%rsp)
je 0x31222d
testb $0x1, 0xee(%rsp)
je 0x31222d
movq 0xf8(%rsp), %rax
movb $0x1, 0x3a(%rax)
jmp 0x312239
movq 0xf8(%rsp), %rax
movb $0x0, 0x3a(%rax)
addq $0x108, %rsp            # imm = 0x108
retq
nopw %cs:(%rax,%rax)