// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/alignment.c
// Function: gt_alignment_eval_generic_with_affine_score
static GtWord gt_alignment_eval_generic_with_affine_score(
                                               bool mapped,
                                               bool downcase,
                                               const GtUchar *characters,
                                               const GtAlignment *alignment,
                                               const GtScoreMatrix *scorematrix,
                                               GtWord matchscore,
                                               GtWord mismatchscore,
                                               GtWord gap_opening,
                                               GtWord gap_extension)
{
  GtUword i, j, idx_u = 0, idx_v = 0, meoplen;
  GtWord sumscore = 0;
  GtMultieop meop;
  AlignmentEoptype next_meop_type = Insertion + 1;

  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
            {
              if (GT_ISSPECIAL(a) || GT_ISSPECIAL(b) ||
                  characters[a] != characters[b])
              {
                sumscore += mismatchscore;
              }
              else
                sumscore += matchscore;
            }
          } else
          {
            if (downcase)
            {
              a = tolower((int) a);
              b = tolower((int) b);
            }
            sumscore += (a != b) ? mismatchscore : matchscore;
          }
          idx_u++;
          idx_v++;
        }
        break;
      case Deletion:
        if (i < meoplen && next_meop_type == Deletion)
        {
          sumscore += gap_extension * meop.steps;
        } else
        {
          sumscore += gap_extension * meop.steps + gap_opening;
        }
        idx_u += meop.steps;
        break;
      case Insertion:
         if (i < meoplen && next_meop_type == Insertion)
        {
          sumscore += gap_extension * meop.steps;
        } else
        {
          sumscore += gap_extension * meop.steps + gap_opening;
        }
        idx_v += meop.steps;
        break;
    }
    next_meop_type = meop.type;
  }
  return sumscore;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x28(%rsp)
movq %r8, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movl %esi, 0x18(%rsp)
movl %edi, 0x1c(%rsp)
testb %sil, %dil
jne 0x121600
testq %rcx, %rcx
je 0x121600
movq 0x30(%rcx), %rdi
movq %rcx, %rbx
callq 0x1620d5
testq %rax, %rax
je 0x1215eb
movq %rbx, %rdi
callq 0x121154
testb %al, %al
je 0x121605
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0x162109
testq %rax, %rax
je 0x1215eb
movl $0x5, %ebx
movq %rax, 0x20(%rsp)
movq %rax, %r14
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%rsp), %rdx
movq 0x30(%rdx), %rdi
leaq -0x1(%r14), %rsi
movq %rsi, 0x38(%rsp)
callq 0x16210e
movq %rdx, %rbp
cmpl $0x3, %eax
movl %eax, 0x14(%rsp)
jae 0x121554
testq %rbp, %rbp
je 0x1215d2
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, 0x1c(%rsp)
je 0x1214ec
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x12152e
movl %ebx, %edx
callq 0x113add
movq 0x8(%rsp), %rdx
movslq %eax, %rcx
jmp 0x12151b
cmpb $0x0, 0x18(%rsp)
je 0x121509
movl %esi, %edi
callq 0x17ae0
movl %eax, %r14d
movl %ebx, %edi
callq 0x17ae0
movq 0x8(%rsp), %rdx
movq 0x28(%rsp), %rcx
cmpb %al, %r14b
je 0x12151b
movq 0x80(%rsp), %rcx
addq %rcx, %r12
incq %r13
incq %r15
decq %rbp
jne 0x1214b3
jmp 0x1215d7
movq 0x80(%rsp), %rcx
cmpb $-0x3, %r14b
ja 0x12151b
cmpb $-0x3, %al
ja 0x12151b
movq 0x30(%rsp), %rdi
movb (%rdi,%rsi), %al
movq 0x28(%rsp), %rcx
cmpb (%rdi,%rbx), %al
jne 0x121513
jmp 0x12151b
je 0x12159a
cmpl $0x4, %eax
movq 0x8(%rsp), %rdx
jne 0x1215d7
movq %rbp, %rax
imulq 0x90(%rsp), %rax
cmpq 0x20(%rsp), %r14
movq 0x88(%rsp), %rsi
movq %rsi, %rcx
movl $0x0, %edi
cmovbq %rdi, %rcx
cmpl $0x4, %ebx
cmovneq %rsi, %rcx
addq %r12, %rcx
addq %rax, %rcx
addq %rbp, %r15
movq %rcx, %r12
jmp 0x1215d7
movq %rbp, %rax
imulq 0x90(%rsp), %rax
cmpq 0x20(%rsp), %r14
movq 0x88(%rsp), %rdx
movq %rdx, %rcx
movl $0x0, %esi
cmovbq %rsi, %rcx
cmpl $0x3, %ebx
cmovneq %rdx, %rcx
addq %r12, %rcx
addq %rax, %rcx
addq %rbp, %r13
movq %rcx, %r12
movq 0x8(%rsp), %rdx
movl 0x14(%rsp), %ebx
movq 0x38(%rsp), %r14
testq %r14, %r14
jne 0x121483
jmp 0x1215ee
xorl %r12d, %r12d
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3a17a
callq 0x3a141