// File: /workspace/github_c_makefile_star2_O1/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 0x1754fe
movq %rsi, %r14
testq %rsi, %rsi
je 0x1754fe
movq 0x68(%rsp), %r13
testq %r13, %r13
je 0x1754fe
movq %rdx, %r15
movq %rdi, %rbx
movq 0x60(%rsp), %rbp
movq %r13, %rdi
callq 0x1797eb
movq %rax, %r12
movq %r13, %rdi
callq 0x1797fb
testq %rbp, %rbp
je 0x1754da
movq %r15, %rdx
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rsi
leaq (%rsi,%rcx), %r15
decq %r15
movq (%rsp), %rsi
leaq (%rdx,%rsi), %rcx
movq %rcx, 0x20(%rsp)
leaq -0x1(%rdx,%rsi), %rcx
movq %rcx, 0x10(%rsp)
leaq (%rax,%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq (%r12,%rax,2), %rcx
movq %rcx, (%rsp)
addq %r12, %rax
addq %rax, %rax
movq %rax, 0x8(%rsp)
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %rax
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x17544c
cmpq $0x1, %rbp
je 0x17541b
movq (%rsp), %r12
cmpq %rcx, -0x10(%r14,%rbp,8)
je 0x175420
movq 0x8(%rsp), %r12
movzbl (%r15,%rbp), %esi
movq 0x10(%rsp), %rcx
movzbl (%rcx,%rax), %edx
movq %r13, %rdi
callq 0x17982a
movq %rbx, %rdi
cmpq %rax, %r12
jbe 0x1754c4
callq 0x126d25
jmp 0x1754d1
cmpq %rcx, %rax
je 0x1754c9
jbe 0x1754d1
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %rax
leaq 0x1(%rcx), %rdx
movq $-0x1, %r13
cmpq %rdx, %rax
je 0x175494
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x126d42
incq %r13
movq -0x8(%r14,%rbp,8), %rcx
movq (%r14,%rbp,8), %rax
movq %rcx, %rdx
notq %rdx
addq %rax, %rdx
cmpq %rdx, %r13
jb 0x17546f
notq %r13
cmpq $0x1, %rbp
je 0x1754a6
movq 0x18(%rsp), %r12
cmpq %rcx, -0x10(%r14,%rbp,8)
je 0x1754aa
movq (%rsp), %r12
movzbl (%r15,%rbp), %esi
addq 0x20(%rsp), %rax
movzbl (%r13,%rax), %edx
movq 0x68(%rsp), %r13
jmp 0x17542e
callq 0x126d42
movq %rbx, %rdi
callq 0x126d5f
decq %rbp
jne 0x1753f8
movq (%r14), %r14
testq %r14, %r14
je 0x1754ef
movq %rbx, %rdi
callq 0x126d42
decq %r14
jne 0x1754e2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x52236