// File: /workspace/github_c_makefile_star2_O2/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 0xb5ac9
testq %rcx, %rcx
je 0xb5ac9
movq %rcx, %rdi
movq %rcx, %r14
callq 0xb5085
testq %rax, %rax
je 0xb5ab4
movq %r14, %rdi
callq 0xb5574
testb %al, %al
je 0xb5af7
movq 0x30(%r14), %rdi
callq 0x101b46
movq %rax, %rbp
pushq $0x5
popq %r9
xorl %r8d, %r8d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %rax, 0x20(%rsp)
movq %r14, %rdx
movq %r14, 0x10(%rsp)
subq $0x1, %rbp
jb 0xb5ab7
movl %r9d, %r15d
movq %r8, %r13
movq 0x30(%rdx), %rdi
movq %rbp, %rsi
callq 0x101b4b
movq %rdx, %r14
movl %eax, 0xc(%rsp)
cmpl $0x3, %eax
jb 0xb5994
movq %r13, %r8
je 0xb5a68
movl 0xc(%rsp), %r9d
cmpl $0x4, %r9d
movq 0x10(%rsp), %rdx
jne 0xb5914
leaq 0x1(%rbp), %rax
movq %r14, %rcx
imulq 0x90(%rsp), %rcx
cmpq 0x20(%rsp), %rax
movq 0x88(%rsp), %rsi
movq %rsi, %rax
movl $0x0, %edi
cmovbq %rdi, %rax
cmpl $0x4, %r15d
cmovneq %rsi, %rax
addq %r8, %rax
addq %rcx, %rax
addq %r14, %r12
movq %rax, %r8
jmp 0xb5914
movq 0x10(%rsp), %rdx
movq %r13, %r8
subq $0x1, %r14
jb 0xb5aaa
movq 0x20(%rdx), %rax
movq 0x28(%rdx), %rcx
movb (%rax,%rbx), %r15b
movzbl %r15b, %esi
movb (%rcx,%r12), %al
movzbl %al, %r13d
cmpb $0x0, 0x1c(%rsp)
je 0xb59e7
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xb5a41
movl %r13d, %edx
movq %r8, %r15
callq 0xa5323
movq %r15, %r8
movq 0x10(%rsp), %rdx
movslq %eax, %rcx
jmp 0xb5a33
cmpb $0x0, 0x18(%rsp)
je 0xb5a21
movl %esi, %edi
movq %rbx, 0x38(%rsp)
movq %r12, %rbx
movq %rbp, %r12
movq %r8, %rbp
callq 0x17a80
movl %eax, %r15d
movl %r13d, %edi
callq 0x17a80
movq %rbp, %r8
movq %r12, %rbp
movq %rbx, %r12
movq 0x38(%rsp), %rbx
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %rcx
cmpb %al, %r15b
je 0xb5a33
movq 0x80(%rsp), %rcx
addq %rcx, %r8
incq %rbx
incq %r12
jmp 0xb599c
movq 0x80(%rsp), %rcx
cmpb $-0x3, %r15b
ja 0xb5a33
cmpb $-0x3, %al
ja 0xb5a33
movq 0x30(%rsp), %rdi
movb (%rdi,%rsi), %al
movq 0x28(%rsp), %rcx
cmpb (%rdi,%r13), %al
jne 0xb5a2b
jmp 0xb5a33
leaq 0x1(%rbp), %rax
movq %r14, %rcx
imulq 0x90(%rsp), %rcx
cmpq 0x20(%rsp), %rax
movq 0x88(%rsp), %rdx
movq %rdx, %rax
movl $0x0, %esi
cmovbq %rsi, %rax
cmpl $0x3, %r15d
cmovneq %rdx, %rax
addq %r8, %rax
addq %rcx, %rax
addq %r14, %rbx
movq %rax, %r8
movq 0x10(%rsp), %rdx
movl 0xc(%rsp), %r9d
jmp 0xb5914
xorl %r8d, %r8d
movq %r8, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x382498(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x22f539(%rip), %rsi    # 0x2e5013
leaq 0x25f66a(%rip), %rdx    # 0x31514b
leaq 0x25f8ec(%rip), %rcx    # 0x3153d4
leaq 0x25f421(%rip), %r8     # 0x314f10
movl $0x184, %r9d            # imm = 0x184
jmp 0xb5b23
movq 0x38246a(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x22f50b(%rip), %rsi    # 0x2e5013
leaq 0x25f682(%rip), %rdx    # 0x315191
leaq 0x25f8be(%rip), %rcx    # 0x3153d4
leaq 0x25f3f3(%rip), %r8     # 0x314f10
movl $0x188, %r9d            # imm = 0x188
xorl %eax, %eax
callq 0x17a50
callq 0x17390