// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/extended/reconstructalignment.c
// Function: gt_reconstructalignment_from_EDtab
void gt_reconstructalignment_from_EDtab(GtAlignment *align,
                                        GtUword * const *E,
                                        const GtUchar *useq,
                                        GtUword ustart,
                                        GtUword ulen,
                                        const GtUchar *vseq,
                                        GtUword vstart,
                                        GtUword vlen,
                                        const GtScoreHandler *scorehandler)
{
  GtUword i = ulen, j = vlen, gapcost;
  const GtUchar *uptr = useq + ustart - 1, *vptr = vseq + vstart - 1;

  gt_assert(align && E && scorehandler);
  gapcost = gt_scorehandler_get_gapscore(scorehandler);
  while (i > 0 || j > 0)
  {
    if (i > 0 && j > 0 && E[i][j] == E[i-1][j-1] +
                                     gt_scorehandler_get_replacement(
                                                          scorehandler,
                                                          uptr[i],vptr[j]))
    {
      gt_alignment_add_replacement(align);
      i--;
      j--;
      continue;
    }
    if (j > 0 && E[i][j] == E[i][j-1] + gapcost)
    {
      gt_alignment_add_insertion(align);
      j--;
      continue;
    }
    if (i > 0 && E[i][j] == E[i-1][j] + gapcost)
    {
      gt_alignment_add_deletion(align);
      i--;
      continue;
    }
    gt_assert(false);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x8(%rsp)
movq %rdx, (%rsp)
testq %rdi, %rdi
je 0x16cee4
movq %rsi, %rbx
testq %rsi, %rsi
je 0x16cee4
movq %rdi, %r12
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x16cee4
movq %r9, %r14
movq %r8, %r15
movq 0x68(%rsp), %rbp
callq 0x171437
movq %rax, %r13
movq %r15, %rax
orq %rbp, %rax
je 0x16ced0
movq 0x60(%rsp), %rax
movq 0x8(%rsp), %rcx
movq (%rsp), %rdx
addq %rdx, %rcx
decq %rcx
movq %rcx, 0x18(%rsp)
addq %r14, %rax
decq %rax
movq %rax, 0x10(%rsp)
testq %r15, %r15
setne %r14b
testq %rbp, %rbp
setne %cl
movq %r13, 0x20(%rsp)
movb %cl, 0x8(%rsp)
movl %r14d, %eax
andb %cl, %al
testb $0x1, %al
je 0x16ce48
movq -0x8(%rbx,%r15,8), %rax
movq (%rbx,%r15,8), %rcx
movq (%rcx,%rbp,8), %rcx
movq %rcx, (%rsp)
movq %rbx, %r13
movq %r12, %rbx
movq -0x8(%rax,%rbp,8), %r12
movq 0x18(%rsp), %rax
movzbl (%rax,%r15), %esi
movq 0x10(%rsp), %rax
movzbl (%rax,%rbp), %edx
movq 0x70(%rsp), %rdi
callq 0x171466
addq %r12, %rax
movq %rbx, %r12
movq %r13, %rbx
movq 0x20(%rsp), %r13
cmpq %rax, (%rsp)
jne 0x16ce4d
jmp 0x16ceac
testb $0x1, %cl
je 0x16ce5f
movq (%rbx,%r15,8), %rax
movq -0x8(%rax,%rbp,8), %rcx
addq %r13, %rcx
cmpq %rcx, (%rax,%rbp,8)
je 0x16cea2
testb $0x1, %r14b
je 0x16cedf
movq -0x8(%rbx,%r15,8), %rax
movq (%rbx,%r15,8), %rcx
movq (%rax,%rbp,8), %rax
addq %r13, %rax
cmpq %rax, (%rcx,%rbp,8)
jne 0x16cedf
movq %r12, %rdi
callq 0x120f4a
cmpq $0x1, %r15
leaq -0x1(%r15), %r15
setne %r14b
movl %r14d, %eax
movb 0x8(%rsp), %cl
orb %cl, %al
testb $0x1, %al
jne 0x16cdf0
jmp 0x16ced0
movq %r12, %rdi
callq 0x120f67
jmp 0x16ceb7
movq %r12, %rdi
callq 0x120f2d
decq %r15
decq %rbp
setne %cl
testq %r15, %r15
setne %r14b
movq %r15, %rax
orq %rbp, %rax
jne 0x16cdec
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5122a
callq 0x511f3