// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/ltr/ltrharvest_stream.c
// Function: searchforTSDandorMotifoutside
static int searchforTSDandorMotifoutside(const GtLTRharvestStream *lo,
                                         LTRboundaries *boundaries,
                                         LTRMotifmismatches *motifmismatches,
                                         GtError *err)
{
  GtUword startleftLTR,
         endleftLTR,
         startrightLTR,
         endrightLTR,
         leftlen,
         rightlen,
         sequenceendpos,
         seqstartpos,
         seqlength;
  SubRepeatInfo subrepeatinfo;
  bool haserr = false;

  gt_error_check(err);

  /* check border cases */
  /* vicinity of 5'-border of left LTR */
  seqstartpos = gt_encseq_seqstartpos(lo->encseq, boundaries->contignumber);
  seqlength = gt_encseq_seqlength(lo->encseq, boundaries->contignumber);
  if (boundaries->contignumber == 0)
  {
    /* do not align over left sequence boundary,
       in case of need decrease alignment length */
    if (boundaries->leftLTR_5 < lo->vicinityforcorrectboundaries)
    {
      startleftLTR = seqstartpos;
    } else
    {
      startleftLTR = boundaries->leftLTR_5 - lo->vicinityforcorrectboundaries;
    }
  } else
  {
    /* do not align over left separator symbol
       in case of need decrease alignment length */
    if (boundaries->leftLTR_5 < lo->vicinityforcorrectboundaries)
    {
      startleftLTR = seqstartpos;
    } else
    {
      startleftLTR = boundaries->leftLTR_5 - lo->vicinityforcorrectboundaries;
      if (startleftLTR < seqstartpos && boundaries->leftLTR_5 >= seqstartpos)
      {
        startleftLTR = seqstartpos;
      }
    }
  }
  /* do not align over 3'-border of left LTR */
  endleftLTR = boundaries->leftLTR_5 + lo->vicinityforcorrectboundaries;
  if (endleftLTR > boundaries->leftLTR_3 - 2) /* -2 because of possible motif */
  {
    endleftLTR = boundaries->leftLTR_3 - 2;
  }
  leftlen = endleftLTR - startleftLTR + 1;

  /* vicinity of 3'-border of right LTR
     do not align over 5'border of right LTR */
  startrightLTR = boundaries->rightLTR_3 - lo->vicinityforcorrectboundaries;
  if (startrightLTR < boundaries->rightLTR_5 + 2) /* +2 for possible motif */
  {
    startrightLTR = boundaries->rightLTR_5 + 2;
  }
  sequenceendpos = seqstartpos + seqlength - 1;
  /* do not align into next sequence in case of need decrease alignment
     length */
  endrightLTR = boundaries->rightLTR_3 + lo->vicinityforcorrectboundaries;
  if (endrightLTR > sequenceendpos && boundaries->rightLTR_3 <= sequenceendpos)
  {
    endrightLTR = sequenceendpos;
  }
  rightlen = endrightLTR - startrightLTR + 1;

  /* now, search for correct boundaries */

  /* search for TSDs and/or motif */
  if (lo->minlengthTSD > 1U)
  {
    GtUchar *dbseq = gt_malloc(sizeof (*dbseq) * leftlen),
            *query = gt_malloc(sizeof (*query) * rightlen);

    gt_encseq_extract_encoded(lo->encseq,dbseq,startleftLTR,endleftLTR);
    gt_encseq_extract_encoded(lo->encseq,query,startrightLTR,endrightLTR);
    GT_INITARRAY(&subrepeatinfo.repeats, Repeat);
    subrepeatinfo.tsd_lmin = (GtUword) lo->minlengthTSD;
    subrepeatinfo.tsd_lmax = (GtUword) lo->maxlengthTSD;
    gt_assert(startleftLTR < startrightLTR);
    subrepeatinfo.offset1 = startleftLTR;
    subrepeatinfo.offset2 = startrightLTR;

    if (gt_sarrquerysubstringmatch(dbseq,
                                   leftlen,
                                   query,
                                   rightlen,
                                   lo->minlengthTSD,
                                   gt_encseq_alphabet(lo->encseq),
                                   gt_subsimpleexactselfmatchstore,
                                   &subrepeatinfo,
                                   NULL,
                                   err) != 0)
    {
       haserr = true;
    }
    gt_free(dbseq);
    gt_free(query);

    if (!haserr)
    {
      searchforbestTSDandormotifatborders(&subrepeatinfo,
                                          lo,
                                          boundaries,
                                          motifmismatches);
    }
    GT_FREEARRAY (&subrepeatinfo.repeats, Repeat);
  } else /* no search for TSDs, search for motif only */
  {
    searchformotifonlyborders(lo,
                              boundaries,
                              startleftLTR,
                              endleftLTR,
                              startrightLTR,
                              endrightLTR,
                              motifmismatches);
  }
  return haserr ? -1 : 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %rbx
movq %rdx, 0x30(%rsp)
movq %rsi, %r14
movq %rdi, %r15
testq %rcx, %rcx
je 0x210f12
movq %rbx, %rdi
callq 0xfcc32
testb %al, %al
jne 0x21167f
movq 0xd8(%r15), %rdi
movq (%r14), %rsi
callq 0xeb6ee
movq %rax, %rbp
movq 0xd8(%r15), %rdi
movq (%r14), %rsi
callq 0xeb9d2
cmpq $0x0, (%r14)
movq 0x8(%r14), %rsi
movq 0xa8(%r15), %rcx
movq %rbx, 0x10(%rsp)
je 0x210f67
movq %rsi, %rdx
movq %rbp, %r13
subq %rcx, %rdx
jb 0x210f71
cmpq %rbp, %rdx
movq %rbp, %r13
cmovaq %rdx, %r13
cmpq %rbp, %rsi
cmovbq %rdx, %r13
jmp 0x210f71
movq %rsi, %r13
subq %rcx, %r13
cmovbq %rbp, %r13
movq %rsi, (%rsp)
leaq (%rcx,%rsi), %rdx
movq 0x10(%r14), %rbx
movq 0x18(%r14), %r12
addq $-0x2, %rbx
cmpq %rbx, %rdx
cmovbq %rdx, %rbx
movq 0x20(%r14), %rsi
movq %rsi, %rdx
subq %rcx, %rdx
addq $0x2, %r12
cmpq %r12, %rdx
cmovaq %rdx, %r12
addq %rbp, %rax
decq %rax
addq %rsi, %rcx
cmpq %rax, %rcx
movq %rax, %rdx
cmovbq %rcx, %rdx
movq %rsi, 0x8(%rsp)
cmpq %rax, %rsi
cmovaq %rcx, %rdx
cmpl $0x2, 0x98(%r15)
movq %r14, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
jb 0x21114d
movq %rbx, %rdi
subq %r13, %rdi
incq %rdi
movq %rdx, %rbp
subq %r12, %rbp
incq %rbp
leaq 0x1affa3(%rip), %rsi    # 0x3c0f94
movq %rbx, 0x8(%rsp)
movq %rdi, 0x28(%rsp)
movl $0x309, %edx            # imm = 0x309
callq 0x104226
movq %rax, %rbx
movq %rbp, 0x38(%rsp)
movq %rbp, %rdi
leaq 0x1aff7d(%rip), %rsi    # 0x3c0f94
movl $0x30a, %edx            # imm = 0x30A
callq 0x104226
movq %rax, %rbp
movq 0xd8(%r15), %rdi
movq %rbx, (%rsp)
movq %rbx, %rsi
movq %r13, %rdx
movq 0x8(%rsp), %rcx
callq 0xe9127
movq 0xd8(%r15), %rdi
movq %rbp, 0x8(%rsp)
movq %rbp, %rsi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
callq 0xe9127
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movl 0x98(%r15), %ebp
movq %rbp, 0xa8(%rsp)
movl 0x9c(%r15), %eax
movq %rax, 0xb0(%rsp)
cmpq %r12, %r13
jae 0x211684
leaq 0x90(%rsp), %rbx
movq %r13, 0x28(%rbx)
movq %r12, 0x30(%rbx)
movq 0xd8(%r15), %rdi
callq 0xebcd9
leaq 0x5cd(%rip), %r10       # 0x211689
movq (%rsp), %r13
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq 0x8(%rsp), %r12
movq %r12, %rdx
movq 0x38(%rsp), %rcx
movl %ebp, %r8d
movq %rax, %r9
pushq 0x10(%rsp)
pushq $0x0
pushq %rbx
pushq %r10
callq 0x1a4168
addq $0x20, %rsp
movl %eax, %ebx
leaq 0x1afe9e(%rip), %rbp    # 0x3c0f94
movq %r13, %rdi
movq %rbp, %rsi
movl $0x322, %edx            # imm = 0x322
callq 0x1045eb
movq %r12, %rdi
movq %rbp, %rsi
movl $0x323, %edx            # imm = 0x323
callq 0x1045eb
movl %ebx, 0x5c(%rsp)
testl %ebx, %ebx
je 0x211381
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x211140
leaq 0x1afe5e(%rip), %rsi    # 0x3c0f94
movl $0x32c, %edx            # imm = 0x32C
callq 0x1045eb
xorl %eax, %eax
negl 0x5c(%rsp)
sbbl %eax, %eax
jmp 0x21136f
cmpq %r13, %rbx
jbe 0x21125b
movq $0x0, 0x10(%rsp)
movl $0x0, 0x28(%rsp)
xorl %r14d, %r14d
movq %r12, 0x40(%rsp)
movq %rbx, %r12
movq %r13, %rbp
movq 0xd8(%r15), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rcx
movq 0xd8(%r15), %rdi
xorl %ebx, %ebx
cmpb 0x8(%rcx), %al
setne %bl
incq %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rdx
leal 0x1(%rbx), %ecx
cmpb 0x9(%rdx), %al
cmovel %ebx, %ecx
movq 0x30(%rsp), %rax
movl (%rax), %eax
leal (%rcx,%rax), %esi
cmpl 0xc(%rdx), %esi
jbe 0x2111cd
movq %r12, %rbx
jmp 0x21122f
testb $0x1, 0x10(%rsp)
movq %r12, %rbx
je 0x211207
movq (%rsp), %rdx
movq %rdx, %rsi
subq %rbp, %rsi
negq %rsi
subq %rbp, %rdx
cmovbeq %rsi, %rdx
cmpq %r14, %rdx
movq 0x40(%rsp), %r12
jae 0x211234
movq 0x20(%rsp), %rsi
movq %rbp, 0x8(%rsi)
movq %rdx, %r14
movl %ecx, 0x28(%rsp)
jmp 0x211234
movq (%rsp), %r14
movq %r14, %rdx
subq %rbp, %rdx
negq %rdx
subq %rbp, %r14
cmovbeq %rdx, %r14
movq 0x20(%rsp), %rdx
movq %rbp, 0x8(%rdx)
movb $0x1, %dl
movq %rdx, 0x10(%rsp)
movl %ecx, 0x28(%rsp)
movq 0x40(%rsp), %r12
cmpq %r13, %rbx
jne 0x21116f
movl 0x28(%rsp), %ecx
addl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
leaq 0x1(%r12), %rcx
cmpq 0x18(%rsp), %rcx
jbe 0x211275
jmp 0x211363
leaq 0x1(%r12), %rcx
cmpq %rdx, %rcx
ja 0x211363
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
movl $0x0, (%rsp)
movq %r12, %r13
movq %rcx, %r12
movq 0xd8(%r15), %rdi
movq %rcx, %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rcx
movq 0xd8(%r15), %rdi
xorl %ebp, %ebp
cmpb 0xb(%rcx), %al
setne %bpl
movq %r13, %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rdx
leal 0x1(%rbp), %ecx
cmpb 0xa(%rdx), %al
cmovel %ebp, %ecx
movq 0x30(%rsp), %rax
movl 0x4(%rax), %eax
leal (%rcx,%rax), %esi
cmpl 0xc(%rdx), %esi
jbe 0x2112e0
movq %r14, %rdx
movq 0x18(%rsp), %rdi
jmp 0x211337
testb $0x1, %bl
movq 0x18(%rsp), %rdi
je 0x21130f
movq 0x8(%rsp), %rdx
movq %rdx, %rsi
subq %r12, %rsi
negq %rsi
subq %r12, %rdx
cmovbeq %rsi, %rdx
cmpq %r14, %rdx
jae 0x211334
movq 0x20(%rsp), %rsi
movq %r12, 0x20(%rsi)
jmp 0x21132f
movq 0x8(%rsp), %rdx
movq %rdx, %rsi
subq %r12, %rsi
negq %rsi
subq %r12, %rdx
cmovbeq %rsi, %rdx
movq 0x20(%rsp), %rsi
movq %r12, 0x20(%rsi)
movb $0x1, %bl
movl %ecx, (%rsp)
jmp 0x211337
movq %r14, %rdx
leaq 0x1(%r12), %rcx
movq %rdx, %r14
cmpq %rdi, %rcx
jbe 0x21127e
movl (%rsp), %ecx
addl %eax, %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x10(%rsp), %rcx
andb %bl, %cl
movb $0x1, %al
testb $0x1, %cl
jne 0x211365
xorl %eax, %eax
movq 0x20(%rsp), %rcx
movb %al, 0x39(%rcx)
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa0(%rsp), %rdx
testq %rdx, %rdx
je 0x211675
movq 0x8(%r14), %rax
movq %rax, 0x68(%rsp)
movq 0x20(%r14), %rax
movq %rax, 0x60(%rsp)
movw $0x1, 0x38(%r14)
jle 0x211122
movq 0x90(%rsp), %rsi
movq 0xa8(%rsp), %rcx
movq $0x0, 0x48(%rsp)
movq %rsi, %r8
movq $0x0, 0x50(%rsp)
movq 0x10(%r8), %rax
leaq 0x1(%rax), %rdi
cmpq %rcx, %rdi
je 0x211659
movq (%r8), %rdx
movq %r8, 0x8(%rsp)
movq 0x8(%r8), %rsi
leaq (%rax,%rdx), %rdi
movq %rdi, 0x78(%rsp)
incq %rdi
movq %rdi, 0x70(%rsp)
leaq -0x1(%rdx,%rsi), %rdi
movq %rdi, (%rsp)
addq %rsi, %rdx
addq $-0x2, %rdx
movq %rdx, 0x28(%rsp)
xorl %ebx, %ebx
xorl %esi, %esi
leaq (%rbx,%rax), %rdx
incq %rdx
cmpq %rcx, %rdx
movq %rbx, 0x88(%rsp)
movq %rsi, 0x80(%rsp)
je 0x21161c
movq 0x78(%rsp), %rdx
subq %rsi, %rdx
movq 0x68(%rsp), %rcx
movq %rcx, %rax
subq %rdx, %rax
negq %rax
movq %rdx, 0x18(%rsp)
subq %rdx, %rcx
cmovbeq %rax, %rcx
movq %rcx, 0x38(%rsp)
leaq 0x1(%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x70(%rsp), %rax
addq %rbx, %rax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movq 0xd8(%r15), %rdi
movq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rcx
movq 0xd8(%r15), %rdi
xorl %ebp, %ebp
cmpb 0x8(%rcx), %al
setne %bpl
movq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0xe7bbc
leal 0x1(%rbp), %r13d
movq 0x88(%r15), %rcx
cmpb 0x9(%rcx), %al
movq 0xd8(%r15), %rdi
cmovel %ebp, %r13d
movq 0x28(%rsp), %rax
leaq (%rax,%r14), %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rcx
movq 0xd8(%r15), %rdi
xorl %r12d, %r12d
cmpb 0xa(%rcx), %al
setne %r12b
movq (%rsp), %rax
leaq (%rax,%r14), %rbp
movq %rbp, %rsi
xorl %edx, %edx
callq 0xe7bbc
movq 0x88(%r15), %rdx
leal 0x1(%r12), %ecx
cmpb 0xb(%rdx), %al
cmovel %r12d, %ecx
movl 0xc(%rdx), %edx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
cmpl %edx, %r13d
ja 0x2115fa
cmpl %edx, %ecx
ja 0x2115fa
leaq (%rbx,%rax), %rdx
cmpq 0xb0(%rsp), %rdx
ja 0x2115fa
movq 0x20(%rsp), %rdi
cmpb $0x0, 0x39(%rdi)
je 0x2115ae
movq 0x60(%rsp), %rsi
movq %rsi, %rdi
subq %rbp, %rdi
negq %rdi
subq %rbp, %rsi
cmovbeq %rdi, %rsi
movq 0x38(%rsp), %rdi
addq %rsi, %rdi
movq 0x50(%rsp), %r8
movq 0x48(%rsp), %r9
addq %r9, %r8
cmpq %r8, %rdi
jae 0x2115fa
movq 0x30(%rsp), %rdi
movl %r13d, (%rdi)
movl %ecx, 0x4(%rdi)
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdi
movq %rdi, 0x8(%rcx)
movq %rbp, 0x20(%rcx)
movq %rdx, 0x30(%rcx)
movq %rdx, 0x28(%rcx)
movq %rsi, 0x50(%rsp)
jmp 0x2115f0
movq 0x60(%rsp), %r8
movq %r8, %rsi
subq %rbp, %rsi
negq %rsi
movq %r8, %r9
subq %rbp, %r9
movq 0x30(%rsp), %r8
movl %r13d, (%r8)
movl %ecx, 0x4(%r8)
movb $0x1, 0x39(%rdi)
movq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rdi)
movq %rbp, 0x20(%rdi)
movq %rdx, 0x30(%rdi)
movq %rdx, 0x28(%rdi)
cmovbeq %rsi, %r9
movq %r9, 0x50(%rsp)
movq 0x38(%rsp), %rcx
movq %rcx, 0x48(%rsp)
incq %r14
movq 0xa8(%rsp), %rcx
movq 0x40(%rsp), %rdx
addq %rax, %rdx
subq %rcx, %rdx
decq %rbx
cmpq %rdx, %r14
jb 0x21147d
movq 0x80(%rsp), %rsi
incq %rsi
movq 0x88(%rsp), %rbx
decq %rbx
movq %rax, %rdx
subq %rcx, %rdx
incq %rdx
cmpq %rdx, %rsi
jb 0x21141d
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0x8(%rsp), %r8
addq $0x20, %r8
movq %rdx, %rax
shlq $0x5, %rax
addq %rsi, %rax
cmpq %rax, %r8
jb 0x2113d6
jmp 0x211122
movb $0x0, 0x39(%r14)
jmp 0x211122
callq 0x81d84
callq 0x81dbd