// File: /workspace/github_c_makefile_star2_O2/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 0x10f460
movq %rsi, %r14
testq %rsi, %rsi
je 0x10f460
movq %rcx, %r15
movq %rdx, %r12
movq %rdi, %rbx
imulq $0x18, %rcx, %rax
leaq (%r14,%rax), %r13
addq $0x8, %r13
cmpq (%r13), %r12
jbe 0x10f3cf
movq %rbx, %rdi
callq 0xb5258
decq %r12
jmp 0x10f2df
imulq $0x18, %r15, %r13
movq 0x8(%r14,%r13), %rax
cmpq $-0x1, %rax
je 0x10f3fa
addq %r14, %r13
movq -0x10(%r13), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jne 0x10f33c
movl 0x10(%r13), %eax
cmpl $0x2, %eax
je 0x10f395
cmpl $0x1, %eax
je 0x10f383
movq %r12, %r15
testl %eax, %eax
jne 0x10f3cf
movq %rbx, %rdi
callq 0xb5208
jmp 0x10f3a5
cmpq %rcx, %rax
je 0x10f38b
movq %r12, %r15
jbe 0x10f3cf
movl 0x10(%r13), %eax
cmpl $0x2, %eax
je 0x10f3aa
testl %eax, %eax
jne 0x10f432
movq %rbx, %rdi
callq 0xb5208
xorl %r15d, %r15d
movq -0x10(%r13), %rax
notq %rax
addq 0x8(%r13), %rax
cmpq %rax, %r15
jae 0x10f3a5
movq %rbx, %rdi
callq 0xb5258
incq %r15
jmp 0x10f366
movq %rbx, %rdi
callq 0xb5258
movq %rbx, %rdi
callq 0xb52a8
jmp 0x10f3a5
movq %rbx, %rdi
callq 0xb52a8
movq %rbx, %rdi
callq 0xb5258
movq %r12, %r15
jmp 0x10f3cf
movq %rbx, %rdi
callq 0xb52a8
xorl %r15d, %r15d
movq 0x8(%r13), %rax
subq -0x10(%r13), %rax
cmpq %rax, %r15
jae 0x10f3a5
movq %rbx, %rdi
callq 0xb5258
incq %r15
jmp 0x10f3b5
movq %r15, %r12
subq $0x1, %r12
jae 0x10f2f6
movq 0x8(%r14), %r14
subq $0x1, %r14
jb 0x10f3f0
movq %rbx, %rdi
callq 0xb5258
jmp 0x10f3e0
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x328b67(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d5c08(%rip), %rsi    # 0x2e5013
leaq 0x220baf(%rip), %rdx    # 0x32ffc1
leaq 0x220b86(%rip), %rcx    # 0x32ff9f
leaq 0x220ab0(%rip), %r8     # 0x32fed0
movl $0xe1, %r9d
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x328b2f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d5bd0(%rip), %rsi    # 0x2e5013
leaq 0x2175a2(%rip), %rdx    # 0x3269ec
leaq 0x220b4e(%rip), %rcx    # 0x32ff9f
leaq 0x220a78(%rip), %r8     # 0x32fed0
movl $0x10b, %r9d            # imm = 0x10B
jmp 0x10f426
movq 0x328b01(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d5ba2(%rip), %rsi    # 0x2e5013
leaq 0x220b19(%rip), %rdx    # 0x32ff91
leaq 0x220b20(%rip), %rcx    # 0x32ff9f
leaq 0x220a4a(%rip), %r8     # 0x32fed0
movl $0xda, %r9d
jmp 0x10f426