// File: /workspace/github_c_makefile_star2_O1/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 0x1059e(%rip), %rsi     # 0x5e276
leaq 0xc1fb(%rip), %rdx      # 0x59eda
leaq 0xc(%rsp), %rcx
callq 0x4c58f
xorl %ebp, %ebp
testq %rax, %rax
je 0x4df85
movq %rax, %r13
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %rax, %rdx
callq 0x2170
testq %rax, %rax
je 0x4dd6e
xorl %ecx, %ecx
movzbl 0x20(%rsp,%rcx), %eax
testl %eax, %eax
je 0x4dd26
cmpl $0xa, %eax
jne 0x4dd69
movb $0x0, 0x20(%rsp,%rcx)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x1f, %ecx
jg 0x4dd38
cmpl $0x9, %ecx
je 0x4dd3d
jmp 0x4dd42
cmpl $0x20, %ecx
jne 0x4dd48
incq %rax
jmp 0x4dd29
testl %ecx, %ecx
je 0x4dd4d
jmp 0x4dd6e
cmpl $0x21, %ecx
jne 0x4dd6e
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %r13, %rdx
callq 0x2170
movl $0x0, %ecx
testq %rax, %rax
jne 0x4dd13
jmp 0x4dd6e
incq %rcx
jmp 0x4dd13
movl $0x0, 0x2cd20(%rip)     # 0x7aa98
leaq 0x20(%rsp), %rax
leaq 0x10(%rsp), %r14
movq %rax, %rdi
movq %r14, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c4a8
movl 0x2ccfb(%rip), %edx     # 0x7aa98
incl %edx
movl %edx, 0x2ccf3(%rip)     # 0x7aa98
testq %rax, %rax
jne 0x4dd82
movl $0x4, %edi
movl %edx, %esi
callq 0x4c647
movq %rax, 0x2cce3(%rip)     # 0x7aaa0
testq %rax, %rax
je 0x4df85
movq %rax, %r14
movslq 0x2ccc8(%rip), %r15     # 0x7aa98
leaq 0x1(%r15), %rdi
callq 0x21d0
movq %rax, 0x2ccc8(%rip)     # 0x7aaa8
testq %rax, %rax
je 0x4df77
testl %r15d, %r15d
jle 0x4de1f
xorl %eax, %eax
movl $0x0, 0x4(%rsp)
movq (%r14,%rax,8), %rcx
xorl %edx, %edx
movslq %edx, %rdx
movl $0x0, (%rcx,%rdx,4)
movl 0x4(%rsp), %edx
incl %edx
movl %edx, 0x4(%rsp)
cmpl %r15d, %edx
jl 0x4ddfe
incq %rax
cmpq %r15, %rax
jne 0x4ddf0
leaq 0x20(%rsp), %r14
leaq 0x10(%rsp), %r15
leaq 0xf4bb(%rip), %r12      # 0x5d2eb
movl $0x0, 0x8(%rsp)
movq %r14, %rax
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x4de4f
cmpl $0xa, %ecx
je 0x4de4c
incq %rax
jmp 0x4de3b
movb $0x0, (%rax)
movq %r14, %rax
movzbl (%rax), %ecx
cmpl $0x9, %ecx
je 0x4de5f
cmpl $0x20, %ecx
jne 0x4de64
incq %rax
jmp 0x4de52
testl %ecx, %ecx
je 0x4df05
movq %r14, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c4a8
movq %r15, %rdi
movq %r12, %rsi
leaq 0x4(%rsp), %rdx
xorl %eax, %eax
callq 0x21f0
movl $0x0, 0x4(%rsp)
movl 0x2cbf7(%rip), %ecx     # 0x7aa98
testl %eax, %eax
je 0x4df20
testl %ecx, %ecx
jle 0x4df01
movslq 0x8(%rsp), %rbx
movq %r14, %rbp
movq %rbp, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c4a8
movq %rax, %rbp
movq 0x2cbd0(%rip), %rax     # 0x7aaa0
movslq 0x4(%rsp), %rdx
shlq $0x2, %rdx
addq (%rax,%rbx,8), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x21f0
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
testq %rbp, %rbp
je 0x4df01
cmpl 0x2cb99(%rip), %eax     # 0x7aa98
jl 0x4deb1
incl 0x8(%rsp)
movq %r14, %rdi
movl $0x190, %esi            # imm = 0x190
movq %r13, %rdx
callq 0x2170
testq %rax, %rax
jne 0x4de38
jmp 0x4df68
testl %ecx, %ecx
jle 0x4df05
movq %r14, %rax
movq %rax, %rdi
movq %r15, %rsi
movl $0x10, %edx
movl $0x1, %ecx
callq 0x4c4a8
movb 0x10(%rsp), %cl
movq 0x2cb61(%rip), %rdx     # 0x7aaa8
movslq 0x4(%rsp), %rsi
movb %cl, (%rdx,%rsi)
movl 0x4(%rsp), %ecx
incl %ecx
movl %ecx, 0x4(%rsp)
testq %rax, %rax
je 0x4df05
cmpl 0x2cb34(%rip), %ecx     # 0x7aa98
jl 0x4df27
jmp 0x4df05
movq %r13, %rdi
callq 0x20c0
movl $0x1, %ebp
jmp 0x4df85
movq %r14, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x4c6de
movl %ebp, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq