// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/reconstructalignment.c
// Function: gt_reconstructalignment_from_Ctab
void gt_reconstructalignment_from_Ctab(GtAlignment *align,
                                       const GtUword *Ctab,
                                       const GtUchar *useq,
                                       GtUword ustart,
                                       const GtUchar *vseq,
                                       GtUword vstart,
                                       GtUword vlen,
                                       const GtScoreHandler *scorehandler)
{
  GtUword i,j, repl, indel, gap_opening, gap_extension;
  gt_assert(align && Ctab && scorehandler);

  gap_opening = gt_scorehandler_get_gap_opening(scorehandler);
  gap_extension = gt_scorehandler_get_gapscore(scorehandler);

  for (i = vlen; i > 0; i--) {
    if (Ctab[i] == Ctab[i-1] + 1)
    {
      if (i > 1 && Ctab[i-2] == Ctab[i-1])
        indel = 2*gap_extension + gap_opening;
      else
        indel = (2*gap_extension + 2*gap_opening);

      repl = gt_scorehandler_get_replacement(scorehandler,
                                             vseq[vstart+i-1],
                                             useq[ustart+Ctab[i]-1]);

      if (indel>repl)
        gt_alignment_add_replacement(align);
      else
      {
        gt_alignment_add_deletion(align);
        gt_alignment_add_insertion(align);
      }
    }
    else if (Ctab[i] == Ctab[i-1])
      gt_alignment_add_insertion(align);
    else if (Ctab[i] > Ctab[i-1]) {
      indel = 0; repl = 0;
      for (j = 0; j < (Ctab[i]-Ctab[i-1])-1; j++)
       gt_alignment_add_deletion(align);
      /*replacmente or insertion+deletion*/
      if (i > 1 && Ctab[i-2] == Ctab[i-1])
        indel = 2*gap_extension;
      else
        indel = (2*gap_extension+gap_opening);

      repl = gt_scorehandler_get_replacement (scorehandler,
                                              vseq[vstart+i-1],
                                              useq[ustart+Ctab[i]-j-1]);
      if (indel > repl)
        gt_alignment_add_replacement(align);
      else
      {
        gt_alignment_add_deletion(align);
        gt_alignment_add_insertion(align);
      }
    }
  }
  for (j = Ctab[0]; j > 0; j--)
    gt_alignment_add_deletion(align);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, (%rsp)
testq %rdi, %rdi
je 0x16d278
movq %rsi, %r14
testq %rsi, %rsi
je 0x16d278
movq 0x68(%rsp), %r13
testq %r13, %r13
je 0x16d278
movq %rdx, %r15
movq %rdi, %rbx
movq 0x60(%rsp), %rbp
movq %r13, %rdi
callq 0x171427
movq %rax, %r12
movq %r13, %rdi
callq 0x171437
testq %rbp, %rbp
je 0x16d254
movq %r15, %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rsi
leaq (%rsi,%rcx), %r15
decq %r15
movq (%rsp), %rsi
leaq -0x1(%rdx,%rsi), %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rax), %rcx
movq %rcx, 0x20(%rsp)
leaq (%r12,%rax,2), %rcx
movq %rcx, 0x18(%rsp)
addq %r12, %rax
addq %rax, %rax
movq %rax, 0x8(%rsp)
leaq (%rsi,%rdx), %rax
decq %rax
movq %rax, (%rsp)
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %rax
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x16d1e2
cmpq $0x1, %rbp
je 0x16d1b8
movq 0x18(%rsp), %r12
cmpq %rcx, -0x10(%r14,%rbp,8)
je 0x16d1bd
movq 0x8(%rsp), %r12
movzbl (%r15,%rbp), %esi
movq 0x10(%rsp), %rcx
movzbl (%rcx,%rax), %edx
movq %r13, %rdi
callq 0x171466
movq %rbx, %rdi
cmpq %rax, %r12
jbe 0x16d23e
callq 0x120f2d
jmp 0x16d24b
cmpq %rcx, %rax
je 0x16d243
jbe 0x16d24b
movq (%rsp), %r13
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x120f4a
incq %r12
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %rax
movq %rcx, %rdx
notq %rdx
addq %rax, %rdx
decq %r13
cmpq %rdx, %r12
jb 0x16d1f0
cmpq $0x1, %rbp
je 0x16d227
movq 0x20(%rsp), %r12
cmpq %rcx, -0x10(%r14,%rbp,8)
je 0x16d22c
movq 0x18(%rsp), %r12
movzbl (%r15,%rbp), %esi
movzbl (%r13,%rax), %edx
movq 0x68(%rsp), %r13
jmp 0x16d1cb
callq 0x120f4a
movq %rbx, %rdi
callq 0x120f67
decq %rbp
jne 0x16d194
movq (%r14), %r14
testq %r14, %r14
je 0x16d269
movq %rbx, %rdi
callq 0x120f4a
decq %r14
jne 0x16d25c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x51308