// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/match/seed-extend.c
// Function: gt_extend_sesp
static bool gt_extend_sesp(bool forxdrop,
                           void *info,
                           const GtSeqorEncseq *dbes,
                           const GtSeqorEncseq *queryes,
                           const GtSeedextendSeqpair *sesp)
{
  GtProcessinfo_and_querymatchspaceptr *info_querymatch
    = (GtProcessinfo_and_querymatchspaceptr *) info;
  GtGreedyextendmatchinfo *greedyextendmatchinfo = NULL;
  GtXdropmatchinfo *xdropmatchinfo = NULL;
  GtUword u_left_ext, v_left_ext, u_right_ext, v_right_ext, r_urightbound;
  GtXdropscore total_score = 0;
  GtFTsequenceResources ufsr, vfsr;
  GtFtPolished_point left_best_polished_point = {0,0,0,0,0},
                     right_best_polished_point = {0,0,0,0,0};
  const bool rightextension = true;
  const GtUword vseqstartpos = queryes->encseq != NULL
                                  ? sesp->query_seqstart : 0;

  if (sesp->same_encseq && sesp->dbseqnum == sesp->queryseqnum &&
      sesp->dbstart_relative + sesp->seedlength - 1 >=
      sesp->querystart_relative)
  {
    return NULL;
  }
  if (forxdrop)
  {
    xdropmatchinfo = info_querymatch->processinfo;
    xdropmatchinfo->best_left.ivalue = 0;
    xdropmatchinfo->best_left.jvalue = 0;
    xdropmatchinfo->best_left.score = 0;
    xdropmatchinfo->best_right.ivalue = 0;
    xdropmatchinfo->best_right.jvalue = 0;
    xdropmatchinfo->best_right.score = 0;
  } else
  {
    greedyextendmatchinfo = info_querymatch->processinfo;
    gt_greedy_extend_init(&ufsr,
                          &vfsr,
                          dbes,
                          queryes,
                          sesp->query_readmode,
                          sesp->query_seqlen,
                          greedyextendmatchinfo);
  }
  if (sesp->dbstart_relative > 0 && sesp->querystart_relative > 0)
  { /* there is something to align on the left of the seed */
    const GtUword uoffset = sesp->db_seqstart,
                  ulen = sesp->dbstart_relative,
      /* stop extension at left instance of seed or querystart,
         whichever is larger */
      r_voffset = (sesp->same_encseq &&
                   sesp->dbseqnum == sesp->queryseqnum)
                     ? sesp->dbstart_relative + sesp->seedlength : 0;
    GtUword vlen;

    gt_assert(r_voffset <= sesp->querystart_relative);
    vlen = sesp->querystart_relative - r_voffset;
    if (ulen > 0 && vlen > 0)
    {
      if (forxdrop)
      {
        gt_seqabstract_reinit_generic(!rightextension,
                                      GT_READMODE_FORWARD,
                                      xdropmatchinfo->useq,
                                      dbes,
                                      ulen,
                                      uoffset,
                                      sesp->db_seqstart,
                                      sesp->dbseqlength);
        gt_seqabstract_reinit_generic(!rightextension,
                                      sesp->query_readmode,
                                      xdropmatchinfo->vseq,
                                      queryes,
                                      vlen,
                                      sesp->query_seqstart + r_voffset,
                                      sesp->query_seqstart,
                                      sesp->query_seqlen);
  #ifdef SKDEBUG
        gt_xdrop_show_context(!rightextension,xdropmatchinfo);
  #endif
        gt_evalxdroparbitscoresextend(!rightextension,
                                      &xdropmatchinfo->best_left,
                                      xdropmatchinfo->res,
                                      xdropmatchinfo->useq,
                                      xdropmatchinfo->vseq,
                                      xdropmatchinfo->belowscore);
      } else
      {
        (void) front_prune_edist_inplace(!rightextension,
                                         &greedyextendmatchinfo->
                                            frontspace_reservoir,
                                         &left_best_polished_point,
                                         greedyextendmatchinfo->
                                             left_front_trace,
                                         greedyextendmatchinfo->pol_info,
                                         greedyextendmatchinfo->trimstrategy,
                                         greedyextendmatchinfo->history,
                                         greedyextendmatchinfo->
                                             perc_mat_history,
                                         greedyextendmatchinfo->
                                            maxalignedlendifference,
                                         greedyextendmatchinfo->showfrontinfo,
                                         sesp->seedlength,
                                         &ufsr,
                                         uoffset,
                                         ulen,
                                         /* as the readmode for the
                                            sequence u is always forward,
                                            we do not need the start position
                                            of the sequence for u. As the
                                            readmode for v can be reversed,
                                            we need the start of the sequence
                                            to correctly obtain the offset
                                            when using the reverse mode */
                                         vseqstartpos,
                                         &vfsr,
                                         sesp->query_seqstart + r_voffset,
                                         vlen,
                                         greedyextendmatchinfo->cam_generic,
                                         greedyextendmatchinfo->trimstat);
      }
    }
  }
  if (forxdrop)
  {
    u_left_ext = xdropmatchinfo->best_left.ivalue;
    v_left_ext = xdropmatchinfo->best_left.jvalue;
#ifdef SKDEBUG
    extensioncoords_show(true,!rightextension,u_left_ext,v_left_ext,
                         xdropmatchinfo->best_left.score);
#endif
  } else
  {
    u_left_ext = left_best_polished_point.row;
    gt_assert(left_best_polished_point.alignedlen >= u_left_ext);
    v_left_ext = left_best_polished_point.alignedlen - u_left_ext;
#ifdef SKDEBUG
    extensioncoords_show(false,!rightextension,u_left_ext,v_left_ext,
                         (GtWord) left_best_polished_point.distance);
#endif
  }
  if (sesp->same_encseq && sesp->dbseqnum == sesp->queryseqnum)
  {
    gt_assert(sesp->querystart_relative >= v_left_ext);
    r_urightbound = GT_MIN(sesp->dbseqlength,
                         sesp->querystart_relative - v_left_ext);
  } else
  {
    r_urightbound = sesp->dbseqlength;
  }
  if (sesp->dbstart_relative + sesp->seedlength < r_urightbound &&
      sesp->querystart_relative + sesp->seedlength < sesp->query_seqlen)
  { /* there is something to align on the right of the seed */
    /* stop extension at right instance of extended seed */
    const GtUword ulen = r_urightbound -
                         (sesp->dbstart_relative + sesp->seedlength);
    const GtUword vlen = sesp->query_seqlen -
                         (sesp->querystart_relative + sesp->seedlength);
    if (forxdrop)
    {
      gt_seqabstract_reinit_generic(rightextension,
                                    GT_READMODE_FORWARD,
                                    xdropmatchinfo->useq,
                                    dbes,
                                    ulen,
                                    sesp->db_seqstart +
                                         gt_sesp_db_seedpos(sesp) +
                                         sesp->seedlength,
                                    sesp->db_seqstart,
                                    sesp->dbseqlength);
      gt_seqabstract_reinit_generic(rightextension,
                                    sesp->query_readmode,
                                    xdropmatchinfo->vseq,
                                    queryes,
                                    vlen,
                                    sesp->query_seqstart +
                                      gt_sesp_query_seedpos(sesp) +
                                      sesp->seedlength,
                                    sesp->query_seqstart,
                                    sesp->query_seqlen);
#ifdef SKDEBUG
      gt_xdrop_show_context(rightextension,xdropmatchinfo);
#endif
      gt_evalxdroparbitscoresextend(rightextension,
                                    &xdropmatchinfo->best_right,
                                    xdropmatchinfo->res,
                                    xdropmatchinfo->useq,
                                    xdropmatchinfo->vseq,
                                    xdropmatchinfo->belowscore);
    } else
    {
      (void) front_prune_edist_inplace(rightextension,
                                       &greedyextendmatchinfo->
                                          frontspace_reservoir,
                                       &right_best_polished_point,
                                       greedyextendmatchinfo->right_front_trace,
                                       greedyextendmatchinfo->pol_info,
                                       greedyextendmatchinfo->trimstrategy,
                                       greedyextendmatchinfo->history,
                                       greedyextendmatchinfo->perc_mat_history,
                                       greedyextendmatchinfo->
                                          maxalignedlendifference,
                                       greedyextendmatchinfo->showfrontinfo,
                                       sesp->seedlength,
                                       &ufsr,
                                       sesp->db_seqstart +
                                         gt_sesp_db_seedpos(sesp) +
                                         sesp->seedlength,
                                       ulen,
                                       vseqstartpos,
                                       &vfsr,
                                       sesp->query_seqstart +
                                         gt_sesp_query_seedpos(sesp) +
                                         sesp->seedlength,
                                       vlen,
                                       greedyextendmatchinfo->cam_generic,
                                       greedyextendmatchinfo->trimstat);
    }
  }
  if (forxdrop)
  {
    u_right_ext = xdropmatchinfo->best_right.ivalue;
    v_right_ext = xdropmatchinfo->best_right.jvalue;
#ifdef SKDEBUG
    extensioncoords_show(true,rightextension,u_right_ext,v_right_ext,
                         xdropmatchinfo->best_right.score);
#endif
    total_score
      = (GtXdropscore) sesp->seedlength * xdropmatchinfo->arbitscores.mat +
        xdropmatchinfo->best_left.score +
        xdropmatchinfo->best_right.score;
  } else
  {
    u_right_ext = right_best_polished_point.row;
    gt_assert(right_best_polished_point.alignedlen >= u_right_ext);
    v_right_ext = right_best_polished_point.alignedlen - u_right_ext;
#ifdef SKDEBUG
    extensioncoords_show(false,rightextension,u_right_ext,v_right_ext,
                         (GtWord) right_best_polished_point.distance);
#endif
    if (greedyextendmatchinfo->check_extend_symmetry)
    {
      gt_assert(right_best_polished_point.alignedlen ==
                left_best_polished_point.alignedlen);
      gt_assert(u_right_ext == u_left_ext);
      gt_assert(right_best_polished_point.distance ==
                left_best_polished_point.distance);
    }
  }
  return gt_combine_extensions(
                 forxdrop,
                 info_querymatch,
                 dbes,
                 queryes,
                 sesp,
                 u_left_ext,
                 v_left_ext,
                 u_right_ext,
                 v_right_ext,
                 forxdrop ? total_score : 0,
                 forxdrop ? 0 : (left_best_polished_point.distance +
                                 right_best_polished_point.distance),
                 forxdrop ? 0 : (left_best_polished_point.max_mismatches +
                                 right_best_polished_point.max_mismatches));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %r8, %rbx
movq %rdx, %r12
xorl %r15d, %r15d
movq %r15, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %r15, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
cmpq %r15, 0x8(%rcx)
je 0x1eb087
movq 0x30(%rbx), %r15
cmpb $0x1, 0x4c(%rbx)
jne 0x1eb0ae
movq (%rbx), %rax
cmpq 0x20(%rbx), %rax
jne 0x1eb0ae
movq 0x18(%rbx), %rax
movq 0x40(%rbx), %rdx
addq %rdx, %rax
decq %rax
cmpq 0x38(%rbx), %rax
jae 0x1eb1de
movq (%rsi), %rbp
testb %dil, %dil
movq %rcx, 0x18(%rsp)
movq %rsi, 0xa8(%rsp)
je 0x1eb0de
movups %xmm0, 0x18(%rbp)
xorl %eax, %eax
movq %rax, 0x28(%rbp)
movups %xmm0, 0x40(%rbp)
movq %rax, 0x50(%rbp)
movq %rbp, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x1eb116
movl 0x48(%rbx), %r8d
movq 0x28(%rbx), %r9
subq $0x8, %rsp
movl %edi, %r14d
leaq 0x120(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movq %r12, %rdx
pushq %rbp
callq 0x1ea6c1
movl %r14d, %edi
addq $0x10, %rsp
movq $0x0, 0x8(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
movq %r12, 0x20(%rsp)
je 0x1eb252
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x1eb252
cmpb $0x1, 0x4c(%rbx)
jne 0x1eb14d
movq (%rbx), %rcx
cmpq 0x20(%rbx), %rcx
jne 0x1eb14d
movq 0x40(%rbx), %r13
addq %rax, %r13
jmp 0x1eb150
xorl %r13d, %r13d
subq %r13, %r14
jb 0x1eb68f
je 0x1eb252
movq 0x10(%rbx), %r10
movl %edi, 0x4(%rsp)
testb %dil, %dil
je 0x1eb1e5
movq 0x8(%rsp), %r12
movq 0x70(%r12), %rdx
xorl %edi, %edi
xorl %esi, %esi
movq 0x20(%rsp), %rcx
movq %rax, %r8
movq %r10, %r9
pushq 0x8(%rbx)
pushq %r10
callq 0x1eb6ad
addq $0x10, %rsp
movl 0x48(%rbx), %esi
movq 0x78(%r12), %rdx
movq 0x30(%rbx), %rax
addq %rax, %r13
xorl %edi, %edi
movq 0x18(%rsp), %rcx
movq %r14, %r8
movq %r13, %r9
pushq 0x28(%rbx)
pushq %rax
callq 0x1eb6ad
addq $0x10, %rsp
leaq 0x18(%r12), %rsi
movq 0x70(%r12), %rcx
movq 0x78(%r12), %r8
movq 0x10(%r12), %rdx
movq 0x68(%r12), %r9
xorl %edi, %edi
callq 0x20cec8
jmp 0x1eb24e
xorl %eax, %eax
jmp 0x1eb66e
leaq 0x98(%rbp), %rsi
movq (%rbp), %rcx
movq 0x10(%rbp), %r8
movl 0xb0(%rbp), %r9d
movzbl 0xbd(%rbp), %r11d
addq 0x30(%rbx), %r13
movzbl 0xc2(%rbp), %r12d
leaq 0x40(%rsp), %rdx
xorl %edi, %edi
pushq 0x50(%rbp)
pushq %r12
pushq %r14
pushq %r13
leaq 0xf8(%rsp), %r14
pushq %r14
pushq %r15
pushq %rax
pushq %r10
leaq 0x158(%rsp), %rax
pushq %rax
pushq 0x40(%rbx)
pushq %r11
pushq 0x20(%rbp)
pushq 0x28(%rbp)
pushq 0x18(%rbp)
callq 0x327562
addq $0x70, %rsp
movl 0x4(%rsp), %edi
testb %dil, %dil
je 0x1eb266
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r12
movq 0x20(%rax), %r9
jmp 0x1eb279
movq 0x40(%rsp), %r9
movq 0x48(%rsp), %r12
subq %r12, %r9
jb 0x1eb685
cmpb $0x1, 0x4c(%rbx)
jne 0x1eb2a2
movq (%rbx), %rax
cmpq 0x20(%rbx), %rax
jne 0x1eb2a2
movq 0x38(%rbx), %r13
subq %r9, %r13
jb 0x1eb699
movq 0x8(%rbx), %rax
cmpq %r13, %rax
cmovbq %rax, %r13
jmp 0x1eb2a6
movq 0x8(%rbx), %r13
movq 0x40(%rbx), %r14
movq 0x18(%rbx), %rax
addq %r14, %rax
subq %rax, %r13
jbe 0x1eb4aa
movq 0x38(%rbx), %rax
addq %r14, %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
jbe 0x1eb4aa
movq %rcx, 0x30(%rsp)
movq %r9, 0x38(%rsp)
movl %edi, 0x4(%rsp)
testb %dil, %dil
je 0x1eb395
movq 0x8(%rsp), %r14
movq 0x70(%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rbx), %r15
movq %rbx, %rdi
callq 0x1e9e8d
addq %rax, %r15
addq 0x40(%rbx), %r15
movl $0x1, %edi
xorl %esi, %esi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %r13, %r8
movq %r15, %r9
pushq 0x8(%rbx)
pushq 0x10(%rbx)
callq 0x1eb6ad
addq $0x10, %rsp
movl 0x48(%rbx), %eax
movl %eax, 0x10(%rsp)
movq 0x78(%r14), %r13
movq 0x30(%rbx), %r15
movq %rbx, %rdi
callq 0x1e9e9d
addq %rax, %r15
addq 0x40(%rbx), %r15
movl $0x1, %edi
movl 0x10(%rsp), %esi
movq %r13, %rdx
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %r8
movq %r15, %r9
pushq 0x28(%rbx)
pushq 0x30(%rbx)
callq 0x1eb6ad
addq $0x10, %rsp
leaq 0x40(%r14), %rsi
movq 0x70(%r14), %rcx
movq 0x78(%r14), %r8
movq 0x10(%r14), %rdx
movq 0x68(%r14), %r9
movl $0x1, %edi
callq 0x20cec8
jmp 0x1eb4a1
leaq 0x98(%rbp), %rax
movq %rax, 0x68(%rsp)
movq 0x8(%rbp), %rax
movq %rax, 0x78(%rsp)
movq 0x10(%rbp), %rax
movq %rax, 0x70(%rsp)
movl 0xb0(%rbp), %eax
movl %eax, 0x2c(%rsp)
movq 0x18(%rbp), %rax
movq %rax, 0xa0(%rsp)
movq 0x28(%rbp), %rax
movq %rax, 0x98(%rsp)
movq 0x20(%rbp), %rax
movq %rax, 0x90(%rsp)
movzbl 0xbd(%rbp), %eax
movq %rax, 0x88(%rsp)
movq %r12, 0x10(%rsp)
movq 0x10(%rbx), %r12
movq %rbx, %rdi
callq 0x1e9e8d
addq %r12, %rax
addq 0x40(%rbx), %rax
movq %rax, 0x80(%rsp)
movq 0x30(%rbx), %r12
movq %rbx, %rdi
callq 0x1e9e9d
addq %r12, %rax
addq 0x40(%rbx), %rax
movzbl 0xc2(%rbp), %r10d
leaq 0xd8(%rsp), %r11
leaq 0x118(%rsp), %r12
leaq 0xb0(%rsp), %rdx
movl $0x1, %edi
movq 0x68(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq 0x70(%rsp), %r8
movl 0x2c(%rsp), %r9d
pushq 0x50(%rbp)
pushq %r10
pushq 0x40(%rsp)
pushq %rax
pushq %r11
pushq %r15
pushq %r13
pushq 0xb8(%rsp)
pushq %r12
movq 0x58(%rsp), %r12
pushq %r14
pushq 0xd8(%rsp)
pushq 0xe8(%rsp)
pushq 0xf8(%rsp)
pushq 0x108(%rsp)
callq 0x327562
addq $0x70, %rsp
movl 0x4(%rsp), %edi
movq 0x38(%rsp), %r9
testb %dil, %dil
je 0x1eb4ce
movq 0x8(%rsp), %rax
movq 0x40(%rax), %r13
movq 0x48(%rax), %r15
movslq (%rax), %r10
imulq 0x40(%rbx), %r10
addq 0x28(%rax), %r10
addq 0x50(%rax), %r10
jmp 0x1eb51d
movq 0xb0(%rsp), %rax
movq 0xb8(%rsp), %r13
movq %rax, %r15
subq %r13, %r15
jb 0x1eb68a
cmpb $0x1, 0xbc(%rbp)
jne 0x1eb51a
cmpq 0x40(%rsp), %rax
jne 0x1eb69e
cmpq %r12, %r13
jne 0x1eb6a3
movq 0xc0(%rsp), %rax
cmpq 0x50(%rsp), %rax
jne 0x1eb6a8
xorl %r10d, %r10d
movq 0xd0(%rsp), %rax
addq 0x60(%rsp), %rax
movq 0x40(%rbx), %rcx
addq %r12, %r13
addq %rcx, %r13
addq %r9, %r15
addq %rcx, %r15
leaq (%r15,%r13), %rsi
xorl %ebp, %ebp
testb %dil, %dil
cmoveq %rax, %rbp
je 0x1eb573
testq %r10, %r10
js 0x1eb5a3
subq %r10, %rsi
jb 0x1eb694
movabsq $0x5555555555555556, %rcx # imm = 0x5555555555555556
movq %rsi, %rax
imulq %rcx
movq %rdx, %r14
shrq $0x3f, %r14
addq %rdx, %r14
jmp 0x1eb5c9
movq 0xc0(%rsp), %r14
addq 0x50(%rsp), %r14
movq %r14, %rdi
movq %rbp, 0x8(%rsp)
movq %r12, %rbp
movq %r9, %r12
callq 0x1c39e3
movq %r12, %r9
movq %rbp, %r12
movq 0x8(%rsp), %rbp
movq %rax, %r10
jmp 0x1eb5c9
addq %r10, %rsi
movabsq $0x5555555555555555, %rcx # imm = 0x5555555555555555
movq %rsi, %rax
imulq %rcx
movq %rdx, %r14
subq %rsi, %r14
movq %r14, %rax
shrq $0x3f, %rax
sarq %r14
addq %rax, %r14
movq 0x18(%rbx), %r11
movq %r11, %r8
subq %r12, %r8
movq 0xa8(%rsp), %rdx
jb 0x1eb680
movq 0x38(%rbx), %r12
movq %r12, %rax
subq %r9, %rax
jb 0x1eb680
movq %r8, 0x20(%rdx)
leaq (%r8,%r13), %rcx
decq %rcx
movq %rcx, 0x28(%rdx)
movq %rax, 0x30(%rdx)
leaq -0x1(%r15,%rax), %rcx
movq %rcx, 0x38(%rdx)
movq %r14, 0x40(%rdx)
movq %rbp, 0x48(%rdx)
movq 0x8(%rdx), %rdi
testq %rdi, %rdi
je 0x1eb66c
movq 0x18(%rdx), %rsi
movq 0x10(%rbx), %r9
movq (%rbx), %rcx
movzbl 0x4c(%rbx), %edx
movq %rdx, 0x8(%rsp)
movq %r13, %rdx
pushq $0x0
pushq 0x40(%rbx)
pushq %r12
pushq %r11
pushq 0x28(%rbx)
pushq 0x30(%rbx)
pushq 0x48(%rsp)
pushq 0x58(%rsp)
pushq %rax
pushq %r15
pushq 0x20(%rbx)
pushq 0x60(%rsp)
pushq %rbp
pushq %r14
pushq %r10
pushq 0x8(%rbx)
callq 0x1c4c6f
addq $0x80, %rsp
jmp 0x1eb66e
movb $0x1, %al
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x76c3b
callq 0x76b1e
callq 0x76c02
callq 0x76ae5
callq 0x76c74
callq 0x76cab
callq 0x76b57
callq 0x76b90
callq 0x76bc9