// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/extended/tir_stream.c
// Function: gt_tir_search_for_TSDs
static int gt_tir_search_for_TSDs(GtTIRStream *tir_stream, TIRPair *tir_pair,
                                  const GtEncseq *encseq, GtError *err)
{
  GtUword start_left_tir,  end_left_tir,
          start_right_tir, end_right_tir,
          left_length, right_length,
          seq_start_pos1, seq_end_pos2, seq_length;
  GtUword contignumber = tir_pair->contignumber;
  TSDinfo info;
  int had_err = 0;
  gt_error_check(err);

  /* check vicinity for left tir start */
  seq_start_pos1 = gt_encseq_seqstartpos(encseq, contignumber);
  seq_length = gt_encseq_seqlength(encseq, contignumber);
  seq_end_pos2 = seq_start_pos1 + seq_length - 1;

  gt_assert(tir_pair->left_tir_start >= seq_start_pos1);
  gt_assert(tir_pair->left_tir_start <= tir_pair->left_tir_end);
  gt_assert(tir_pair->right_tir_start <= tir_pair->right_tir_end);

  /* check if left tir start with vicinity aligns over sequence border */
  if (tir_pair->left_tir_start - seq_start_pos1 < tir_stream->vicinity)
    start_left_tir = seq_start_pos1;
  else
    start_left_tir = tir_pair->left_tir_start - tir_stream->vicinity;
  /* do not align over end of left tir */
  if (tir_pair->left_tir_start + tir_stream->vicinity > tir_pair->left_tir_end)
    end_left_tir = tir_pair->left_tir_end;
  else
    end_left_tir = tir_pair->left_tir_start + tir_stream->vicinity;
  left_length = end_left_tir - start_left_tir + 1;

  /* do not align over 5'border of right tir */
  if (tir_pair->right_transformed_start > tir_pair->right_transformed_end
        - tir_stream->vicinity)
    start_right_tir = tir_pair->right_transformed_start;
  else
    start_right_tir = tir_pair->right_transformed_end - tir_stream->vicinity;
  /* do not align into next sequence */
  if (tir_pair->right_transformed_end + tir_stream->vicinity > seq_end_pos2)
    end_right_tir = seq_end_pos2;
  else
    end_right_tir = tir_pair->right_transformed_end + tir_stream->vicinity;
  right_length = end_right_tir - start_right_tir + 1;

  /* search for TSDs */
  if (tir_stream->min_TSD_length > 1U) {
    GtUchar *dbseq, *query;
    dbseq = gt_calloc(left_length, sizeof (GtUchar));
    query = gt_calloc(right_length, sizeof (GtUchar));

    gt_encseq_extract_encoded(encseq, dbseq,
                              start_left_tir, end_left_tir);
    gt_encseq_extract_encoded(encseq, query,
                              start_right_tir, end_right_tir);

    GT_INITARRAY(&info.TSDs, Seed);
    gt_assert(start_left_tir < start_right_tir);
    info.left_start_pos = start_left_tir;
    info.right_start_pos = start_right_tir;
    info.encseq = encseq;

    if (gt_sarrquerysubstringmatch(dbseq,
                                   left_length,
                                   query,
                                   right_length,
                                   tir_stream->min_TSD_length,
                                   gt_encseq_alphabet(encseq),
                                   gt_tir_store_TSDs,
                                   &info,
                                   NULL,
                                   err) != 0) {
       had_err = -1;
    }
    gt_free(dbseq);
    gt_free(query);

    /* find the best TSD */
    if (!had_err)
      gt_tir_find_best_TSD(&info, tir_stream, tir_pair);

    GT_FREEARRAY(&info.TSDs, Seed);
  }

  return had_err;
}

// Assembly:
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movq %rdx, 0xe8(%rsp)
movq %rcx, 0xe0(%rsp)
movq 0xf0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x90(%rsp)
movl $0x0, 0x5c(%rsp)
cmpq $0x0, 0xe0(%rsp)
je 0x1f1c49
movq 0xe0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x1f1c11
jmp 0x1f1c49
movq 0x44a388(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3243f1(%rip), %rsi    # 0x516013
leaq 0x324596(%rip), %rdx    # 0x5161bf
leaq 0x3777d7(%rip), %rcx    # 0x569407
leaq 0x3775f8(%rip), %r8     # 0x56922f
movl $0x17a, %r9d            # imm = 0x17A
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1f1c4b
movq 0xe8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xb0530
movq %rax, 0xa8(%rsp)
movq 0xe8(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xb09f0
movq %rax, 0x98(%rsp)
movq 0xa8(%rsp), %rax
addq 0x98(%rsp), %rax
subq $0x1, %rax
movq %rax, 0xa0(%rsp)
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
cmpq 0xa8(%rsp), %rax
jae 0x1f1cef
movq 0x44a2e2(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x32434b(%rip), %rsi    # 0x516013
leaq 0x37774f(%rip), %rdx    # 0x56941e
leaq 0x377731(%rip), %rcx    # 0x569407
leaq 0x377552(%rip), %r8     # 0x56922f
movl $0x181, %r9d            # imm = 0x181
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1f1cf1
jmp 0x1f1cf3
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf0(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x1f1d45
movq 0x44a28c(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x3242f5(%rip), %rsi    # 0x516013
leaq 0x377724(%rip), %rdx    # 0x569449
leaq 0x3776db(%rip), %rcx    # 0x569407
leaq 0x3774fc(%rip), %r8     # 0x56922f
movl $0x182, %r9d            # imm = 0x182
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1f1d47
jmp 0x1f1d49
movq 0xf0(%rsp), %rax
movq 0x18(%rax), %rax
movq 0xf0(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jbe 0x1f1d9b
movq 0x44a236(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x32429f(%rip), %rsi    # 0x516013
leaq 0x377701(%rip), %rdx    # 0x56947c
leaq 0x377685(%rip), %rcx    # 0x569407
leaq 0x3774a6(%rip), %r8     # 0x56922f
movl $0x183, %r9d            # imm = 0x183
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1f1d9d
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
subq 0xa8(%rsp), %rax
movq 0xf8(%rsp), %rcx
cmpq 0x118(%rcx), %rax
jae 0x1f1dd4
movq 0xa8(%rsp), %rax
movq %rax, 0xd8(%rsp)
jmp 0x1f1df7
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
subq 0x118(%rcx), %rax
movq %rax, 0xd8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0x118(%rcx), %rax
movq 0xf0(%rsp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x1f1e36
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xd0(%rsp)
jmp 0x1f1e59
movq 0xf0(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0x118(%rcx), %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 0x40(%rax), %rax
movq 0xf0(%rsp), %rcx
movq 0x48(%rcx), %rcx
movq 0xf8(%rsp), %rdx
subq 0x118(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x1f1eb7
movq 0xf0(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0xc8(%rsp)
jmp 0x1f1eda
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xf8(%rsp), %rcx
subq 0x118(%rcx), %rax
movq %rax, 0xc8(%rsp)
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0x118(%rcx), %rax
cmpq 0xa0(%rsp), %rax
jbe 0x1f1f11
movq 0xa0(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x1f1f34
movq 0xf0(%rsp), %rax
movq 0x48(%rax), %rax
movq 0xf8(%rsp), %rcx
addq 0x118(%rcx), %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
subq 0xc8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb0(%rsp)
movq 0xf8(%rsp), %rax
cmpq $0x1, 0x108(%rax)
jbe 0x1f21be
movq 0xb8(%rsp), %rdi
movl $0x1, %esi
leaq 0x3772b5(%rip), %rdx    # 0x56922f
movl $0x1a1, %ecx            # imm = 0x1A1
callq 0xe83c0
movq %rax, 0x50(%rsp)
movq 0xb0(%rsp), %rdi
movl $0x1, %esi
leaq 0x377292(%rip), %rdx    # 0x56922f
movl $0x1a2, %ecx            # imm = 0x1A2
callq 0xe83c0
movq %rax, 0x48(%rsp)
movq 0xe8(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
callq 0xac280
movq 0xe8(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xc0(%rsp), %rcx
callq 0xac280
movq $0x0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
jmp 0x1f2010
movq 0xd8(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jb 0x1f205a
movq 0x449f77(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x323fe0(%rip), %rsi    # 0x516013
leaq 0x377477(%rip), %rdx    # 0x5694b1
leaq 0x3773c6(%rip), %rcx    # 0x569407
leaq 0x3771e7(%rip), %r8     # 0x56922f
movl $0x1aa, %r9d            # imm = 0x1AA
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x1f205c
movq 0xd8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xc8(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x88(%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
movq 0x108(%rax), %rax
movl %eax, 0x44(%rsp)
movq 0xe8(%rsp), %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 0x6a1(%rip), %r11       # 0x1f27a0
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 0x1f212f
movl $0xffffffff, 0x5c(%rsp) # imm = 0xFFFFFFFF
movq 0x50(%rsp), %rdi
leaq 0x3770f4(%rip), %rsi    # 0x56922f
movl $0x1bb, %edx            # imm = 0x1BB
callq 0xe88c0
movq 0x48(%rsp), %rdi
leaq 0x3770de(%rip), %rsi    # 0x56922f
movl $0x1bc, %edx            # imm = 0x1BC
callq 0xe88c0
cmpl $0x0, 0x5c(%rsp)
jne 0x1f217c
movq 0xf8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0x1f2950
jmp 0x1f217e
cmpq $0x0, 0x70(%rsp)
je 0x1f21ba
movq 0x70(%rsp), %rdi
leaq 0x37709d(%rip), %rsi    # 0x56922f
movl $0x1c2, %edx            # imm = 0x1C2
callq 0xe88c0
movq $0x0, 0x78(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x70(%rsp)
jmp 0x1f21bc
jmp 0x1f21be
movl 0x5c(%rsp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
retq
nopl (%rax,%rax)