// File: /workspace/github_c_makefile_star2_O3/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 0xa66e0(%rip), %rax     # 0xc0ff0
testq %rax, %rax
je 0x1a916
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, 0xa66c3(%rip)     # 0xc0ff8
jne 0x1a948
movl $0x40018, %edi          # imm = 0x40018
callq 0x2dff4
movq %rax, 0xa66b0(%rip)     # 0xc0ff8
movq %r14, %rdi
callq 0x1feba
testq %rax, %rax
je 0x1abb9
leaq 0x60(%rsp), %r13
leaq 0x73fcd(%rip), %rbp     # 0x8e932
movq %rax, 0x20(%rsp)
movq %rax, %rbx
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
movq %r12, 0x18(%rsp)
movq %rbx, %r14
movq %rbx, %rdi
movl $0xa, %esi
callq 0x6270
testq %rax, %rax
je 0x1a99d
movq %rax, %rbx
incq %rbx
movb $0x0, (%rax)
jmp 0x1a99f
xorl %ebx, %ebx
incl 0x4(%rsp)
movq %r14, %rdi
callq 0x215d4
movzbl (%rax), %ecx
testl %ecx, %ecx
je 0x1ab94
cmpl $0x23, %ecx
je 0x1ab94
movq %rax, %rdi
movq %r13, %rsi
movl $0x19, %edx
callq 0x226f5
movl %eax, %r14d
testl %r15d, %r15d
je 0x1ab29
cmpl $0x19, %r14d
je 0x1a9f6
leaq 0x7414d(%rip), %rdi     # 0x8eb35
movl 0x4(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26e94
movq 0x60(%rsp), %rdi
movsbq (%rdi), %rax
movq %rax, 0x8(%rsp)
callq 0x62d0
cmpq $0x1, %rax
jne 0x1aa23
callq 0x6790
movq (%rax), %rax
movq 0x8(%rsp), %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0x1aa38
leaq 0x7410b(%rip), %rdi     # 0x8eb35
movl 0x4(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26e94
incl %r15d
callq 0x6160
cmpl $0x2, %r14d
jl 0x1ab94
movl %r15d, 0x14(%rsp)
movq %rbx, 0x28(%rsp)
movl %r14d, %ebp
movq %rax, 0x30(%rsp)
movq (%rax), %r14
movq 0x8(%rsp), %rax
movsbq (%r14,%rax,4), %rbx
callq 0x6790
movq %rax, 0x38(%rsp)
movl %ebp, %ebp
decq %rbp
shlq $0xa, %rbx
xorl %r13d, %r13d
movq 0x68(%rsp,%r13,8), %rdi
xorl %eax, %eax
cmpb $0x2d, (%rdi)
sete %al
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movsbq (%rdi,%rax), %rax
testb $0x8, 0x1(%rcx,%rax,2)
jne 0x1aac4
leaq 0x7408e(%rip), %rdi     # 0x8eb35
movl 0x4(%rsp), %esi
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq 0x26e94
movq 0x30(%rsp), %rax
movq (%rax), %r14
movq 0x68(%rsp,%r13,8), %rdi
movsbq 0x40(%rsp,%r13), %r15
movsbq (%r14,%r15,4), %r12
callq 0x6bd0
movq 0xa651d(%rip), %rcx     # 0xc0ff8
movq 0x8(%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,%r12,4)
movl %eax, (%rcx,%r12,4)
incq %r13
cmpq %r13, %rbp
jne 0x1aa7f
movq 0x18(%rsp), %r12
leaq 0x60(%rsp), %r13
leaq 0x73e15(%rip), %rbp     # 0x8e932
movq 0x28(%rsp), %rbx
movl 0x14(%rsp), %r15d
jmp 0x1ab94
cmpl $0x18, %r14d
je 0x1ab49
leaq 0x73dbd(%rip), %rdi     # 0x8e8f3
movl 0x4(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26e94
testl %r14d, %r14d
jle 0x1ab9f
movq %rbx, %r13
movl %r14d, %ebx
xorl %r15d, %r15d
movq 0x60(%rsp,%r15,8), %r14
movq %r14, %rdi
callq 0x62d0
cmpq $0x1, %rax
je 0x1ab76
movq %rbp, %rdi
movl 0x4(%rsp), %esi
movq %r12, %rdx
xorl %eax, %eax
callq 0x26e94
movb (%r14), %al
movb %al, 0x40(%rsp,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x1ab52
movl $0x1, %r15d
movq %r13, %rbx
leaq 0x60(%rsp), %r13
testq %rbx, %rbx
jne 0x1a97d
jmp 0x1aba7
movl $0x1, %r15d
jmp 0x1ab94
movq 0x20(%rsp), %rdi
callq 0x2e0a0
cmpl $0x18, %r15d
jle 0x1abc1
jmp 0x1abd2
movq %rax, %rdi
callq 0x2e0a0
leaq 0x73da8(%rip), %rdi     # 0x8e970
movq %r12, %rsi
xorl %eax, %eax
callq 0x26e94
movq 0xa641f(%rip), %rax     # 0xc0ff8
movq %rax, 0xa6410(%rip)     # 0xc0ff0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq