// File: /workspace/github_c_makefile_star2_O2/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 $0x1c8, %rsp            # imm = 0x1C8
leaq 0x10a67(%rip), %rsi     # 0x581c4
leaq 0xc67a(%rip), %rdx      # 0x53dde
leaq 0x1c(%rsp), %rcx
callq 0x4629c
testq %rax, %rax
je 0x4787c
movq %rax, %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdx
callq 0x2170
testq %rax, %rax
je 0x477c9
movq %r14, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x477ab
cmpl $0xa, %ecx
je 0x477a8
incq %rax
jmp 0x47797
movb $0x0, (%rax)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x477bb
cmpl $0x20, %ecx
jne 0x477c0
incq %rax
jmp 0x477ae
testl %ecx, %ecx
je 0x4777f
cmpl $0x21, %ecx
je 0x4777f
movq %rbx, 0x10(%rsp)
leaq 0x30(%rsp), %rax
xorl %edx, %edx
leaq 0x20(%rsp), %rbx
pushq $0x10
popq %rbp
pushq $0x1
popq %r14
movl %edx, 0x2e2b1(%rip)     # 0x75a98
testq %rax, %rax
je 0x47806
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %edx
movl %r14d, %ecx
callq 0x46190
movl 0x2e296(%rip), %edx     # 0x75a98
incl %edx
jmp 0x477e1
pushq $0x4
popq %rdi
movl %edx, %esi
callq 0x46351
movq %rax, 0x2e289(%rip)     # 0x75aa0
xorl %ebp, %ebp
testq %rax, %rax
je 0x479d3
movq %rax, %r14
movslq 0x2e26c(%rip), %r15     # 0x75a98
movq %r15, %rdi
incq %rdi
callq 0x21d0
movq %rax, 0x2e26a(%rip)     # 0x75aa8
testq %rax, %rax
je 0x479c5
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
movq 0x10(%rsp), %rbx
cmpq %rcx, %rax
je 0x47883
xorl %edx, %edx
movl %edx, 0x8(%rsp)
cmpl %r15d, %edx
jge 0x47877
movq (%r14,%rax,8), %rsi
andl $0x0, (%rsi,%rdx,4)
incq %rdx
jmp 0x47861
incq %rax
jmp 0x4785a
xorl %ebp, %ebp
jmp 0x479d3
leaq 0x30(%rsp), %r14
leaq 0x20(%rsp), %r15
pushq $0x10
popq %r12
pushq $0x1
popq %rbp
leaq 0xf990(%rip), %r13      # 0x5722b
movl $0x0, 0xc(%rsp)
movq %r14, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x478ba
cmpl $0xa, %ecx
je 0x478b7
incq %rax
jmp 0x478a6
movb $0x0, (%rax)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x478ca
cmpl $0x20, %ecx
jne 0x478cf
incq %rax
jmp 0x478bd
testl %ecx, %ecx
je 0x4795f
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x46190
movq %r15, %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
testl %eax, %eax
je 0x4797a
movslq 0xc(%rsp), %rbx
xorl %eax, %eax
movl %eax, 0x8(%rsp)
testq %r14, %r14
je 0x47951
cmpl 0x2e185(%rip), %eax     # 0x75a98
jge 0x47951
movq %r14, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x46190
movq %rax, %r14
movq 0x2e171(%rip), %rax     # 0x75aa0
movslq 0x8(%rsp), %rdx
shlq $0x2, %rdx
addq (%rax,%rbx,8), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x21f0
movl 0x8(%rsp), %eax
incl %eax
jmp 0x47904
incl 0xc(%rsp)
movq 0x10(%rsp), %rbx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %rbx, %rdx
callq 0x2170
testq %rax, %rax
jne 0x478a3
jmp 0x479bb
xorl %ecx, %ecx
movq %r14, %rax
movl %ecx, 0x8(%rsp)
testq %rax, %rax
je 0x4795f
cmpl 0x2e10a(%rip), %ecx     # 0x75a98
jge 0x4795f
movq %rax, %rdi
movq %r15, %rsi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x46190
movb 0x20(%rsp), %cl
movq 0x2e0fd(%rip), %rdx     # 0x75aa8
movslq 0x8(%rsp), %rsi
movb %cl, (%rdx,%rsi)
movl 0x8(%rsp), %ecx
incl %ecx
jmp 0x4797f
movq %rbx, %rdi
callq 0x20c0
jmp 0x479d3
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x463dc
movl %ebp, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq