// File: /workspace/github_c_makefile_star2_O2/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), %rax
imulq $0x50, %r8, %r13
leaq (%rax,%r13), %rcx
pushq $0x1
popq %rsi
subl %r9d, %esi
movq (%rcx,%rsi,8), %rcx
testq %rcx, %rcx
je 0x137a13
decq %rcx
leaq 0x8(%rsp), %rsi
movq %rcx, 0x8(%rsi)
movq %rbx, (%rsi)
movq (%rdx), %rdi
leaq -0x6f(%rip), %rdx       # 0x137948
xorl %ecx, %ecx
callq 0x107744
testq %rax, %rax
je 0x137a10
movq %rax, %r12
movq 0x8(%r15), %rsi
testq %rsi, %rsi
je 0x1379e2
movq (%r12), %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x137902
testb %al, %al
je 0x137a10
movl %ebp, %edx
movq (%r14), %rax
movq (%r12), %rsi
imulq $0x50, %rsi, %rcx
movq 0x48(%rax,%rcx), %rcx
movl (%r15), %ebp
testl %ebp, %ebp
je 0x137a57
movq %rcx, (%rsp)
movq %r14, %rdi
testb %dl, %dl
je 0x137a5e
movq %rbx, %rdx
callq 0x137863
jmp 0x137a69
movq (%r14), %rax
movq 0x30(%rax,%r13), %rcx
cmpl $0x1, (%r15)
jne 0x137a26
leaq (%rax,%r13), %rdx
subq 0x38(%rdx), %rcx
movq 0x18(%r14), %rsi
movq %rcx, 0x48(%rax,%r13)
movq %rsi, 0x28(%rax,%r13)
cmpq 0x18(%r14), %rsi
je 0x137a43
imulq $0x50, %rsi, %rcx
movq 0x20(%rax,%rcx), %rbx
movq %rbx, 0x20(%rax,%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq 0x30(%rax,%r13), %rcx
jmp 0x137a2a
movq %rbx, %rdx
callq 0x137885
movl (%r15), %ebp
cmpl $0x1, %ebp
sete %cl
movq (%rsp), %rsi
subq %rax, %rsi
setg %al
orb %cl, %al
leaq 0x18(%r14), %rdx
xorl %ecx, %ecx
testb %al, %al
cmovneq %r12, %rdx
cmovneq %rsi, %rcx
movq (%r14), %rax
addq 0x30(%rax,%r13), %rcx
movq (%rdx), %rsi
jmp 0x137a2a