// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/match/diagbandseed.c
// Function: gt_diagbandseed_segment2matches
static void gt_diagbandseed_segment2matches(
             void *v_segment2matches_info,
             GT_UNUSED const GtEncseq *aencseq,
             GT_UNUSED const GtEncseq *bencseq,
             GtUword aseqnum,
             GtUword bseqnum,
             const GtDiagbandStruct *diagband_struct,
             const GtDiagbandseedMaximalmatch *memstore,
             unsigned int seedlength,
             const GtSeedpairPositions *segment_positions,
             GtUword segment_length)
{
  GtDiagbandseedExtendSegmentInfo *esi
    = (GtDiagbandseedExtendSegmentInfo *) v_segment2matches_info;
  bool found_selected = false, haspreviousmatch = false;
  GtUword idx, matchlength = seedlength;
  GtArrayGtDiagbandseedRectangle *previous_extensions = NULL;

  if (esi->use_apos > 0)
  {
    previous_extensions = gt_rectangle_store_new();
  }
  gt_assert(memstore != NULL || segment_positions != NULL);
  for (idx = 0; idx < segment_length; idx++)
  {
    GtDiagbandseedPosition apos, bpos;
    GtUword coverage;

    if (memstore != NULL)
    {
      apos = memstore[idx].apos;
      bpos = memstore[idx].bpos;
      matchlength = memstore[idx].len;
    } else
    {
      apos = segment_positions[idx].apos;
      bpos = segment_positions[idx].bpos;
    }
    if (esi->debug)
    {
      printf("# apos=%u,bpos=%u,matchlength=" GT_WU "\n",
             apos,bpos,matchlength);
    }

    /* The filter sums the score of the current diagonalband
       as well as the maximum of the score of the previous and next
       diagonal band */
    coverage = gt_diagband_struct_coverage(diagband_struct,apos,bpos);
    if (coverage >= esi->mincoverage)
    {
      int ret;

      if (esi->dbs_state != NULL)
      {
        esi->dbs_state->selected_seeds++;
      }
      if (!found_selected)
      {
        if (esi->dbs_state != NULL)
        {
          esi->dbs_state->seqpairs_with_minsegment++;
        }
        found_selected = true;
      }
      if (esi->only_selected_seqpairs)
      {
        printf("# " GT_WU "%c" GT_WU "\n",aseqnum,
               esi->query_readmode == GT_READMODE_REVCOMPL ? '-' : '+',
               bseqnum);
        break;
      }
      ret = gt_diagbandseed_possibly_extend(
                     previous_extensions,
                     haspreviousmatch,
                     esi->use_apos,
                     aseqnum,
                     apos,
                     bseqnum,
                     bpos,
                     matchlength,
                     esi);
      if (ret >= 1 && esi->dbs_state != NULL)
      {
        esi->dbs_state->extended_seeds++;
      }
      if (ret >= 2)
      {
        haspreviousmatch = true;
        if (esi->use_apos == 2 || /* add all previous matches */
            (esi->use_apos == 1 /* only add successful match */
             && ret == 3))
        {
          GtDiagbandseedRectangle newrectangle;

          newrectangle.a_start
            = esi->info_querymatch.previous_match_a_start;
          newrectangle.a_end = esi->info_querymatch.previous_match_a_end;
          newrectangle.b_start
            = esi->info_querymatch.previous_match_b_start;
          newrectangle.b_end
            = esi->info_querymatch.previous_match_b_end;
          if (esi->debug)
          {
            printf("# add rectangle (%u,%u) (%u,%u) from seed (%u,%u,"
                   GT_WU ")\n",
                    newrectangle.a_start,
                    newrectangle.a_end,
                    newrectangle.b_start,
                    newrectangle.b_end,
                    apos,bpos,matchlength);
          }
          gt_rectangle_store_add(previous_extensions,&newrectangle);
        }
        if (ret == 2 && esi->dbs_state != NULL)
        {
          esi->dbs_state->failedmatches++;
        }
      }
      if (ret == 3)
      {
        if (esi->dbs_state != NULL)
        {
          esi->dbs_state->countmatches++;
        }
        if (esi->segment_reject_func != NULL)
        {
          gt_segment_reject_register_match(esi->segment_reject_info,bseqnum);
          break;
        }
      }
    } else
    {
      if (esi->dbs_state != NULL)
      {
        esi->dbs_state->filteredbydiagonalscore++;
      }
      if (esi->debug)
      {
        printf("# filtered as diagonal score " GT_WU " < " GT_WU "\n",
               coverage,
               esi->mincoverage);
      }
    }
  }
  if (esi->use_apos > 0)
  {
    gt_rectangle_store_delete(previous_extensions);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, %r14
movq %r8, 0x48(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdi, %rbx
movq 0xd0(%rsp), %r12
cmpq $0x0, 0x10(%rdi)
je 0x141a8d
callq 0x18d9d8
jmp 0x141a8f
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %r12, %rax
orq 0xe0(%rsp), %rax
je 0x14212a
movl 0xd8(%rsp), %eax
movq %rax, 0x38(%rsp)
movq 0xe8(%rsp), %rbp
leaq 0x108(%rbx), %rax
movq %rax, 0x90(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x88(%rsp)
leaq 0x80(%rbx), %rax
movq %rax, 0x80(%rsp)
movq %r12, %r15
xorl %r13d, %r13d
movq $0x0, 0x20(%rsp)
movq $0x0, 0x50(%rsp)
movq %r14, 0x60(%rsp)
subq $0x1, %rbp
jb 0x1420c6
testq %r12, %r12
movq %r15, 0x30(%rsp)
movq %r13, 0x28(%rsp)
je 0x141b27
movl 0x8(%r15), %eax
movq %rax, 0x38(%rsp)
movq %r15, %rax
jmp 0x141b33
movq 0xe0(%rsp), %rax
leaq (%rax,%r13,8), %rax
movl (%rax), %r13d
movl 0x4(%rax), %r15d
cmpb $0x1, 0x105(%rbx)
jne 0x141b5c
leaq 0x1ffa3d(%rip), %rdi    # 0x341587
movl %r13d, %esi
movl %r15d, %edx
movq 0x38(%rsp), %rcx
xorl %eax, %eax
callq 0x17070
movq %r14, %rdi
movl %r13d, %esi
movl %r15d, %edx
callq 0x2a695a
movq 0x18(%rbx), %rdx
movq 0x190(%rbx), %rcx
cmpq %rdx, %rax
jae 0x141bb0
testq %rcx, %rcx
je 0x141b83
incq 0x50(%rcx)
cmpb $0x1, 0x105(%rbx)
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
jne 0x142070
leaq 0x1ffa4c(%rip), %rdi    # 0x3415ed
movq %rax, %rsi
xorl %eax, %eax
callq 0x17070
jmp 0x142070
testq %rcx, %rcx
je 0x141bc8
incq 0x18(%rcx)
testb $0x1, 0x50(%rsp)
jne 0x141bdd
incq 0x30(%rcx)
movb $0x1, %al
jmp 0x141bd8
movq 0x50(%rsp), %rax
testb $0x1, %al
movzbl %al, %eax
pushq $0x1
popq %rcx
cmovel %ecx, %eax
movq %rax, 0x50(%rsp)
cmpb $0x1, 0x20(%rbx)
je 0x14209e
movq 0x10(%rbx), %r14
cmpb $0x1, 0x105(%rbx)
jne 0x141c20
testb $0x1, 0x20(%rsp)
leaq 0x1e4dec(%rip), %rdx    # 0x3269ec
leaq 0x2003bd(%rip), %rax    # 0x341fc4
cmovneq %rax, %rdx
leaq 0x1ffa03(%rip), %rdi    # 0x341615
leaq 0x1ffa16(%rip), %rsi    # 0x34162f
xorl %eax, %eax
callq 0x17070
testb $0x1, 0x20(%rsp)
je 0x141d29
testq %r14, %r14
je 0x141cb8
movb 0x105(%rbx), %cl
movq %r13, %r12
movq 0x38(%rsp), %rax
subq %rax, %r12
incq %r12
movq %r15, %r14
subq %rax, %r14
incq %r14
movb %cl, 0xf(%rsp)
cmpb $0x1, %cl
jne 0x141cd2
movq 0x128(%rbx), %r9
subq $0x8, %rsp
leaq 0x1ff9fa(%rip), %rdi    # 0x341666
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
pushq 0x140(%rbx)
pushq 0x138(%rbx)
pushq 0x130(%rbx)
callq 0x17070
addq $0x20, %rsp
movl %r12d, 0x10(%rsp)
movl %r13d, 0x14(%rsp)
movl %r14d, 0x18(%rsp)
movl %r15d, 0x1c(%rsp)
movq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x18dc18
jmp 0x141ceb
cmpq %r15, 0x140(%rbx)
jb 0x141d29
movb $0x1, %al
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %r14
jmp 0x142038
movl %r12d, 0x10(%rsp)
movl %r13d, 0x14(%rsp)
movl %r14d, 0x18(%rsp)
movl %r15d, 0x1c(%rsp)
movq 0x40(%rsp), %r14
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x18dbda
movl %eax, %r14d
cmpb $0x0, 0xf(%rsp)
movq 0xd0(%rsp), %r12
je 0x141d24
testb %r14b, %r14b
leaq 0x200244(%rip), %rdi    # 0x341f58
leaq 0x200278(%rip), %rax    # 0x341f93
cmovneq %rax, %rdi
callq 0x17b60
testb %r14b, %r14b
jne 0x141cc1
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x190(%rbx), %rax
testq %rax, %rax
je 0x141d4f
cmpb $0x1, 0x58(%rax)
jne 0x141d4f
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x17c10
movq %r15, %rax
movq 0x38(%rsp), %r11
subq %r11, %rax
incq %rax
movq %r13, %rcx
subq %r11, %rcx
incq %rcx
movzbl 0x104(%rbx), %r9d
movl 0x100(%rbx), %r10d
movq 0x90(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x80(%rsp), %r8
pushq %r10
pushq %r11
pushq %rax
pushq 0x60(%rsp)
callq *0x158(%rbx)
addq $0x20, %rsp
movl %eax, %r14d
movq 0x190(%rbx), %rax
testq %rax, %rax
je 0x141dee
cmpb $0x1, 0x58(%rax)
jne 0x141df0
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
callq 0x17c10
movq 0x70(%rsp), %rax
subq 0x10(%rsp), %rax
imulq $0xf4240, %rax, %rcx    # imm = 0xF4240
addq 0x78(%rsp), %rcx
subq 0x18(%rsp), %rcx
movq 0x190(%rbx), %rax
addq %rcx, 0x40(%rax)
jmp 0x141df0
xorl %eax, %eax
pushq $0x1
popq %r12
testb %r14b, %r14b
je 0x141f70
cmpq $0x0, 0x188(%rbx)
je 0x141e98
movq 0xa0(%rbx), %rcx
movq 0x130(%rbx), %r14
addq 0x140(%rbx), %r14
movq 0x128(%rbx), %rax
addq 0x138(%rbx), %rax
subq %rax, %r14
addq $0x2, %r14
movq 0x170(%rbx), %rdx
movq 0x148(%rbx), %r9
movsd 0x28(%rbx), %xmm0
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movq %r14, %r8
movq 0x2f6054(%rip), %rax    # 0x437eb0
pushq (%rax)
pushq 0x8(%rbx)
pushq (%rbx)
pushq 0x150(%rbx)
callq 0x16acf1
addq $0x20, %rsp
pushq $0x2
popq %r12
testb %al, %al
je 0x141f69
movq 0x188(%rbx), %rax
addq %r14, 0x8(%rax)
movq 0x148(%rbx), %rcx
addq %rcx, (%rax)
jmp 0x141f65
movq 0x110(%rbx), %r14
testq %r14, %r14
je 0x1420fc
movq 0x170(%rbx), %rdx
movq (%rbx), %r8
movq 0x8(%rbx), %r9
movsd 0x28(%rbx), %xmm0
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
movq %r14, %rcx
callq 0x16af45
movb 0x180(%rbx), %cl
testb %al, %al
je 0x14207c
pushq $0x3
popq %r12
testb %cl, %cl
jne 0x141f69
movq 0x178(%rbx), %rdi
callq 0x1690d2
testb %al, %al
je 0x141f4a
movq 0x190(%rbx), %rax
testq %rax, %rax
je 0x142162
movq 0x70(%rax), %rsi
movq %r14, %rdi
callq 0x16a2b8
movq 0x190(%rbx), %rax
incq 0x70(%rax)
movq 0x60(%rax), %rdi
movq 0x58(%rsp), %rsi
callq 0x5e143
movq 0x190(%rbx), %rax
movq 0x68(%rax), %rdi
testq %rdi, %rdi
jne 0x141f40
movq 0x60(%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x5e143
movsd 0x70(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
movq 0x178(%rbx), %rdi
movq %r14, %rsi
callq 0x16a2d0
pushq $0x3
popq %r12
movq 0x190(%rbx), %rax
testq %rax, %rax
movq 0x60(%rsp), %r14
je 0x141f7e
incq 0x10(%rax)
cmpl $0x2, %r12d
jb 0x142030
movq 0x10(%rbx), %rax
cmpq $0x2, %rax
je 0x141fa4
cmpq $0x1, %rax
setne %al
cmpl $0x3, %r12d
setne %cl
orb %al, %cl
jne 0x141fff
movl 0x128(%rbx), %esi
movl %esi, 0x10(%rsp)
movl 0x130(%rbx), %edx
movl %edx, 0x14(%rsp)
movl 0x138(%rbx), %ecx
movl %ecx, 0x18(%rsp)
movl 0x140(%rbx), %r8d
movl %r8d, 0x1c(%rsp)
cmpb $0x1, 0x105(%rbx)
jne 0x141ff0
leaq 0x1ff5d8(%rip), %rdi    # 0x3415b6
movl %r13d, %r9d
xorl %eax, %eax
pushq 0x38(%rsp)
pushq %r15
callq 0x17070
popq %rcx
popq %rdx
movq 0x40(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x18da37
movq 0x190(%rbx), %rax
cmpl $0x2, %r12d
jne 0x142044
movb $0x1, %cl
movq %rcx, 0x20(%rsp)
testq %rax, %rax
movq 0xd0(%rsp), %r12
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
je 0x142070
incq 0x28(%rax)
jmp 0x142070
movq 0xd0(%rsp), %r12
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
jmp 0x142070
testq %rax, %rax
movq 0xd0(%rsp), %r12
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r13
je 0x14205f
incq 0x20(%rax)
movb $0x1, %al
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x160(%rbx)
jne 0x1420e9
incq %r13
addq $0xc, %r15
jmp 0x141b00
pushq $0x2
popq %r12
testb %cl, %cl
jne 0x141f69
movq 0x178(%rbx), %rdi
movq %r14, %rsi
callq 0x16ac6c
pushq $0x2
jmp 0x141f67
xorl %eax, %eax
cmpl $0x3, 0x100(%rbx)
sete %al
leal 0x2b(%rax,%rax), %edx
leaq 0x1ff4f5(%rip), %rdi    # 0x3415aa
movq 0x58(%rsp), %rsi
movq 0x48(%rsp), %rcx
xorl %eax, %eax
callq 0x17070
cmpq $0x0, 0x10(%rbx)
je 0x1420d7
movq 0x40(%rsp), %rdi
callq 0x18d9f8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x168(%rbx), %rdi
movq 0x48(%rsp), %rsi
callq 0x142764
jmp 0x1420c6
movq 0x2f5e65(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a2f06(%rip), %rsi    # 0x2e5013
leaq 0x213347(%rip), %rdx    # 0x35545b
leaq 0x1ff514(%rip), %rcx    # 0x34162f
leaq 0x1fdd9a(%rip), %r8     # 0x33febc
movl $0xad5, %r9d            # imm = 0xAD5
jmp 0x142156
movq 0x2f5e37(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a2ed8(%rip), %rsi    # 0x2e5013
leaq 0x1ff3f7(%rip), %rdx    # 0x341539
leaq 0x1ff41e(%rip), %rcx    # 0x341567
leaq 0x1fdd6c(%rip), %r8     # 0x33febc
movl $0xc5d, %r9d            # imm = 0xC5D
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x2f5dff(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1a2ea0(%rip), %rsi    # 0x2e5013
leaq 0x1ff4d5(%rip), %rdx    # 0x34164f
leaq 0x1ff4ae(%rip), %rcx    # 0x34162f
leaq 0x1fdd34(%rip), %r8     # 0x33febc
movl $0xae1, %r9d            # imm = 0xAE1
jmp 0x142156