// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/diagbandseed.c
// Function: gt_diagbandseed_possibly_extend
static int gt_diagbandseed_possibly_extend(const GtArrayGtDiagbandseedRectangle
                                             *previous_extensions,
                                           bool haspreviousmatch,
                                           GtUword use_apos,
                                           GtUword aseqnum,
                                           GtUword apos,
                                           GtUword bseqnum,
                                           GtUword bpos,
                                           GtUword matchlength,
                                           GtDiagbandseedExtendSegmentInfo *esi)
{
  int ret = 0;

  if (esi->debug)
  {
    printf("# %s haspreviousmatch=%s\n",__func__,
           haspreviousmatch ? "true" : "false");
  }
  if (!haspreviousmatch ||
      (use_apos == 0 &&
       esi->info_querymatch.previous_match_b_end < bpos) || /* no overlap */
      (use_apos > 0 && !gt_diagbandseed_has_overlap_with_previous_match(
                             previous_extensions,
                             esi->info_querymatch.previous_match_a_start,
                             esi->info_querymatch.previous_match_a_end,
                             esi->info_querymatch.previous_match_b_start,
                             esi->info_querymatch.previous_match_b_end,
                             apos,
                             bpos,
                             matchlength,
                             esi->debug)))
  {
    bool success;

    /* relative seed start position in A and B */
    const GtUword bstart = bpos + 1 - matchlength;
    const GtUword astart = apos + 1 - matchlength;
#ifndef _WIN32
    struct timeval tvalBefore = {0};

    if (esi->dbs_state != NULL &&
        esi->dbs_state->withtiming)
    {
      gettimeofday (&tvalBefore, NULL);
    }
#endif
    ret = 1; /* perform extension */
    /* the following function called is either
         gt_greedy_extend_seed_relative or
         gt_xdrop_extend_seed_relative */
    success = esi->extend_relative_coords_function(&esi->info_querymatch,
                                                   &esi->plainsequence_info.
                                                     aseqorencseq,
                                                   aseqnum,
                                                   astart,
                                                   &esi->plainsequence_info.
                                                     bseqorencseq,
                                                   esi->same_encseq,
                                                   bseqnum,
                                                   bstart,
                                                   matchlength,
                                                   esi->query_readmode);
#ifndef _WIN32
    if (esi->dbs_state != NULL &&
        esi->dbs_state->withtiming)
    {
      struct timeval tvalAfter;
      gettimeofday (&tvalAfter, NULL);
      esi->dbs_state->total_extension_time_usec
        += (tvalAfter.tv_sec - tvalBefore.tv_sec) * 1000000L
            + tvalAfter.tv_usec - tvalBefore.tv_usec;
    }
#endif
    if (success)
    {
      double evalue, bit_score;

      if (esi->ani_accumulate != NULL)
      {
        const GtUword query_seqlen
          = esi->plainsequence_info.bseqorencseq.seqlength,
        aligned_len
          = esi->info_querymatch.previous_match_a_end -
            esi->info_querymatch.previous_match_a_start + 1 +
            esi->info_querymatch.previous_match_b_end -
            esi->info_querymatch.previous_match_b_start + 1;
        if (gt_querymatch_check_final_generic(
                               &evalue,
                               &bit_score,
                               esi->karlin_altschul_stat,
                               query_seqlen,
                               aligned_len,
                               esi->info_querymatch.previous_match_distance,
                               esi->info_querymatch.previous_match_mismatches,
                               esi->userdefinedleastlength,
                               esi->errorpercentage,
                               esi->evalue_threshold,
                               stdout))
        {
          esi->ani_accumulate->sum_of_aligned_len += aligned_len;
          esi->ani_accumulate->sum_of_distance
            += esi->info_querymatch.previous_match_distance;
          ret = 3;
        } else
        {
          ret = 2; /* found match, which does not satisfy length or similarity
                      constraints */
        }
      } else
      {
        const GtQuerymatch *querymatch
          = esi->info_querymatch.querymatchspaceptr;

        /* show extension results */
        gt_assert(querymatch != NULL);
        if (gt_querymatch_check_final(&evalue,
                                      &bit_score,
                                      esi->karlin_altschul_stat,
                                      querymatch,
                                      esi->userdefinedleastlength,
                                      esi->errorpercentage,
                                      esi->evalue_threshold))
        {
          if (!esi->benchmark) {
            if (gt_querymatch_gfa2_display(esi->out_display_flag))
            {
              gt_assert(esi->dbs_state != NULL);
              gt_querymatch_gfa2_edge(querymatch,
                                      esi->dbs_state->
                                           current_gfa2_edge_num);
              esi->dbs_state->current_gfa2_edge_num++;
              gt_bittab_set_bit(esi->dbs_state->used_a_sequences,
                                aseqnum);
              gt_bittab_set_bit(
                 esi->dbs_state->used_b_sequences != NULL
                   ? esi->dbs_state->used_b_sequences
                   : esi->dbs_state->used_a_sequences,
                   bseqnum);
            }
            gt_querymatch_prettyprint(evalue,bit_score,esi->out_display_flag,
                                      querymatch);
          }
          ret = 3; /* output match */
        } else
        {
          if (!esi->benchmark) {
            gt_querymatch_show_failed_seed(esi->out_display_flag,querymatch);
          }
          ret = 2; /* found match, which does not satisfy length or similarity
                      constraints */
        }
      }
    }
    /* else reference and query are the same sequence and overlap so that
       no extension was performed */
  }
  return ret;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xb8, %rsp
movb %sil, %al
movq 0xe0(%rsp), %rsi
movq 0xd8(%rsp), %rsi
movq 0xd0(%rsp), %rsi
movq %rdi, 0xb0(%rsp)
andb $0x1, %al
movb %al, 0xaf(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
movq %r8, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movl $0x0, 0x84(%rsp)
movq 0xe0(%rsp), %rax
testb $0x1, 0x105(%rax)
je 0x21d203
movb 0xaf(%rsp), %cl
leaq 0x33bb83(%rip), %rdx    # 0x558d63
leaq 0x3976c2(%rip), %rax    # 0x5b48a9
testb $0x1, %cl
cmovneq %rax, %rdx
leaq 0x3566e8(%rip), %rdi    # 0x5738dd
leaq 0x3566fb(%rip), %rsi    # 0x5738f7
movb $0x0, %al
callq 0x19070
testb $0x1, 0xaf(%rsp)
je 0x21d2d1
cmpq $0x0, 0xa0(%rsp)
jne 0x21d239
movq 0xe0(%rsp), %rax
movq 0x140(%rax), %rax
cmpq 0xd0(%rsp), %rax
jb 0x21d2d1
cmpq $0x0, 0xa0(%rsp)
jbe 0x21d80f
movq 0xb0(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x128(%rax), %rsi
movq 0xe0(%rsp), %rax
movq 0x130(%rax), %rdx
movq 0xe0(%rsp), %rax
movq 0x138(%rax), %rcx
movq 0xe0(%rsp), %rax
movq 0x140(%rax), %r8
movq 0x90(%rsp), %r9
movq 0xd0(%rsp), %r11
movq 0xd8(%rsp), %r10
movq 0xe0(%rsp), %rax
movb 0x105(%rax), %al
andb $0x1, %al
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movzbl %al, %eax
movl %eax, 0x10(%rsp)
callq 0x21d960
testb $0x1, %al
jne 0x21d80f
movq 0xd0(%rsp), %rax
addq $0x1, %rax
subq 0xd8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x90(%rsp), %rax
addq $0x1, %rax
subq 0xd8(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x19360
movq 0xe0(%rsp), %rax
cmpq $0x0, 0x190(%rax)
je 0x21d349
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
testb $0x1, 0x58(%rax)
je 0x21d349
leaq 0x60(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x19bb0
movl $0x1, 0x84(%rsp)
movq 0xe0(%rsp), %rax
movq 0x158(%rax), %rax
movq 0xe0(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
movq 0xe0(%rsp), %rsi
addq $0x30, %rsi
addq $0x18, %rsi
movq 0x98(%rsp), %rdx
movq 0x70(%rsp), %rcx
movq 0xe0(%rsp), %r8
addq $0x30, %r8
addq $0x50, %r8
movq 0xe0(%rsp), %r9
movb 0x104(%r9), %r9b
movq 0x88(%rsp), %r14
movq 0x78(%rsp), %rbx
movq 0xd8(%rsp), %r11
movq 0xe0(%rsp), %r10
movl 0x100(%r10), %r10d
andb $0x1, %r9b
movzbl %r9b, %r9d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
callq *%rax
andb $0x1, %al
movb %al, 0x83(%rsp)
movq 0xe0(%rsp), %rax
cmpq $0x0, 0x190(%rax)
je 0x21d45f
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
testb $0x1, 0x58(%rax)
je 0x21d45f
leaq 0x50(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x19bb0
movq 0x50(%rsp), %rax
subq 0x60(%rsp), %rax
imulq $0xf4240, %rax, %rcx    # imm = 0xF4240
addq 0x58(%rsp), %rcx
subq 0x68(%rsp), %rcx
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
addq 0x40(%rax), %rcx
movq %rcx, 0x40(%rax)
testb $0x1, 0x83(%rsp)
je 0x21d80d
movq 0xe0(%rsp), %rax
cmpq $0x0, 0x188(%rax)
je 0x21d5ca
movq 0xe0(%rsp), %rax
movq 0xa0(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0xe0(%rsp), %rax
movq 0x130(%rax), %rax
movq 0xe0(%rsp), %rcx
subq 0x128(%rcx), %rax
addq $0x1, %rax
movq 0xe0(%rsp), %rcx
addq 0x140(%rcx), %rax
movq 0xe0(%rsp), %rcx
subq 0x138(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x30(%rsp)
movq 0xe0(%rsp), %rax
movq 0x170(%rax), %rdx
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0xe0(%rsp), %rax
movq 0x148(%rax), %r9
movq 0xe0(%rsp), %rax
movq 0x150(%rax), %rbx
movq 0xe0(%rsp), %rax
movq (%rax), %r11
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %r10
movq 0xe0(%rsp), %rax
movsd 0x28(%rax), %xmm0
movq 0x41e9f6(%rip), %rax    # 0x63bf38
movq (%rax), %rax
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x268f00
testb $0x1, %al
jne 0x21d56d
jmp 0x21d5ba
movq 0x30(%rsp), %rcx
movq 0xe0(%rsp), %rax
movq 0x188(%rax), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0xe0(%rsp), %rax
movq 0x148(%rax), %rcx
movq 0xe0(%rsp), %rax
movq 0x188(%rax), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl $0x3, 0x84(%rsp)
jmp 0x21d5c5
movl $0x2, 0x84(%rsp)
jmp 0x21d80b
movq 0xe0(%rsp), %rax
movq 0x110(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x21d61e
movq 0x41e9b3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f8a1c(%rip), %rsi    # 0x516013
leaq 0x36a84d(%rip), %rdx    # 0x587e4b
leaq 0x3562f2(%rip), %rcx    # 0x5738f7
leaq 0x354988(%rip), %r8     # 0x571f94
movl $0xad5, %r9d            # imm = 0xAD5
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x21d620
movq 0xe0(%rsp), %rax
movq 0x170(%rax), %rdx
movq 0x28(%rsp), %rcx
movq 0xe0(%rsp), %rax
movq (%rax), %r8
movq 0xe0(%rsp), %rax
movq 0x8(%rax), %r9
movq 0xe0(%rsp), %rax
movsd 0x28(%rax), %xmm0
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x269230
testb $0x1, %al
jne 0x21d670
jmp 0x21d7d4
movq 0xe0(%rsp), %rax
testb $0x1, 0x180(%rax)
jne 0x21d7c7
movq 0xe0(%rsp), %rax
movq 0x178(%rax), %rdi
callq 0x2657b0
testb $0x1, %al
jne 0x21d6a2
jmp 0x21d7a2
jmp 0x21d6a4
movq 0xe0(%rsp), %rax
cmpq $0x0, 0x190(%rax)
jne 0x21d6ee
movq 0x41e8e3(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f894c(%rip), %rsi    # 0x516013
leaq 0x356249(%rip), %rdx    # 0x573917
leaq 0x356222(%rip), %rcx    # 0x5738f7
leaq 0x3548b8(%rip), %r8     # 0x571f94
movl $0xae1, %r9d            # imm = 0xAE1
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x21d6f0
movq 0x28(%rsp), %rdi
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
movq 0x70(%rax), %rsi
callq 0x267b90
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
movq 0x70(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x70(%rax)
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
movq 0x60(%rax), %rdi
movq 0x98(%rsp), %rsi
callq 0x89b00
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
cmpq $0x0, 0x68(%rax)
je 0x21d778
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
movq 0x68(%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x21d790
movq 0xe0(%rsp), %rax
movq 0x190(%rax), %rax
movq 0x60(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0x89b00
movsd 0x48(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movq 0xe0(%rsp), %rax
movq 0x178(%rax), %rdi
movq 0x28(%rsp), %rsi
callq 0x267bd0
movl $0x3, 0x84(%rsp)
jmp 0x21d809
movq 0xe0(%rsp), %rax
testb $0x1, 0x180(%rax)
jne 0x21d7fe
movq 0xe0(%rsp), %rax
movq 0x178(%rax), %rdi
movq 0x28(%rsp), %rsi
callq 0x268de0
movl $0x2, 0x84(%rsp)
jmp 0x21d80b
jmp 0x21d80d
jmp 0x21d80f
movl 0x84(%rsp), %eax
addq $0xb8, %rsp
popq %rbx
popq %r14
retq
nopw %cs:(%rax,%rax)