// File: /workspace/github_c_makefile_star2_O2/richarddurbin[P]hash10x/readseq.c
// Function: readMatrix
int readMatrix (char *name, int *conv, int** *mat)
{
  char matdirname[256] ;
  char fullname[512] ;
  FILE *fil ;
  char line[1024] = "#", *p;
  int i, j, nsymb, smax = 0 ;
  int symb[128] ;
  extern char* strtok (char*, const char*) ;

  if (getenv ("BLASTMAT")) 
    strcpy (matdirname, getenv ("BLASTMAT")) ;
  else
    strcpy (matdirname, "/nfs/disk100/pubseq/blastdb/") ;
  strcpy (fullname, matdirname) ;
  strcat (fullname, name) ;

  if (!(fil = fopen (name, "r")) && !(fil = fopen (fullname, "r")))
    { fprintf (stderr, "ERROR in readMatrix: could not open %s or %s\n",
	       name, matdirname) ;
      return 0 ;
    }
    
  while (!feof(fil) && *line == '#' && fgets (line, 1023, fil)) ; /* comments */
  if (feof(fil) || ferror(fil))
    { fprintf (stderr, "ERROR in readMatrix: empty file or read error\n") ;
      return 0 ;
    }

				/* character set */
  p = line ; while (*p == ' ' || *p == '\t' || *p == '\n') ++p ;
  for (i = 0 ; *p && i < 128 ; ++i)
    { symb[i] = conv[*p] ;
      if (symb[i] < -2)
	{ fprintf (stderr, "ERROR in readMatrix: illegal symbol %c\n", *p) ;
	  fclose (fil) ;
	  return 0 ;
	}
      if (symb[i] > smax)
	smax = symb[i] ;
      ++p ; while (*p == ' ' || *p == '\t' || *p == '\n') ++p ;
    }
  nsymb = i ;

  ++smax ;
  *mat = (int**) messalloc (smax * sizeof (int*)) ;
  for (i = 0 ; i < smax ; ++i)
    (*mat)[i] = (int*) messalloc (smax * sizeof (int)) ;

  for (i = 0 ; fgets(line, 1023, fil) && i < nsymb ; ++i)
    { p = line ; while (*p == ' ' || *p == '\t' || *p == '\n') ++p ;
      if (p && conv[*p] == symb[i])
	{ ++p ; while (*p == ' ' || *p == '\t' || *p == '\n') ++p ; }
      for (j = 0 ; *p && j < 128 ; ++j)
	{ if (symb[i] >= 0 && symb[j] >= 0) 
	    (*mat)[symb[i]][symb[j]] = atoi(p) ;
	  if (*p == '-') ++p ;
	  while (p && *p >= '0' && *p <= '9') ++p ;
	  while (*p == ' ' || *p == '\t' || *p == '\n') ++p ;
	}
      if (j != nsymb)
	{ fprintf (stderr, "ERROR in readMatrix: bad line: %s\n", line) ;
	  fclose (fil) ;
	  return 0 ;
	} 
    }

  fclose (fil) ;
  return 1 ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x938, %rsp            # imm = 0x938
movq %rdx, 0x8(%rsp)
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x130(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x10f0
movb $0x23, (%r15)
leaq 0x3a9d(%rip), %rdi      # 0xa840
callq 0x1030
testq %rax, %rax
je 0x6dbc
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1070
jmp 0x6dd4
movups 0x3a93(%rip), %xmm0     # 0xa856
movups %xmm0, 0x3d(%rsp)
movups 0x3a7a(%rip), %xmm0     # 0xa849
movaps %xmm0, 0x30(%rsp)
leaq 0x730(%rsp), %r15
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x1070
movq %r15, %rdi
movq %r12, %rsi
callq 0x1230
leaq 0x258e(%rip), %rsi      # 0x9389
movq %r12, %rdi
callq 0x11f0
testq %rax, %rax
jne 0x6e25
leaq 0x257a(%rip), %rsi      # 0x9389
leaq 0x730(%rsp), %rdi
callq 0x11f0
testq %rax, %rax
je 0x70d3
movq %rax, %r13
leaq 0x130(%rsp), %r12
movq %r13, %rdi
callq 0x1160
testl %eax, %eax
jne 0x6e5b
cmpb $0x23, 0x130(%rsp)
jne 0x6e5b
movq %r12, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r13, %rdx
callq 0x1110
testq %rax, %rax
jne 0x6e30
movq %r13, %rdi
callq 0x1160
testl %eax, %eax
jne 0x708a
movq %r13, %rdi
callq 0x1080
testl %eax, %eax
jne 0x708a
movabsq $0x100000600, %r14      # imm = 0x100000600
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x6e9b
btq %rax, %r14
jae 0x6e9b
incq %r12
jmp 0x6e85
xorl %edx, %edx
xorl %r15d, %r15d
testb %al, %al
je 0x6ee1
cmpq $0x7f, %rdx
ja 0x6ee1
movsbq %al, %rax
movl (%rbx,%rax,4), %ecx
movl %ecx, 0x530(%rsp,%rdx,4)
cmpl $-0x2, %ecx
jl 0x70aa
incq %r12
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x6ed5
btq %rax, %r14
jb 0x6ec1
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
incq %rdx
jmp 0x6ea0
movq %rdx, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
leal 0x8(,%r15,8), %edi
callq 0x70fa
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
leal 0x4(,%r15,4), %ebp
movl %r15d, %r15d
xorl %r12d, %r12d
cmpq %r15, %r12
ja 0x6f2b
movl %ebp, %edi
callq 0x70fa
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
jmp 0x6f0e
movl 0x10(%rsp), %eax
movq %rax, 0x28(%rsp)
xorl %ebp, %ebp
leaq 0x130(%rsp), %rbx
movq %r13, 0x18(%rsp)
movq %rbx, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r13, %rdx
callq 0x1110
testq %rax, %rax
je 0x706b
cmpq 0x28(%rsp), %rbp
jae 0x706b
leaq 0x131(%rsp), %rcx
movq %rbx, %r13
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x6f8b
btq %rax, %r14
jae 0x6f8b
incq %r13
incq %rcx
jmp 0x6f72
movsbq %al, %rdx
movl 0x530(%rsp,%rbp,4), %r12d
movq 0x20(%rsp), %rsi
cmpl %r12d, (%rsi,%rdx,4)
jne 0x6fbb
movq %rcx, %r13
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x6fbb
btq %rax, %r14
jae 0x6fbb
incq %r13
jmp 0x6fa5
xorl %r15d, %r15d
testb %al, %al
je 0x702c
cmpq $0x7f, %r15
ja 0x702c
testl %r12d, %r12d
js 0x6ff5
movslq 0x530(%rsp,%r15,4), %rbx
testq %rbx, %rbx
js 0x6ff5
movq %r13, %rdi
callq 0x1220
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, (%rcx,%rbx,4)
movb (%r13), %al
xorl %ecx, %ecx
cmpb $0x2d, %al
sete %cl
addq %rcx, %r13
decq %r13
movb 0x1(%r13), %al
incq %r13
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
jb 0x7002
jmp 0x701a
movb 0x1(%r13), %al
incq %r13
cmpb $0x20, %al
ja 0x7027
movzbl %al, %ecx
btq %rcx, %r14
jb 0x7013
incq %r15
jmp 0x6fbe
incq %rbp
cmpq 0x10(%rsp), %r15
movq 0x18(%rsp), %r13
leaq 0x130(%rsp), %rbx
je 0x6f43
movq 0x7fa2(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x3893(%rip), %rsi      # 0xa8eb
xorl %ebx, %ebx
leaq 0x130(%rsp), %rdx
xorl %eax, %eax
callq 0x1150
jmp 0x70c9
movq %r13, %rdi
callq 0x10b0
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x938, %rsp            # imm = 0x938
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7f5f(%rip), %rax      # 0xeff0
movq (%rax), %rcx
leaq 0x37f9(%rip), %rdi      # 0xa894
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1260
xorl %ebx, %ebx
jmp 0x7076
movq 0x7f3f(%rip), %rax      # 0xeff0
movq (%rax), %rdi
movsbl (%r12), %edx
leaq 0x3803(%rip), %rsi      # 0xa8c3
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1150
movq %r13, %rdi
callq 0x10b0
jmp 0x7076
movq 0x7f16(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x3782(%rip), %rsi      # 0xa866
xorl %ebx, %ebx
leaq 0x30(%rsp), %rcx
movq %r12, %rdx
xorl %eax, %eax
callq 0x1150
jmp 0x7076