// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/alignment.c
// Function: gt_alignment_eval_generic_with_score
static GtWord gt_alignment_eval_generic_with_score(bool mapped,
                                            bool downcase,
                                            const GtUchar *characters,
                                            const GtAlignment *alignment,
                                            const GtScoreMatrix *scorematrix,
                                            GtWord matchscore,
                                            GtWord mismatchscore,
                                            GtWord gapscore)
{
  GtUword i, j, idx_u = 0, idx_v = 0, meoplen;
  GtWord sumscore = 0;
  GtMultieop meop;

  gt_assert(alignment != NULL && (!mapped || !downcase));
  if (gt_alignment_get_length(alignment) == 0)
  {
    return 0;
  }
#ifndef NDEBUG
  gt_assert(gt_alignment_is_valid(alignment));
#endif

  meoplen = gt_multieoplist_get_num_entries(alignment->eops);
  for (i = meoplen; i > 0; i--) {
    meop = gt_multieoplist_get_entry(alignment->eops, i - 1);
    switch (meop.type) {
      case Mismatch:
      case Match:
      case Replacement:
        for (j = 0; j < meop.steps; j++) {
          GtUchar a = alignment->u[idx_u],
                  b = alignment->v[idx_v];
          if (mapped)
          {
            if (scorematrix != NULL)
            {
              sumscore += gt_score_matrix_get_score(scorematrix, a, b);
            } else
            {
              sumscore += (GT_ISSPECIAL(a) || GT_ISSPECIAL(b) ||
                           characters[a] != characters[b]) ? mismatchscore
                                                           : matchscore;
            }
          }
          else
          {
            if (downcase)
            {
              a = tolower((int) a);
              b = tolower((int) b);
            }
            sumscore += ((a != b) ? mismatchscore : matchscore);
          }
          idx_u++;
          idx_v++;
        }
        break;
      case Deletion:
        sumscore += gapscore * meop.steps;
        idx_u += meop.steps;
        break;
      case Insertion:
        sumscore += gapscore * meop.steps;
        idx_v += meop.steps;
        break;
    }
  }
  return sumscore;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x30(%rsp)
movq %rdx, 0x18(%rsp)
movl %esi, 0x8(%rsp)
movl %edi, 0xc(%rsp)
testb %sil, %dil
jne 0xb57b7
testq %rcx, %rcx
je 0xb57b7
movq %rcx, %rdi
movq %rcx, %rbx
callq 0xb5085
testq %rax, %rax
je 0xb57a2
movq %rbx, %rdi
callq 0xb5574
testb %al, %al
je 0xb57e5
movq 0x70(%rsp), %rbp
movq 0x30(%rbx), %rdi
callq 0x101b46
movq %rax, %r12
xorl %r8d, %r8d
xorl %r15d, %r15d
xorl %r9d, %r9d
movq %rbx, %rdx
movq %rbx, (%rsp)
subq $0x1, %r12
jb 0xb57a5
movq %r9, %r13
movq %r8, %r14
movq 0x30(%rdx), %rdi
movq %r12, %rsi
callq 0x101b4b
movq %rdx, %rbx
cmpl $0x3, %eax
jb 0xb56b1
movq %r14, %r8
movq %r13, %r9
je 0xb578a
cmpl $0x4, %eax
movq (%rsp), %rdx
jne 0xb5667
movq %rbx, %rax
imulq 0x78(%rsp), %rax
addq %rax, %r8
addq %rbx, %r15
jmp 0xb5667
movq (%rsp), %rdx
movq %r14, %r8
movq %r13, %r9
movq %r12, 0x20(%rsp)
subq $0x1, %rbx
jb 0xb5667
movq 0x20(%rdx), %rax
movq 0x28(%rdx), %rcx
movb (%rax,%r9), %r13b
movzbl %r13b, %esi
movb (%rcx,%r15), %al
movzbl %al, %r14d
cmpb $0x0, 0xc(%rsp)
je 0xb570c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb5765
movl %r14d, %edx
movq %r8, %r14
movq %r9, %r13
callq 0xa5323
movq %r13, %r9
movq %r14, %r8
movq (%rsp), %rdx
movslq %eax, %rcx
jmp 0xb5757
cmpb $0x0, 0x8(%rsp)
je 0xb574a
movl %esi, %edi
movq %r15, 0x28(%rsp)
movq %rbp, %r12
movq %r8, %rbp
movq %r9, %r15
callq 0x17a80
movl %eax, %r13d
movl %r14d, %edi
callq 0x17a80
movq %r15, %r9
movq %rbp, %r8
movq %r12, %rbp
movq 0x20(%rsp), %r12
movq 0x28(%rsp), %r15
movq (%rsp), %rdx
movq 0x10(%rsp), %rcx
cmpb %al, %r13b
je 0xb5757
movq %rbp, %rcx
addq %rcx, %r8
incq %r9
incq %r15
jmp 0xb56c0
movq %rbp, %rcx
cmpb $-0x3, %r13b
ja 0xb5757
movq %rbp, %rcx
cmpb $-0x3, %al
ja 0xb5757
movq 0x18(%rsp), %rdi
movb (%rdi,%rsi), %al
movq 0x10(%rsp), %rcx
cmpb (%rdi,%r14), %al
jne 0xb5754
jmp 0xb5757
movq %rbx, %rax
imulq 0x78(%rsp), %rax
addq %rax, %r8
addq %rbx, %r9
movq (%rsp), %rdx
jmp 0xb5667
xorl %r8d, %r8d
movq %r8, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3827aa(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x22f84b(%rip), %rsi    # 0x2e5013
leaq 0x25f97c(%rip), %rdx    # 0x31514b
leaq 0x25fbd9(%rip), %rcx    # 0x3153af
leaq 0x25f733(%rip), %r8     # 0x314f10
movl $0x115, %r9d            # imm = 0x115
jmp 0xb5811
movq 0x38277c(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x22f81d(%rip), %rsi    # 0x2e5013
leaq 0x25f994(%rip), %rdx    # 0x315191
leaq 0x25fbab(%rip), %rcx    # 0x3153af
leaq 0x25f705(%rip), %r8     # 0x314f10
movl $0x11b, %r9d            # imm = 0x11B
xorl %eax, %eax
callq 0x17a50
callq 0x17390