// File: /workspace/github_c_makefile_star2_O2/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 %rdx, (%rsp)
testq %rdi, %rdi
je 0x10f274
movq %rsi, %r14
testq %rsi, %rsi
je 0x10f274
movq 0x68(%rsp), %rbp
testq %rbp, %rbp
je 0x10f274
movq %rcx, %r13
movq %rdi, %rbx
movq 0x60(%rsp), %r12
movq %rbp, %rdi
callq 0x114a29
movq %rax, %r15
movq %rbp, %rdi
callq 0x114a6a
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
addq %rdx, %rcx
decq %rcx
movq %rcx, 0x8(%rsp)
movq (%rsp), %rcx
leaq -0x1(%rcx,%r13), %rcx
movq %rcx, (%rsp)
leaq (%rax,%rax), %rcx
movq %rcx, 0x20(%rsp)
leaq (%r15,%rax,2), %rcx
movq %rcx, 0x18(%rsp)
addq %r15, %rax
addq %rax, %rax
movq %rax, 0x10(%rsp)
movq %r12, %r13
subq $0x1, %r12
jb 0x10f252
movq (%r14,%r13,8), %rax
movq (%r14,%r12,8), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x10f1dc
cmpq $0x1, %r13
je 0x10f1ae
movq 0x18(%rsp), %r15
cmpq %rcx, -0x8(%r14,%r12,8)
je 0x10f1b3
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %rcx
movzbl (%rcx,%r13), %esi
movq (%rsp), %rcx
movzbl (%rcx,%rax), %edx
movq %rbp, %rdi
callq 0x114b2c
movq %rbx, %rdi
cmpq %rax, %r15
jbe 0x10f210
callq 0xb5208
jmp 0x10f17e
cmpq %rcx, %rax
je 0x10f215
jbe 0x10f17e
movq (%rsp), %rbp
xorl %r15d, %r15d
movq %rcx, %rdx
notq %rdx
addq %rax, %rdx
cmpq %rdx, %r15
jae 0x10f222
movq %rbx, %rdi
callq 0xb5258
incq %r15
movq (%r14,%r13,8), %rax
movq (%r14,%r12,8), %rcx
decq %rbp
jmp 0x10f1ea
callq 0xb5258
movq %rbx, %rdi
callq 0xb52a8
jmp 0x10f17e
cmpq $0x1, %r13
je 0x10f234
movq 0x20(%rsp), %r15
cmpq %rcx, -0x8(%r14,%r12,8)
je 0x10f239
movq 0x18(%rsp), %r15
movq 0x8(%rsp), %rcx
movzbl (%rcx,%r13), %esi
movzbl (%rbp,%rax), %edx
movq 0x68(%rsp), %rbp
jmp 0x10f1c5
movq (%r14), %r14
subq $0x1, %r14
jb 0x10f265
movq %rbx, %rdi
callq 0xb5258
jmp 0x10f255
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x328ced(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d5d8e(%rip), %rsi    # 0x2e5013
leaq 0x220cc5(%rip), %rdx    # 0x32ff51
leaq 0x220cdc(%rip), %rcx    # 0x32ff6f
leaq 0x220c36(%rip), %r8     # 0x32fed0
movl $0x9e, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390