// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/extended/reconstructalignment.c
// Function: gt_reconstructalignment_from_Dtab
void gt_reconstructalignment_from_Dtab(GtAlignment *align,
                                       const GtDiagAlignentry *Dtab,
                                       GtUword ulen, GtUword vlen)
{
  GtUword i,j;

  gt_assert(align && Dtab);

  for (j = ulen; j > Dtab[vlen].currentrowindex; j--)
  {
    gt_alignment_add_deletion(align);
  }
  for (i = vlen; i > 0; i--) {
    gt_assert(Dtab[i].currentrowindex != GT_UWORD_MAX);
    if (Dtab[i].currentrowindex == Dtab[i-1].currentrowindex + 1)
    {
      if (Dtab[i].last_type == Linear_R)
       gt_alignment_add_replacement(align);

      else if (Dtab[i].last_type == Linear_D)
      {
         gt_alignment_add_deletion(align);
         gt_alignment_add_insertion(align);
      }
      else if (Dtab[i].last_type == Linear_I)
      {
         gt_alignment_add_insertion(align);
         gt_alignment_add_deletion(align);
      }
    }
    else if (Dtab[i].currentrowindex == Dtab[i-1].currentrowindex)
      gt_alignment_add_insertion(align);

    else if (Dtab[i].currentrowindex > Dtab[i-1].currentrowindex)
    {
      if (Dtab[i].last_type == Linear_R)
      {
        gt_alignment_add_replacement(align);
        for (j = 0; j < (Dtab[i].currentrowindex -
                         Dtab[i-1].currentrowindex)-1; j++)
        {
          gt_alignment_add_deletion(align);
        }
      }
      else if (Dtab[i].last_type == Linear_I)
      {
        gt_alignment_add_insertion(align);
        for (j = 0; j < (Dtab[i].currentrowindex -
                         Dtab[i-1].currentrowindex); j++)
        {
          gt_alignment_add_deletion(align);
        }
      }
      else
      {
        gt_assert(false);
        /*for (j = 0; j < (Dtab[i].currentrowindex -
                         Dtab[i-1].currentrowindex)-1; j++)
        {
          gt_alignment_add_deletion(align);
        }
          gt_alignment_add_replacement(align);*/

      }
    }
  }
  for (j = Dtab[0].currentrowindex; j > 0; j--)
  {
    gt_alignment_add_deletion(align);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x175675
movq %rsi, %r15
testq %rsi, %rsi
je 0x175675
movq %rcx, %r14
movq %rdx, %r12
movq %rdi, %rbx
leaq (%rcx,%rcx,2), %rax
cmpq %rdx, 0x8(%r15,%rax,8)
jae 0x17554e
leaq (%r15,%rax,8), %r13
addq $0x8, %r13
movq %rbx, %rdi
callq 0x126d42
decq %r12
cmpq (%r13), %r12
ja 0x17553d
testq %r14, %r14
je 0x17564b
leaq (%r14,%r14,2), %rcx
movq 0x8(%r15,%rcx,8), %rax
cmpq $-0x1, %rax
je 0x17566b
leaq (%r15,%rcx,8), %r12
movq -0x10(%r12), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x175599
movl 0x10(%r12), %eax
cmpl $0x2, %eax
je 0x1755fd
cmpl $0x1, %eax
je 0x1755eb
testl %eax, %eax
jne 0x17560d
movq %rbx, %rdi
callq 0x126d25
jmp 0x17560d
cmpq %rcx, %rax
je 0x1755f3
jbe 0x17560d
movl 0x10(%r12), %eax
cmpl $0x2, %eax
je 0x175618
testl %eax, %eax
jne 0x175670
movq %rbx, %rdi
callq 0x126d25
movq -0x10(%r12), %rax
incq %rax
cmpq %rax, 0x8(%r12)
je 0x17560d
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x126d42
incq %r13
movq -0x10(%r12), %rax
notq %rax
addq 0x8(%r12), %rax
cmpq %rax, %r13
jb 0x1755cc
jmp 0x17560d
movq %rbx, %rdi
callq 0x126d42
movq %rbx, %rdi
callq 0x126d5f
jmp 0x17560d
movq %rbx, %rdi
callq 0x126d5f
movq %rbx, %rdi
callq 0x126d42
decq %r14
jne 0x175557
jmp 0x17564b
movq %rbx, %rdi
callq 0x126d5f
movq 0x8(%r12), %rax
cmpq -0x10(%r12), %rax
je 0x17560d
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x126d42
incq %r13
movq 0x8(%r12), %rax
subq -0x10(%r12), %rax
cmpq %rax, %r13
jb 0x17562f
jmp 0x17560d
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x175661
movq %rbx, %rdi
callq 0x126d42
decq %r14
jne 0x175654
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x522e1
callq 0x522a8
callq 0x5226f