// File: /workspace/github_c_makefile_star2_O1/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 0xa6933(%rip), %rax     # 0xc0ff0
testq %rax, %rax
je 0x1a6c3
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r12
movq %rdi, %r14
cmpq $0x0, 0xa6916(%rip)     # 0xc0ff8
jne 0x1a6f5
movl $0x40018, %edi          # imm = 0x40018
callq 0x2dc95
movq %rax, 0xa6903(%rip)     # 0xc0ff8
movq %r14, %rdi
callq 0x1f9f6
testq %rax, %rax
je 0x1a94d
leaq 0x60(%rsp), %r13
leaq 0x74180(%rip), %rbp     # 0x8e892
movq %rax, 0x30(%rsp)
movq %rax, %r15
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
movq %r12, 0x28(%rsp)
movq %r15, %r14
movq %r15, %rdi
movl $0xa, %esi
callq 0x6270
testq %rax, %rax
je 0x1a749
movq %rax, %r15
incq %r15
movb $0x0, (%rax)
jmp 0x1a74c
xorl %r15d, %r15d
incl 0xc(%rsp)
movq %r14, %rdi
callq 0x21238
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x1a933
cmpl $0x23, %ecx
je 0x1a933
movq %rax, %rdi
movq %r13, %rsi
movl $0x19, %edx
callq 0x223ad
movl %eax, %r14d
testl %ebx, %ebx
je 0x1a8c5
cmpl $0x19, %r14d
je 0x1a7a2
leaq 0x74303(%rip), %rdi     # 0x8ea97
movl 0xc(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26b6f
movq 0x60(%rsp), %rdi
movsbq (%rdi), %rax
movq %rax, 0x18(%rsp)
callq 0x62d0
cmpq $0x1, %rax
jne 0x1a7cf
callq 0x6790
movq (%rax), %rax
movq 0x18(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1a7e4
leaq 0x742c1(%rip), %rdi     # 0x8ea97
movl 0xc(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26b6f
incl %ebx
callq 0x6160
cmpl $0x2, %r14d
jl 0x1a933
movq %r15, 0x10(%rsp)
movl %ebx, 0x24(%rsp)
movq %rax, 0x38(%rsp)
movq (%rax), %rax
movq 0x18(%rsp), %rcx
movsbq (%rax,%rcx,4), %rbx
callq 0x6790
movq %rax, %r12
movl %r14d, %ebp
decq %rbp
shlq $0xa, %rbx
xorl %r13d, %r13d
movq 0x68(%rsp,%r13,8), %rax
xorl %ecx, %ecx
cmpb $0x2d, (%rax)
sete %cl
movq (%r12), %rdx
movsbq (%rax,%rcx), %rax
testb $0x8, 0x1(%rdx,%rax,2)
jne 0x1a859
leaq 0x7424e(%rip), %rdi     # 0x8ea97
movl 0xc(%rsp), %esi
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0x26b6f
movsbq 0x40(%rsp,%r13), %r15
movq 0x38(%rsp), %rax
movq (%rax), %rax
movsbq (%rax,%r15,4), %r14
movq 0x68(%rsp,%r13,8), %rdi
callq 0x6bd0
movq 0xa677b(%rip), %rcx     # 0xc0ff8
movq 0x18(%rsp), %rdx
shlq $0xa, %rdx
addq %rcx, %rdx
addq $0x8, %rdx
movl %eax, (%rdx,%r15,4)
leaq 0x8(%rcx,%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movl %eax, (%rdx,%r14,4)
movl %eax, (%rcx,%r14,4)
incq %r13
cmpq %r13, %rbp
jne 0x1a825
movq 0x28(%rsp), %r12
leaq 0x60(%rsp), %r13
leaq 0x73fd3(%rip), %rbp     # 0x8e892
movl 0x24(%rsp), %ebx
jmp 0x1a92e
cmpl $0x18, %r14d
je 0x1a8e0
leaq 0x73f81(%rip), %rdi     # 0x8e853
movl 0xc(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26b6f
movl $0x1, %ebx
testl %r14d, %r14d
jle 0x1a933
movq %r15, 0x10(%rsp)
movl %r14d, %ebx
xorl %r15d, %r15d
movq 0x60(%rsp,%r15,8), %r14
movq %r14, %rdi
callq 0x62d0
cmpq $0x1, %rax
je 0x1a919
movq %rbp, %rdi
movl 0xc(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26b6f
movb (%r14), %al
movb %al, 0x40(%rsp,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x1a8f5
movl $0x1, %ebx
movq 0x10(%rsp), %r15
testq %r15, %r15
jne 0x1a729
movq 0x30(%rsp), %rdi
callq 0x2dd41
cmpl $0x19, %ebx
jl 0x1a955
jmp 0x1a966
movq %rax, %rdi
callq 0x2dd41
leaq 0x73f74(%rip), %rdi     # 0x8e8d0
movq %r12, %rsi
xorl %eax, %eax
callq 0x26b6f
movq 0xa668b(%rip), %rax     # 0xc0ff8
movq %rax, 0xa667c(%rip)     # 0xc0ff0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq