// File: /workspace/github_c_makefile_star2_O3/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, 0x18(%rsp)
movq %rsi, %rbp
movq %rdi, %r12
leaq 0x130(%rsp), %r15
movl $0x400, %edx            # imm = 0x400
movq %r15, %rdi
xorl %esi, %esi
callq 0x10f0
movb $0x23, (%r15)
leaq 0x4287(%rip), %rdi      # 0xb880
callq 0x1030
testq %rax, %rax
je 0x7612
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1070
jmp 0x762a
movups 0x427d(%rip), %xmm0     # 0xb896
movups %xmm0, 0x3d(%rsp)
movups 0x4264(%rip), %xmm0     # 0xb889
movaps %xmm0, 0x30(%rsp)
leaq 0x730(%rsp), %r15
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x1070
movq %r15, %rdi
movq %r12, %rsi
callq 0x1220
leaq 0x2d78(%rip), %rsi      # 0xa3c9
movq %r12, %rdi
callq 0x11e0
testq %rax, %rax
jne 0x767b
leaq 0x2d64(%rip), %rsi      # 0xa3c9
leaq 0x730(%rsp), %rdi
callq 0x11e0
testq %rax, %rax
je 0x7947
movq %rax, %rbx
leaq 0x130(%rsp), %r12
movq %rbx, %rdi
callq 0x1160
testl %eax, %eax
jne 0x76b1
cmpb $0x23, 0x130(%rsp)
jne 0x76b1
movq %r12, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %rbx, %rdx
callq 0x1110
testq %rax, %rax
jne 0x7686
movq %rbx, %rdi
callq 0x1160
testl %eax, %eax
jne 0x76c9
movq %rbx, %rdi
callq 0x1080
testl %eax, %eax
je 0x76d8
callq 0x1aef
xorl %ebx, %ebx
jmp 0x78f7
incq %r12
movb (%r12), %cl
movzbl %cl, %eax
leal -0x9(%rax), %edx
cmpl $0x2, %edx
jb 0x76d5
cmpl $0x20, %eax
je 0x76d5
testl %eax, %eax
movq %rbx, 0x10(%rsp)
jne 0x7706
movl $0x1, %r13d
movq $0x0, 0x8(%rsp)
jmp 0x7761
xorl %eax, %eax
movabsq $0x100000600, %rdx      # imm = 0x100000600
xorl %r13d, %r13d
movsbq %cl, %rcx
movl (%rbp,%rcx,4), %esi
movl %esi, 0x530(%rsp,%rax,4)
cmpl $-0x2, %esi
jl 0x790b
incq %r12
movzbl (%r12), %ecx
cmpq $0x20, %rcx
ja 0x7741
btq %rcx, %rdx
jb 0x772d
cmpl %r13d, %esi
cmovgl %esi, %r13d
leaq 0x1(%rax), %rsi
testb %cl, %cl
je 0x7759
cmpq $0x7f, %rax
movq %rsi, %rax
jb 0x7715
movq %rsi, 0x8(%rsp)
incl %r13d
leal (,%r13,8), %edi
callq 0x796b
movq 0x18(%rsp), %rbx
movq %rax, (%rbx)
movl %r13d, %r14d
shll $0x2, %r13d
xorl %r15d, %r15d
movl %r13d, %edi
callq 0x796b
movq (%rbx), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %r14
jne 0x7780
leaq 0x130(%rsp), %r13
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq 0x10(%rsp), %r15
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
setne %al
cmpl $0x0, 0x8(%rsp)
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x78ea
movl 0x8(%rsp), %eax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
movabsq $0x100000600, %r14      # imm = 0x100000600
movq %rbp, 0x28(%rsp)
leaq 0x131(%rsp), %rcx
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x7809
btq %rax, %r14
jae 0x7809
incq %r13
incq %rcx
jmp 0x77f0
movsbq %al, %rdx
movl 0x530(%rsp,%r12,4), %r15d
cmpl %r15d, (%rbp,%rdx,4)
jne 0x7835
movq %rcx, %r13
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x7835
btq %rax, %r14
jae 0x7835
incq %r13
jmp 0x781f
testb %al, %al
je 0x78ad
xorl %ebp, %ebp
testl %r15d, %r15d
js 0x7868
movslq 0x530(%rsp,%rbp,4), %rbx
testq %rbx, %rbx
js 0x7868
movq %r13, %rdi
callq 0x1210
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r15,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 0x7875
jmp 0x788d
movb 0x1(%r13), %al
incq %r13
cmpb $0x20, %al
ja 0x789a
movzbl %al, %ecx
btq %rcx, %r14
jb 0x7886
leaq 0x1(%rbp), %rcx
testb %al, %al
je 0x78af
cmpq $0x7f, %rbp
movq %rcx, %rbp
jb 0x783b
jmp 0x78af
xorl %ecx, %ecx
cmpl 0x8(%rsp), %ecx
movq 0x10(%rsp), %r15
leaq 0x130(%rsp), %r13
jne 0x791b
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
movq 0x28(%rsp), %rbp
je 0x78ea
incq %r12
cmpq 0x20(%rsp), %r12
jb 0x77e8
movq %r15, %rdi
callq 0x10b0
movl $0x1, %ebx
movl %ebx, %eax
addq $0x938, %rsp            # imm = 0x938
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1b11
jmp 0x76ce
movq 0x76ce(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x3fff(%rip), %rsi      # 0xb92b
xorl %ebx, %ebx
leaq 0x130(%rsp), %rdx
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
callq 0x10b0
jmp 0x78f7
movq 0x76a2(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x3f4e(%rip), %rsi      # 0xb8a6
xorl %ebx, %ebx
leaq 0x30(%rsp), %rcx
movq %r12, %rdx
xorl %eax, %eax
callq 0x1150
jmp 0x78f7