// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/NeedlemanWunsch.c
// Function: ReadMDM
int ReadMDM(char *mdmfile)
{
   FILE *mdm = NULL;
   int  i, j;
   char buffer[MAXBUFF],
        word[16],
        *p;
   int noenv;

   if((mdm=OpenFile(mdmfile, DATAENV, "r", &noenv))==NULL)
   {
      return(0);
   }

   /* Read over any comment lines                                       */
   while(fgets(buffer,MAXBUFF,mdm))
   {
      TERMINATE(buffer);
      KILLLEADSPACES(p,buffer);
      if(strlen(p) && p[0] != '!')
         break;
   }

   /* See how many fields there are in the buffer                       */
   for(p = buffer, sMDMSize = 0; p!=NULL; sMDMSize++)
     p = GetWord(p, word, 16, 1);


   /* Allocate memory for the MDM and the AA List                       */
   if((sMDMScore = (int **)Array2D(sizeof(int),sMDMSize,sMDMSize))==NULL)
      return(0);
   if((sMDM_AAList = (char *)malloc((sMDMSize+1)*sizeof(char)))==NULL)
   {
      FreeArray2D((char **)sMDMScore, sMDMSize, sMDMSize);
      return(0);
   }

   /* Fill the matrix with zeros                                        */
   for(i=0; i<sMDMSize; i++)
   {
      for(j=0; j<sMDMSize; j++)
      {
         sMDMScore[i][j] = 0;
      }
   }

   /* If our first word was a valid number, assume that numbers come
      first
   */
   i=0;
   do
   {
      TERMINATE(buffer);
      KILLLEADSPACES(p, buffer);
      if(strlen(p))
      {
         GetWord(buffer, word, 16, 1);
         if(sscanf(word,"%d",&j))    /* A row of numbers                */
         {
            for(p = buffer, j = 0; p!=NULL && j<sMDMSize; j++)
            {
               p = GetWord(p, word, 16, 1);
               sscanf(word,"%d",&(sMDMScore[i][j]));
            }
            i++;
         }
         else                        /* Amino acid names                */
         {
            for(p = buffer, j = 0; p!=NULL && j<sMDMSize; j++)
            {
               p = GetWord(p, word, 16, 1);
               sMDM_AAList[j] = word[0];
            }
         }
      }
   }  while(fgets(buffer,MAXBUFF,mdm));

   fclose(mdm);

   return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
leaq 0x105dd(%rip), %rsi     # 0x5e254
leaq 0xc200(%rip), %rdx      # 0x59e7e
leaq 0xc(%rsp), %rcx
callq 0x4c574
xorl %ebp, %ebp
testq %rax, %rax
je 0x4df16
movq %rax, %r13
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %rax, %rdx
callq 0x2170
testq %rax, %rax
je 0x4dd0d
xorl %ecx, %ecx
movzbl 0x20(%rsp,%rcx), %eax
testl %eax, %eax
je 0x4dcc5
cmpl $0xa, %eax
jne 0x4dd08
movb $0x0, 0x20(%rsp,%rcx)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x1f, %ecx
jg 0x4dcd7
cmpl $0x9, %ecx
je 0x4dcdc
jmp 0x4dce1
cmpl $0x20, %ecx
jne 0x4dce7
incq %rax
jmp 0x4dcc8
testl %ecx, %ecx
je 0x4dcec
jmp 0x4dd0d
cmpl $0x21, %ecx
jne 0x4dd0d
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %r13, %rdx
callq 0x2170
movl $0x0, %ecx
testq %rax, %rax
jne 0x4dcb2
jmp 0x4dd0d
incq %rcx
jmp 0x4dcb2
movl $0x0, 0x2cd71(%rip)     # 0x7aa88
leaq 0x20(%rsp), %rax
leaq 0x10(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c44c
movl 0x2cd4c(%rip), %edx     # 0x7aa88
incl %edx
movl %edx, 0x2cd44(%rip)     # 0x7aa88
testq %rax, %rax
jne 0x4dd21
movl $0x4, %edi
movl %edx, %esi
callq 0x4c62c
movq %rax, 0x2cd34(%rip)     # 0x7aa90
testq %rax, %rax
je 0x4df16
movq %rax, %r14
movslq 0x2cd19(%rip), %r15     # 0x7aa88
leaq 0x1(%r15), %rdi
callq 0x21e0
movq %rax, 0x2cd19(%rip)     # 0x7aa98
testq %rax, %rax
je 0x4df08
testl %r15d, %r15d
jle 0x4ddb0
xorl %eax, %eax
movq (%r14,%rax,8), %rcx
xorl %edx, %edx
movl $0x0, (%rcx,%rdx,4)
incq %rdx
movl %edx, 0x4(%rsp)
cmpl %r15d, %edx
jl 0x4dd95
incq %rax
cmpq %r15, %rax
jne 0x4dd8f
leaq 0x20(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0xf4fa(%rip), %r12      # 0x5d2bb
movl $0x0, 0x8(%rsp)
movq %r14, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x4dde0
cmpl $0xa, %ecx
je 0x4dddd
incq %rax
jmp 0x4ddcc
movb $0x0, (%rax)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x4ddf0
cmpl $0x20, %ecx
jne 0x4ddf5
incq %rax
jmp 0x4dde3
testl %ecx, %ecx
je 0x4de96
movq %r14, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c44c
movq %r15, %rdi
movq %r12, %rsi
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x2200
movl $0x0, 0x4(%rsp)
movl 0x2cc56(%rip), %ecx     # 0x7aa88
testl %eax, %eax
je 0x4deb1
testl %ecx, %ecx
jle 0x4de92
movslq 0x8(%rsp), %rbx
movq %r14, %rbp
movq %rbp, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c44c
movq %rax, %rbp
movq 0x2cc2f(%rip), %rax     # 0x7aa90
movslq 0x4(%rsp), %rdx
shlq $0x2, %rdx
addq (%rax,%rbx,8), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x2200
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
testq %rbp, %rbp
je 0x4de92
cmpl 0x2cbf8(%rip), %eax     # 0x7aa88
jl 0x4de42
incl 0x8(%rsp)
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %r13, %rdx
callq 0x2170
testq %rax, %rax
jne 0x4ddc9
jmp 0x4def9
testl %ecx, %ecx
jle 0x4de96
movq %r14, %rax
movq %rax, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c44c
movb 0x10(%rsp), %cl
movq 0x2cbc0(%rip), %rdx     # 0x7aa98
movslq 0x4(%rsp), %rsi
movb %cl, (%rdx,%rsi)
movl 0x4(%rsp), %ecx
incl %ecx
movl %ecx, 0x4(%rsp)
testq %rax, %rax
je 0x4de96
cmpl 0x2cb93(%rip), %ecx     # 0x7aa88
jl 0x4deb8
jmp 0x4de96
movq %r13, %rdi
callq 0x20c0
movl $0x1, %ebp
jmp 0x4df16
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x4c6be
movl %ebp, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq