// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/NeedlemanWunsch.c
// Function: TraceBack
static int TraceBack(int  **matrix,
                     XY   **dirn,
                     int  length1,
                     int  length2,
                     char *seq1,
                     char *seq2,
                     char *align1,
                     char *align2,
                     int  *align_len)
{
   int   i,    j,
         ai,
         BestI,BestJ;
   XY    nextCell;

   ai = SearchForBest(matrix, length1, length2, &BestI, &BestJ,
                       seq1, seq2, align1, align2);

   /* Now trace back to find the alignment                              */
   i            = BestI;
   j            = BestJ;
   align1[ai]   = seq1[i];
   align2[ai++] = seq2[j];

   while(i < length1-1 && j < length2-1)
   {
      nextCell.x = dirn[i][j].x;
      nextCell.y = dirn[i][j].y;
      if((nextCell.x == i+1) && (nextCell.y == j+1))
      {
         /* We are inheriting from the diagonal                         */
         i++;
         j++;
      }
      else if(nextCell.y == j+1)
      {
         /* We are inheriting from the off-diagonal inserting a gap in
            the y-sequence (seq2)
         */
         i++;
         j++;
         while((i < nextCell.x) && (i < length1-1))
         {
            align1[ai] = seq1[i++];
            align2[ai++] = '-';
         }
      }
      else if(nextCell.x == i+1)
      {
         /* We are inheriting from the off-diagonal inserting a gap in
            the x-sequence (seq1)
         */
         i++;
         j++;
         while((j < nextCell.y) && (j < length2-1))
         {
            align1[ai] = '-';
            align2[ai++] = seq2[j++];
         }
      }
      else
      {
         /* Cockup!                                                     */
         fprintf(stderr,"align.c/TraceBack() internal error\n");
      }

      align1[ai]   = seq1[i];
      align2[ai++] = seq2[j];
   }

   /* If one sequence finished first, fill in the end with insertions   */
   if(i < length1-1)
   {
      for(j=i+1; j<length1; j++)
      {
         align1[ai]   = seq1[j];
         align2[ai++] = '-';
      }
   }
   else if(j < length2-1)
   {
      for(i=j+1; i<length2; i++)
      {
         align1[ai]   = '-';
         align2[ai++] = seq2[i];
      }
   }

   *align_len = ai;

   return(matrix[BestI][BestJ]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r11
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
leaq -0x38(%rbp), %rcx
leaq -0x3c(%rbp), %r8
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x70950
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
movl -0x14(%rbp), %edx
subl $0x1, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x45(%rbp)
jge 0x6f377
movl -0x30(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x6f383
jmp 0x6f53b
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x30(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6f3e1
movl -0x40(%rbp), %eax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6f3e1
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6f500
movl -0x40(%rbp), %eax
movl -0x30(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6f464
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x44(%rbp), %ecx
movb %al, -0x46(%rbp)
jge 0x6f41e
movl -0x2c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0x6f427
jmp 0x6f45f
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0x2d, (%rax,%rcx)
jmp 0x6f400
jmp 0x6f4fe
movl -0x44(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6f4e4
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x40(%rbp), %ecx
movb %al, -0x47(%rbp)
jge 0x6f4a1
movl -0x30(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x47(%rbp)
movb -0x47(%rbp), %al
testb $0x1, %al
jne 0x6f4aa
jmp 0x6f4e2
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movq -0x28(%rbp), %rax
movl -0x30(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x30(%rbp)
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x6f483
jmp 0x6f4fc
movq 0x1ab0d(%rip), %rax     # 0x89ff8
movq (%rax), %rdi
leaq 0x141ad(%rip), %rsi     # 0x836a2
movb $0x0, %al
callq 0x1150
jmp 0x6f4fe
jmp 0x6f500
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x6f354
movl -0x2c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6f592
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x6f590
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0x2d, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6f551
jmp 0x6f5eb
movl -0x30(%rbp), %eax
movl -0x18(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x6f5e9
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x6f5e7
movq 0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6f5a8
jmp 0x6f5e9
jmp 0x6f5eb
movl -0x34(%rbp), %ecx
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)