// File: /workspace/github_c_makefile_star2_O1/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, %rbx
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 0x4424(%rip), %rdi      # 0xb85a
callq 0x1030
testq %rax, %rax
je 0x744f
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0x1070
jmp 0x7467
movups 0x441a(%rip), %xmm0     # 0xb870
movups %xmm0, 0x3d(%rsp)
movups 0x4401(%rip), %xmm0     # 0xb863
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 0x3daa(%rip), %rsi      # 0xb238
movq %r12, %rdi
callq 0x11e0
testq %rax, %rax
jne 0x74b8
leaq 0x3d96(%rip), %rsi      # 0xb238
leaq 0x730(%rsp), %rdi
callq 0x11e0
testq %rax, %rax
je 0x778d
movq %rax, %r15
leaq 0x130(%rsp), %r12
movq %r15, %rdi
callq 0x1160
testl %eax, %eax
jne 0x74ee
cmpb $0x23, 0x130(%rsp)
jne 0x74ee
movq %r12, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
jne 0x74c3
movq %r15, %rdi
callq 0x1160
testl %eax, %eax
jne 0x7749
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
jne 0x7749
movabsq $0x100000600, %r14      # imm = 0x100000600
movzbl (%r12), %eax
cmpq $0x20, %rax
ja 0x752e
btq %rax, %r14
jae 0x752e
incq %r12
jmp 0x7518
movq %r15, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movb (%r12), %cl
testb %cl, %cl
movq %rbp, 0x28(%rsp)
je 0x7599
xorl %eax, %eax
xorl %r13d, %r13d
movsbq %cl, %rcx
movl (%rbp,%rcx,4), %ecx
movl %ecx, 0x530(%rsp,%rax,4)
cmpl $-0x2, %ecx
jl 0x7750
incq %r12
movzbl (%r12), %edx
cmpq $0x20, %rdx
ja 0x7576
btq %rdx, %r14
jb 0x7562
cmpl %r13d, %ecx
cmovgl %ecx, %r13d
leaq 0x1(%rax), %rdx
movb (%r12), %cl
testb %cl, %cl
je 0x7592
cmpq $0x7f, %rax
movq %rdx, %rax
jb 0x754a
movq %rdx, 0x8(%rsp)
jmp 0x75a5
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movl %r13d, %ebx
incl %ebx
leal 0x8(,%r13,8), %edi
callq 0x77b1
movq 0x18(%rsp), %r15
movq %rax, (%r15)
leal 0x4(,%r13,4), %ebp
xorl %r12d, %r12d
movl %ebp, %edi
callq 0x77b1
movq (%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x75ca
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
movq 0x8(%rsp), %rbx
testl %ebx, %ebx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x7728
movl %ebx, %eax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0x131(%rsp), %rax
movzbl (%r13), %ecx
cmpq $0x20, %rcx
ja 0x7643
btq %rcx, %r14
jae 0x7643
incq %r13
incq %rax
jmp 0x762a
movsbq %cl, %rcx
movl 0x530(%rsp,%r12,4), %ebp
movq 0x28(%rsp), %rdx
cmpl %ebp, (%rdx,%rcx,4)
jne 0x7672
movq %rax, %r13
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x7672
btq %rax, %r14
jae 0x7672
incq %r13
jmp 0x765c
cmpb $0x0, (%r13)
je 0x76f2
xorl %ebx, %ebx
testl %ebp, %ebp
js 0x76a4
movslq 0x530(%rsp,%rbx,4), %r15
testq %r15, %r15
js 0x76a4
movq %r13, %rdi
callq 0x1210
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movl %eax, (%rcx,%r15,4)
xorl %eax, %eax
cmpb $0x2d, (%r13)
sete %al
addq %rax, %r13
decq %r13
movb 0x1(%r13), %al
incq %r13
addb $-0x30, %al
cmpb $0xa, %al
jb 0x76b4
jmp 0x76c6
incq %r13
movzbl (%r13), %eax
cmpq $0x20, %rax
ja 0x76d7
btq %rax, %r14
jb 0x76c3
leaq 0x1(%rbx), %rax
cmpb $0x0, (%r13)
je 0x76eb
cmpq $0x7f, %rbx
movq %rax, %rbx
jb 0x767b
movq 0x8(%rsp), %rbx
jmp 0x76f4
xorl %eax, %eax
cmpl %ebx, %eax
movq 0x10(%rsp), %r15
leaq 0x130(%rsp), %r13
jne 0x7761
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x1110
testq %rax, %rax
je 0x7728
incq %r12
cmpq 0x20(%rsp), %r12
jb 0x7622
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
callq 0x1aee
jmp 0x775d
movq %r12, %rdi
movq 0x10(%rsp), %rsi
callq 0x1b10
xorl %ebx, %ebx
jmp 0x7735
movq 0x7888(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x4193(%rip), %rsi      # 0xb905
xorl %ebx, %ebx
leaq 0x130(%rsp), %rdx
xorl %eax, %eax
callq 0x1150
movq %r15, %rdi
callq 0x10b0
jmp 0x7735
movq 0x785c(%rip), %rax      # 0xeff0
movq (%rax), %rdi
leaq 0x40e2(%rip), %rsi      # 0xb880
xorl %ebx, %ebx
leaq 0x30(%rsp), %rcx
movq %r12, %rdx
xorl %eax, %eax
callq 0x1150
jmp 0x7735