// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/match/chain2dim.c
// Function: gt_chain2dim_evalmatchscore
static void gt_chain2dim_evalmatchscore(const GtChain2Dimmode *chainmode,
                                        GtChain2Dimmatchtable *matchtable,
                                        GtChain2DimMatchstore *matchstore,
                                        bool gapsL1,
                                        GtUword matchpointident,
                                        unsigned int presortdim)
{
  GtUword previous;
  GtChain2Dimpostype startpos2;
  GtChain2DimMatchpoint *qmatch2;
  GtChain2Dimscoretype score;

  startpos2 = GT_CHAIN2DIM_GETSTOREDSTARTPOINT(1-presortdim,matchpointident);
  if (startpos2 == 0)
  {
    qmatch2 = NULL;
  } else
  {
    GtChain2DimMatchpoint keymatch2;

    keymatch2.fpposition = startpos2 - 1;  /* it is a start position */
    keymatch2.fpident = MAKEENDPOINT(matchpointident);
                       /* but considered as endpoint */
    qmatch2 = (GtChain2DimMatchpoint *) gt_rbtree_previous_equal_key(
                                                 matchstore->dictroot,
                                                 &keymatch2,
                                                 gt_chain2dim_cmpendMatchpoint2,
                                                 NULL);
    if (qmatch2 != NULL)
    {
      if (chainmode->maxgapwidth != 0 &&
          !gt_chain2dim_checkmaxgapwidth(matchtable,
                                         chainmode->maxgapwidth,
                                         FRAGIDENT(qmatch2),
                                         matchpointident))
      {
        qmatch2 = NULL;
      }
    }
  }
  if (qmatch2 == NULL)
  {
    score = matchtable->matches[matchpointident].weight;
    if (chainmode->chainkind == GLOBALCHAININGWITHGAPCOST)
    {
      score -= GT_CHAIN2DIM_INITIALGAP(matchpointident);
    }
    previous = GT_CHAIN2DIM_UNDEFPREVIOUS;
  } else
  {
    score = matchtable->matches[FRAGIDENT(qmatch2)].score;
    if (chainmode->chainkind == GLOBALCHAINING)
    {
      score += matchtable->matches[matchpointident].weight;
      previous = FRAGIDENT(qmatch2);
    } else
    {
      GtChain2Dimscoretype tmpgc;

      if (gapsL1)
      {
        tmpgc = gapcostL1(matchtable,FRAGIDENT(qmatch2),matchpointident);
      } else
      {
        tmpgc = gapcostCc(matchtable,FRAGIDENT(qmatch2),matchpointident);
      }
      if (chainmode->chainkind == GLOBALCHAININGWITHGAPCOST || score > tmpgc)
      {
        score += (matchtable->matches[matchpointident].weight - tmpgc);
        previous = FRAGIDENT(qmatch2);
      } else
      {
        score = matchtable->matches[matchpointident].weight;
        previous = GT_CHAIN2DIM_UNDEFPREVIOUS;
      }
    }
  }
  matchtable->matches[matchpointident].score = score;
  matchtable->matches[matchpointident].previousinchain = previous;
  if (previous == GT_CHAIN2DIM_UNDEFPREVIOUS)
  {
    matchtable->matches[matchpointident].firstinchain = matchpointident;
  } else
  {
    matchtable->matches[matchpointident].firstinchain
      = matchtable->matches[previous].firstinchain;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq (%rsi), %rcx
leaq (%r8,%r8,4), %r13
shlq $0x4, %r13
leaq (%rcx,%r13), %rax
movl $0x1, %esi
subl %r9d, %esi
movq (%rax,%rsi,8), %rax
testq %rax, %rax
je 0x18e563
decq %rax
leaq 0x8(%rsp), %rsi
movq %rax, 0x8(%rsi)
movq %rbx, (%rsi)
movq (%rdx), %rdi
leaq -0x80(%rip), %rdx       # 0x18e447
xorl %ecx, %ecx
callq 0x166b9a
movq (%r14), %rcx
testq %rax, %rax
je 0x18e563
movq %rax, %r12
movq 0x8(%r15), %rax
testq %rax, %rax
je 0x18e52d
movq (%r12), %rdx
movq (%rcx,%r13), %rsi
leaq (%rdx,%rdx,4), %rdx
shlq $0x4, %rdx
movq 0x10(%rcx,%rdx), %rdi
cmpq %rdi, %rsi
jbe 0x18e50b
notq %rdi
addq %rdi, %rsi
cmpq %rax, %rsi
ja 0x18e563
movq 0x8(%rcx,%r13), %rsi
movq 0x18(%rcx,%rdx), %rdx
cmpq %rdx, %rsi
setbe %dil
notq %rdx
addq %rsi, %rdx
cmpq %rax, %rdx
setbe %al
orb %dil, %al
je 0x18e563
movl %ebp, %eax
movq (%r12), %rsi
leaq (%rsi,%rsi,4), %rdi
shlq $0x4, %rdi
movq 0x48(%rcx,%rdi), %rbp
movl (%r15), %edx
testl %edx, %edx
je 0x18e5ab
testb %al, %al
je 0x18e5b5
movq (%rcx,%r13), %rax
addq 0x8(%rcx,%r13), %rax
movq 0x10(%rcx,%rdi), %rsi
addq 0x18(%rcx,%rdi), %rsi
subq %rsi, %rax
jmp 0x18e5c3
movq 0x30(%rcx,%r13), %rax
cmpl $0x1, (%r15)
jne 0x18e576
leaq (%rcx,%r13), %rdx
subq 0x38(%rdx), %rax
movq 0x18(%r14), %rsi
movq %rax, 0x48(%rcx,%r13)
movq %rsi, 0x28(%rcx,%r13)
cmpq 0x18(%r14), %rsi
je 0x18e597
leaq (%rsi,%rsi,4), %rax
shlq $0x4, %rax
movq 0x20(%rcx,%rax), %rbx
movq %rbx, 0x20(%rcx,%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq 0x30(%rcx,%r13), %rbp
movq %rbp, %rax
jmp 0x18e57a
movq %r14, %rdi
movq %rbx, %rdx
callq 0x18e3f5
movl (%r15), %edx
cmpl $0x1, %edx
sete %cl
subq %rax, %rbp
setg %dl
orb %cl, %dl
leaq 0x18(%r14), %rsi
xorl %eax, %eax
testb %dl, %dl
cmovneq %r12, %rsi
cmovneq %rbp, %rax
movq (%r14), %rcx
addq 0x30(%rcx,%r13), %rax
movq (%rsi), %rsi
jmp 0x18e57a