// File: /workspace/github_c_makefile_star2_O3/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 0x16d3ef
movq %rsi, %r15
testq %rsi, %rsi
je 0x16d3ef
movq %rcx, %r14
movq %rdx, %r12
movq %rdi, %rbx
leaq (%rcx,%rcx,2), %rax
cmpq %rdx, 0x8(%r15,%rax,8)
jae 0x16d2c8
leaq (%r15,%rax,8), %r13
addq $0x8, %r13
movq %rbx, %rdi
callq 0x120f4a
decq %r12
cmpq (%r13), %r12
ja 0x16d2b7
testq %r14, %r14
je 0x16d3c5
leaq (%r14,%r14,2), %rcx
movq 0x8(%r15,%rcx,8), %rax
cmpq $-0x1, %rax
je 0x16d3e5
leaq (%r15,%rcx,8), %r12
movq -0x10(%r12), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x16d313
movl 0x10(%r12), %eax
cmpl $0x2, %eax
je 0x16d377
cmpl $0x1, %eax
je 0x16d365
testl %eax, %eax
jne 0x16d387
movq %rbx, %rdi
callq 0x120f2d
jmp 0x16d387
cmpq %rcx, %rax
je 0x16d36d
jbe 0x16d387
movl 0x10(%r12), %eax
cmpl $0x2, %eax
je 0x16d392
testl %eax, %eax
jne 0x16d3ea
movq %rbx, %rdi
callq 0x120f2d
movq -0x10(%r12), %rax
incq %rax
cmpq %rax, 0x8(%r12)
je 0x16d387
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x120f4a
incq %r13
movq -0x10(%r12), %rax
notq %rax
addq 0x8(%r12), %rax
cmpq %rax, %r13
jb 0x16d346
jmp 0x16d387
movq %rbx, %rdi
callq 0x120f4a
movq %rbx, %rdi
callq 0x120f67
jmp 0x16d387
movq %rbx, %rdi
callq 0x120f67
movq %rbx, %rdi
callq 0x120f4a
decq %r14
jne 0x16d2d1
jmp 0x16d3c5
movq %rbx, %rdi
callq 0x120f67
movq 0x8(%r12), %rax
cmpq -0x10(%r12), %rax
je 0x16d387
xorl %r13d, %r13d
movq %rbx, %rdi
callq 0x120f4a
incq %r13
movq 0x8(%r12), %rax
subq -0x10(%r12), %rax
cmpq %rax, %r13
jb 0x16d3a9
jmp 0x16d387
movq 0x8(%r15), %r14
testq %r14, %r14
je 0x16d3db
movq %rbx, %rdi
callq 0x120f4a
decq %r14
jne 0x16d3ce
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
callq 0x513b3
callq 0x5137a
callq 0x51341