// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/extended/reconstructalignment.c
// Function: gt_reconstructalignment_from_affineDtab
void gt_reconstructalignment_from_affineDtab(GtAlignment *align,
                                             const GtAffineDiagAlignentry *Dtab,
                                             GtAffineAlignEdge edge,
                                             GT_UNUSED const GtUchar *useq,
                                             GtUword ulen,
                                             GT_UNUSED const GtUchar *vseq,
                                             GtUword vlen)
{
  GtUword i,j;
  GtDiagAlignentry node, prevnode;
  GtAffineAlignEdge prevedge;
  gt_assert(align != NULL && Dtab != NULL);

  switch (edge) {
    case Affine_R:
      node = Dtab[vlen].val_R;
      break;
    case Affine_D:
      node = Dtab[vlen].val_D;
      break;
    case Affine_I:
      node = Dtab[vlen].val_I;
      break;
    default:
      gt_assert(false);
#ifdef NDEBUG
      exit(GT_EXIT_PROGRAMMING_ERROR);
#endif
  }

  for (j = ulen; j > node.currentrowindex; j--)
  {
    gt_alignment_add_deletion(align);
  }
  prevedge = edge;
  /*consider pairwise distance between prevnode and node */
  /*prevedge->prevnode, prevnode.edge->node, node.edge->nextnode*/
  for (i = vlen; i > 0; i--)
  {
    prevnode = node;
    switch (prevnode.last_type) {
      case Affine_R:
        node = Dtab[i-1].val_R;
        break;
      case Affine_D:
        node = Dtab[i-1].val_D;
        break;
      case Affine_I:
        node = Dtab[i-1].val_I;
        break;
      default:
        gt_assert(false);
#ifdef NDEBUG
        exit(GT_EXIT_PROGRAMMING_ERROR);
#endif
    }

    gt_assert(prevnode.currentrowindex != GT_UWORD_MAX);
    if (prevnode.currentrowindex == node.currentrowindex + 1)
    {
      if (prevedge == Affine_R)
      {
        gt_alignment_add_replacement(align);
      }
      else if (prevedge == Affine_D)
      {
         gt_alignment_add_deletion(align);
         gt_alignment_add_insertion(align);
      }
      else if (prevedge == Affine_I)
      {
         gt_alignment_add_insertion(align);
         gt_alignment_add_deletion(align);
      }
    }
    else if (prevnode.currentrowindex == node.currentrowindex)
    {
      gt_alignment_add_insertion(align);
    }
    else if (prevnode.currentrowindex > node.currentrowindex)
    {
      if (prevedge == Affine_R)
      {
        gt_alignment_add_replacement(align);

        for (j = 0; j < prevnode.currentrowindex - node.currentrowindex - 1;
             j++)
        {
          gt_alignment_add_deletion(align);
        }
      }
      else if (prevedge == Affine_I)
      {
        gt_alignment_add_insertion(align);
        for (j = 0; j < prevnode.currentrowindex - node.currentrowindex; j++)
        {
          gt_alignment_add_deletion(align);
        }
      }
      else
      {
        gt_assert(false);
      }
    }
    prevedge = prevnode.last_type;
  }
  for (j = node.currentrowindex; j > 0; j--)
  {
    gt_alignment_add_deletion(align);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x10f6b5
testq %rsi, %rsi
je 0x10f6b5
movq %r8, %r15
movl %edx, %ebp
movq %rdi, %rbx
movq 0x50(%rsp), %r14
cmpl $0x2, %edx
movq %rsi, 0x10(%rsp)
je 0x10f4e8
cmpl $0x1, %ebp
je 0x10f4db
testl %ebp, %ebp
jne 0x10f6e3
imulq $0x48, %r14, %rax
addq %rsi, %rax
jmp 0x10f4f3
imulq $0x48, %r14, %rax
addq %rsi, %rax
addq $0x18, %rax
jmp 0x10f4f3
imulq $0x48, %r14, %rax
addq %rsi, %rax
addq $0x30, %rax
movl 0x10(%rax), %ecx
movl %ecx, 0x4(%rsp)
movq 0x8(%rax), %r12
cmpq %r12, %r15
jbe 0x10f510
movq %rbx, %rdi
callq 0xb5258
decq %r15
jmp 0x10f4fe
movq %r12, 0x8(%rsp)
movl %ebp, %eax
movl 0x4(%rsp), %ebp
movq 0x8(%rsp), %r12
movq %r14, %r15
subq $0x1, %r15
jb 0x10f60c
cmpl $0x3, %ebp
jae 0x10f64f
cmpq $-0x1, %r12
je 0x10f621
movl %ebp, %ecx
imulq $0x18, %rcx, %rcx
imulq $0x48, %r14, %rdx
addq 0x10(%rsp), %rdx
movl -0x38(%rcx,%rdx), %esi
movl %esi, 0x4(%rsp)
movq -0x40(%rcx,%rdx), %rdx
leaq 0x1(%rdx), %rcx
cmpq %rcx, %r12
movq %rdx, 0x8(%rsp)
jne 0x10f585
cmpl $0x2, %eax
je 0x10f5d4
cmpl $0x1, %eax
je 0x10f5c2
movq %r15, %r14
testl %eax, %eax
jne 0x10f515
movq %rbx, %rdi
callq 0xb5208
jmp 0x10f5e4
movq %r12, %r13
subq %rdx, %r13
je 0x10f5ca
movq %r15, %r14
jbe 0x10f515
cmpl $0x2, %eax
je 0x10f5ec
testl %eax, %eax
jne 0x10f687
movq %rbx, %rdi
callq 0xb5208
movq 0x8(%rsp), %rax
notq %rax
addq %rax, %r12
subq $0x1, %r12
jb 0x10f5e4
movq %rbx, %rdi
callq 0xb5258
jmp 0x10f5b2
movq %rbx, %rdi
callq 0xb5258
movq %rbx, %rdi
callq 0xb52a8
jmp 0x10f5e4
movq %rbx, %rdi
callq 0xb52a8
movq %rbx, %rdi
callq 0xb5258
movq %r15, %r14
jmp 0x10f515
movq %rbx, %rdi
callq 0xb52a8
subq $0x1, %r13
jb 0x10f5e4
movq %rbx, %rdi
callq 0xb5258
jmp 0x10f5f4
movq %rbx, %rdi
callq 0xb5258
subq $0x1, %r12
jae 0x10f604
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x328940(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d59e1(%rip), %rsi    # 0x2e5013
leaq 0x2209f6(%rip), %rdx    # 0x33002f
leaq 0x2209c7(%rip), %rcx    # 0x330007
leaq 0x220889(%rip), %r8     # 0x32fed0
movl $0x157, %r9d            # imm = 0x157
jmp 0x10f67b
movq 0x328912(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d59b3(%rip), %rsi    # 0x2e5013
leaq 0x217385(%rip), %rdx    # 0x3269ec
leaq 0x220999(%rip), %rcx    # 0x330007
leaq 0x22085b(%rip), %r8     # 0x32fed0
movl $0x151, %r9d            # imm = 0x151
xorl %eax, %eax
callq 0x17a50
callq 0x17390
movq 0x3288da(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d597b(%rip), %rsi    # 0x2e5013
leaq 0x21734d(%rip), %rdx    # 0x3269ec
leaq 0x220961(%rip), %rcx    # 0x330007
leaq 0x220823(%rip), %r8     # 0x32fed0
movl $0x183, %r9d            # imm = 0x183
jmp 0x10f67b
movq 0x3288ac(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d594d(%rip), %rsi    # 0x2e5013
leaq 0x22091c(%rip), %rdx    # 0x32ffe9
leaq 0x220933(%rip), %rcx    # 0x330007
leaq 0x2207f5(%rip), %r8     # 0x32fed0
movl $0x129, %r9d            # imm = 0x129
jmp 0x10f67b
movq 0x32887e(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x1d591f(%rip), %rsi    # 0x2e5013
leaq 0x2172f1(%rip), %rdx    # 0x3269ec
leaq 0x220905(%rip), %rcx    # 0x330007
leaq 0x2207c7(%rip), %r8     # 0x32fed0
movl $0x136, %r9d            # imm = 0x136
jmp 0x10f67b