// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
movq %r8, 0x30(%rsp)
movq %rdx, 0x20(%rsp)
movl %esi, 0x10(%rsp)
movl %edi, 0x14(%rsp)
testb %sil, %dil
jne 0x127164
testq %rcx, %rcx
je 0x127164
movq 0x30(%rcx), %rdi
movq %rcx, %rbx
callq 0x169f3d
testq %rax, %rax
je 0x12714f
movq %rbx, %rdi
callq 0x126f4c
testb %al, %al
je 0x127169
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0x169f71
testq %rax, %rax
je 0x12714f
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rsp), %rdx
movq 0x30(%rdx), %rdi
decq %rax
movq %rax, 0x28(%rsp)
movq %rax, %rsi
callq 0x169f76
movq %rdx, %rbp
cmpl $0x3, %eax
jae 0x12710e
testq %rbp, %rbp
je 0x12713a
movq 0x8(%rsp), %rdx
movq 0x20(%rdx), %rax
movq 0x28(%rdx), %rcx
movb (%rax,%r13), %r14b
movzbl %r14b, %esi
movb (%rcx,%r15), %al
movzbl %al, %ebx
cmpb $0x0, 0x14(%rsp)
je 0x1270af
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1270eb
movl %ebx, %edx
callq 0x1191b4
movq 0x8(%rsp), %rdx
movslq %eax, %rcx
jmp 0x1270db
cmpb $0x0, 0x10(%rsp)
je 0x1270cc
movl %esi, %edi
callq 0x17ae0
movl %eax, %r14d
movl %ebx, %edi
callq 0x17ae0
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
cmpb %al, %r14b
je 0x1270db
movq 0x70(%rsp), %rcx
addq %rcx, %r12
incq %r13
incq %r15
decq %rbp
jne 0x127076
jmp 0x12713f
movq 0x70(%rsp), %rcx
cmpb $-0x3, %r14b
ja 0x1270db
cmpb $-0x3, %al
ja 0x1270db
movq 0x20(%rsp), %rdi
movb (%rdi,%rsi), %al
movq 0x18(%rsp), %rcx
cmpb (%rdi,%rbx), %al
jne 0x1270d6
jmp 0x1270db
je 0x12712b
cmpl $0x4, %eax
movq 0x8(%rsp), %rdx
jne 0x12713f
movq %rbp, %rax
imulq 0x78(%rsp), %rax
addq %rax, %r12
addq %rbp, %r15
jmp 0x12713f
movq %rbp, %rax
imulq 0x78(%rsp), %rax
addq %rax, %r12
addq %rbp, %r13
movq 0x8(%rsp), %rdx
movq 0x28(%rsp), %rax
testq %rax, %rax
jne 0x127048
jmp 0x127152
xorl %r12d, %r12d
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3aadd
callq 0x3aaa4