// File: /workspace/github_c_makefile_star2_O0/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 %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movq %rdx, 0xe8(%rsp)
movq %rcx, 0xe0(%rsp)
movb $0x0, 0x5f(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x311513
movq 0xe0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x3114db
jmp 0x311513
movq 0x32aabe(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x204b27(%rip), %rsi    # 0x516013
leaq 0x204ccc(%rip), %rdx    # 0x5161bf
leaq 0x282fec(%rip), %rcx    # 0x5944e6
leaq 0x282d81(%rip), %r8     # 0x594282
movl $0x2ca, %r9d            # imm = 0x2CA
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x311515
movq 0xf8(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xf0(%rsp), %rax
movq (%rax), %rsi
callq 0xb0530
movq %rax, 0xa0(%rsp)
movq 0xf8(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0xf0(%rsp), %rax
movq (%rax), %rsi
callq 0xb09f0
movq %rax, 0x98(%rsp)
movq 0xf0(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x3115c8
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
cmpq 0xa8(%rcx), %rax
jae 0x3115a0
movq 0xa0(%rsp), %rax
movq %rax, 0xd8(%rsp)
jmp 0x3115c3
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
subq 0xa8(%rcx), %rax
movq %rax, 0xd8(%rsp)
jmp 0x311656
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
cmpq 0xa8(%rcx), %rax
jae 0x3115f7
movq 0xa0(%rsp), %rax
movq %rax, 0xd8(%rsp)
jmp 0x311654
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
subq 0xa8(%rcx), %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
cmpq 0xa0(%rsp), %rax
jae 0x311652
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0xa0(%rsp), %rax
jb 0x311652
movq 0xa0(%rsp), %rax
movq %rax, 0xd8(%rsp)
jmp 0x311654
jmp 0x311656
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0xa8(%rcx), %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x10(%rcx), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jbe 0x3116ae
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rax
subq $0x2, %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
subq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
movq 0xf8(%rsp), %rcx
subq 0xa8(%rcx), %rax
movq %rax, 0xc8(%rsp)
movq 0xc8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq 0x18(%rcx), %rcx
addq $0x2, %rcx
cmpq %rcx, %rax
jae 0x311722
movq 0xf0(%rsp), %rax
movq 0x18(%rax), %rax
addq $0x2, %rax
movq %rax, 0xc8(%rsp)
movq 0xa0(%rsp), %rax
addq 0x98(%rsp), %rax
subq $0x1, %rax
movq %rax, 0xa8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0xa8(%rcx), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xa8(%rsp), %rax
jbe 0x311799
movq 0xf0(%rsp), %rax
movq 0x20(%rax), %rax
cmpq 0xa8(%rsp), %rax
ja 0x311799
movq 0xa8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
subq 0xc8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
movq 0xf8(%rsp), %rax
cmpl $0x1, 0x98(%rax)
jbe 0x311a50
movq 0xb8(%rsp), %rdi
shlq $0x0, %rdi
leaq 0x282aa5(%rip), %rsi    # 0x594282
movl $0x309, %edx            # imm = 0x309
callq 0xe80f0
movq %rax, 0x50(%rsp)
movq 0xb0(%rsp), %rdi
shlq $0x0, %rdi
leaq 0x282a83(%rip), %rsi    # 0x594282
movl $0x30a, %edx            # imm = 0x30A
callq 0xe80f0
movq %rax, 0x48(%rsp)
movq 0xf8(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0x50(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
callq 0xac280
movq 0xf8(%rsp), %rax
movq 0xd8(%rax), %rdi
movq 0x48(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0xac280
movq $0x0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x68(%rsp)
movq 0xf8(%rsp), %rax
movl 0x98(%rax), %eax
movq %rax, 0x78(%rsp)
movq 0xf8(%rsp), %rax
movl 0x9c(%rax), %eax
movq %rax, 0x80(%rsp)
movq 0xd8(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jb 0x3118ee
movq 0x32a6e3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x20474c(%rip), %rsi    # 0x516013
leaq 0x282c36(%rip), %rdx    # 0x594504
leaq 0x282c11(%rip), %rcx    # 0x5944e6
leaq 0x2829a6(%rip), %r8     # 0x594282
movl $0x311, %r9d            # imm = 0x311
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x3118f0
movq 0xd8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xf8(%rsp), %rax
movl 0x98(%rax), %eax
movl %eax, 0x44(%rsp)
movq 0xf8(%rsp), %rax
movq 0xd8(%rax), %rdi
callq 0xb0f00
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl 0x44(%rsp), %r8d
movq %rax, %r9
movq 0xe0(%rsp), %rax
leaq 0x8c1(%rip), %r11       # 0x312250
leaq 0x60(%rsp), %r10
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x2388e0
cmpl $0x0, %eax
je 0x3119bc
movb $0x1, 0x5f(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x2828ba(%rip), %rsi    # 0x594282
movl $0x322, %edx            # imm = 0x322
callq 0xe88c0
movq 0x48(%rsp), %rdi
leaq 0x2828a4(%rip), %rsi    # 0x594282
movl $0x323, %edx            # imm = 0x323
callq 0xe88c0
testb $0x1, 0x5f(%rsp)
jne 0x311a11
movq 0xf8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
movq 0xe8(%rsp), %rcx
leaq 0x60(%rsp), %rdi
callq 0x312430
jmp 0x311a13
cmpq $0x0, 0x60(%rsp)
je 0x311a4c
movq 0x60(%rsp), %rdi
leaq 0x28285b(%rip), %rsi    # 0x594282
movl $0x32c, %edx            # imm = 0x32C
callq 0xe88c0
movq $0x0, 0x68(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x60(%rsp)
jmp 0x311a4e
jmp 0x311a91
movq 0xf8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movq 0xc8(%rsp), %r8
movq 0xc0(%rsp), %r9
movq 0xe8(%rsp), %rax
movq %rax, (%rsp)
callq 0x312b90
movb 0x5f(%rsp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
retq
nopl (%rax,%rax)