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

   /* Now search the outside of the matrix for the highest scoring cell */
   ai    = 0;
   besti = 0;
   for(i = 1; i < length1; i++)
   {
      if(matrix[i][0] > matrix[besti][0]) besti = i;
   }
   bestj = 0;
   for(j = 1; j < length2; j++)
   {
      if(matrix[0][j] > matrix[0][bestj]) bestj = j;
   }
   if(matrix[besti][0] > matrix[0][bestj])
   {
      *BestI = besti;
      *BestJ = 0;
      for(i=0; i<*BestI; i++)
      {
         align1[ai] = seq1[i];
         align2[ai++] = '-';
      }
   }
   else
   {
      *BestI = 0;
      *BestJ = bestj;
      for(j=0; j<*BestJ; j++)
      {
         align1[ai] = '-';
         align2[ai++] = seq2[j];
      }
   }
   return(ai);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x709c4
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl (%rcx), %eax
jle 0x709b7
movl -0x38(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x709b9
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x7098b
movl $0x0, -0x34(%rbp)
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x70a0b
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x709fe
movl -0x3c(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x70a00
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x709d2
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x70a87
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x70a85
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq 0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
movb $0x2d, (%rax,%rcx)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x70a43
jmp 0x70ae5
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x70ae3
movq 0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x2d, (%rax,%rcx)
movq 0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq 0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x2c(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x70aa1
jmp 0x70ae5
movl -0x2c(%rbp), %eax
popq %rbp
retq
nopw (%rax,%rax)