// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/lib/axt.c
// Function: axtScoreSchemeFromProteinText
struct axtScoreScheme *axtScoreSchemeFromProteinText(char *text, char *fileName)
/* Parse text into a scoring scheme.  This should be in BLAST protein matrix
 * format as in blosumText above. */
{
char *line, *nextLine;
int lineIx = 0;
int realCount = 0;
char columns[24];
char *row[25];
char *txt;
int i;
static struct axtScoreScheme *ss;
static struct axtScoreScheme *tt;

if (ss != NULL)
    return ss;
if (tt == NULL)
    AllocVar(tt);

txt = cloneString(text);
for (line = txt; line != NULL; line = nextLine)
    {
    nextLine = strchr(line, '\n');
    if (nextLine != NULL)
        *nextLine++ = 0;
    ++lineIx;
    line = skipLeadingSpaces(line);
    if (line[0] == '#' || line[0] == 0)
        continue;
    ++realCount;
    if (realCount == 1)
        {
	int wordCount = chopLine(line, row);
	if (wordCount != 24)
	    errAbort("Not a good protein matrix - expecting 24 letters line %d of %s", lineIx, fileName);
	for (i=0; i<wordCount; ++i)
	    {
	    char *letter = row[i];
	    if (strlen(letter) != 1)
		errAbort("Not a good protein matrix - got word not letter line %d of %s", lineIx, fileName);
	    columns[i] = letter[0];
	    }
	}
    else
        {
	int wordCount = chopLine(line, row);
	char letter, lcLetter;
	if (wordCount != 25)
	    badProteinMatrixLine(lineIx, fileName);
	letter = row[0][0];
	if (strlen(row[0]) != 1 || isdigit(letter))
	    badProteinMatrixLine(lineIx, fileName);
	lcLetter = tolower(letter);
	for (i=1; i<wordCount; ++i)
	    {
	    char *s = row[i];
	    int val;
	    char otherLetter, lcOtherLetter;
	    if (s[0] == '-') ++s;
	    if (!isdigit(s[0]))
		badProteinMatrixLine(lineIx, fileName);
	    otherLetter = columns[i-1];
	    lcOtherLetter = tolower(otherLetter);
	    val = atoi(row[i]);
	    tt->matrix[(int)letter][(int)otherLetter] = val;
	    tt->matrix[(int)lcLetter][(int)otherLetter] = val;
	    tt->matrix[(int)letter][(int)lcOtherLetter] = val;
	    tt->matrix[(int)lcLetter][(int)lcOtherLetter] = val;
	    }
	}
    }
freeMem(txt);
if (realCount < 25)
    errAbort("Unexpected end of %s", fileName);
ss = tt;
return ss;
}

// Assembly:
movq 0x9dc01(%rip), %rax     # 0xb5010
testq %rax, %rax
je 0x17415
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %rbp
movq %rdi, %r14
cmpq $0x0, 0x9dbe4(%rip)     # 0xb5018
jne 0x17447
movl $0x40018, %edi          # imm = 0x40018
callq 0x28bb0
movq %rax, 0x9dbd1(%rip)     # 0xb5018
movq %r14, %rdi
callq 0x1c306
movq %rax, %rbx
pushq $0xa
popq %r13
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
movq %rax, %r14
incl %r15d
movq %r14, %r12
testq %r14, %r14
je 0x17671
movq %r12, %rdi
movl %r13d, %esi
callq 0x6270
testq %rax, %rax
je 0x1748e
movq %rax, %r14
incq %r14
movb $0x0, (%rax)
jmp 0x17491
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x1d6a7
movzbl (%rax), %ecx
cmpl $0x23, %ecx
je 0x17464
testl %ecx, %ecx
je 0x17464
movq %rax, %rdi
leaq 0x60(%rsp), %rsi
pushq $0x19
popq %rdx
callq 0x1e59b
movl %eax, %r12d
cmpl $0x0, 0x4(%rsp)
movq %rbx, 0x10(%rsp)
je 0x175fb
cmpl $0x19, %r12d
je 0x174d9
movl %r15d, %edi
movq %rbp, %rsi
callq 0x176b1
movq 0x60(%rsp), %rdi
movsbq (%rdi), %rax
movq %rax, 0x8(%rsp)
callq 0x62d0
cmpq $0x1, %rax
jne 0x17506
callq 0x6790
movq (%rax), %rax
movq 0x8(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x17511
movl %r15d, %edi
movq %rbp, %rsi
callq 0x176b1
movq %rbp, 0x18(%rsp)
incl 0x4(%rsp)
callq 0x6160
movq %rax, 0x28(%rsp)
movq (%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x20(%rsp)
movsbq (%rcx,%rax,4), %rax
movslq %r12d, %rcx
movq %rcx, 0x38(%rsp)
shlq $0xa, %rax
movq %rax, 0x30(%rsp)
pushq $0x1
popq %rbx
cmpq 0x38(%rsp), %rbx
jge 0x175ec
movq 0x60(%rsp,%rbx,8), %r12
xorl %r13d, %r13d
cmpb $0x2d, (%r12)
sete %r13b
callq 0x6790
movq (%rax), %rax
movsbq (%r12,%r13), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x17599
movl %r15d, %edi
movq 0x18(%rsp), %rsi
callq 0x176b1
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp,%rbx,8), %r12
movsbq 0x3f(%rsp,%rbx), %r13
movq 0x20(%rsp), %rax
movsbq (%rax,%r13,4), %rbp
movq %r12, %rdi
callq 0x6bd0
movq 0x9da60(%rip), %rcx     # 0xb5018
movq 0x8(%rsp), %rdx
shlq $0xa, %rdx
addq %rcx, %rdx
addq $0x8, %rdx
movl %eax, (%rdx,%r13,4)
movq 0x30(%rsp), %rsi
leaq 0x8(%rcx,%rsi), %rcx
movl %eax, (%rcx,%r13,4)
movl %eax, (%rdx,%rbp,4)
movl %eax, (%rcx,%rbp,4)
incq %rbx
pushq $0xa
popq %r13
jmp 0x1754a
movq 0x18(%rsp), %rbp
movq 0x10(%rsp), %rbx
jmp 0x17464
cmpl $0x18, %r12d
je 0x17615
leaq 0x66243(%rip), %rdi     # 0x7d84b
movl %r15d, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x223fb
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x17660
movq 0x60(%rsp,%rbx,8), %r13
movq %r13, %rdi
callq 0x62d0
cmpq $0x1, %rax
je 0x1764f
leaq 0x66248(%rip), %rdi     # 0x7d88a
movl %r15d, %esi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x223fb
movb (%r13), %al
movb %al, 0x40(%rsp,%rbx)
incq %rbx
pushq $0xa
popq %r13
jmp 0x17623
pushq $0x1
popq %rax
movl %eax, 0x4(%rsp)
movq 0x10(%rsp), %rbx
jmp 0x17464
movq %rbx, %rdi
callq 0x28c2d
cmpl $0x18, 0x4(%rsp)
jg 0x17691
leaq 0x66241(%rip), %rdi     # 0x7d8c8
movq %rbp, %rsi
xorl %eax, %eax
callq 0x223fb
movq 0x9d980(%rip), %rax     # 0xb5018
movq %rax, 0x9d971(%rip)     # 0xb5010
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq