// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/lib/fa.c
// Function: faReadMixedNext
boolean faReadMixedNext(FILE *f, boolean preserveCase, char *defaultName, 
    boolean mustStartWithComment, char **retCommentLine, struct dnaSeq **retSeq)
/* Read next sequence from .fa file. Return sequence in retSeq.  
 * If retCommentLine is non-null return the '>' line in retCommentLine.
 * The whole thing returns FALSE at end of file. 
 * Contains parameter to preserve mixed case. */
{
char lineBuf[1024];
int lineSize;
char *words[1];
int c;
off_t offset = ftello(f);
size_t dnaSize = 0;
DNA *dna, *sequence;
char *name = defaultName;

if (name == NULL)
    name = "";
dnaUtilOpen();
if (retCommentLine != NULL)
    *retCommentLine = NULL;
*retSeq = NULL;

/* Skip first lines until it starts with '>' */
for (;;)
    {
    if(fgets(lineBuf, sizeof(lineBuf), f) == NULL)
        {
        if (ferror(f))
            errnoAbort("read of fasta file failed");
        return FALSE;
        }
    lineSize = strlen(lineBuf);
    if (lineBuf[0] == '>')
        {
	if (retCommentLine != NULL)
            *retCommentLine = cloneString(lineBuf);
        offset = ftello(f);
        chopByWhite(lineBuf, words, ArraySize(words));
        name = words[0]+1;
        break;
        }
    else if (!mustStartWithComment)
        {
        if (fseeko(f, offset, SEEK_SET) < 0)
            errnoAbort("fseek on fasta file failed");
        break;
        }
    else
        offset += lineSize;
    }
/* Count up DNA. */
for (;;)
    {
    c = fgetc(f);
    if (c == EOF || c == '>')
        break;
    if (isalpha(c))
        {
        ++dnaSize;
        }
    }

if (dnaSize == 0)
    {
    warn("Invalid fasta format: sequence size == 0 for element %s",name);
    }

/* Allocate DNA and fill it up from file. */
dna = sequence = needHugeMem(dnaSize+1);
if (fseeko(f, offset, SEEK_SET) < 0)
    errnoAbort("fseek on fasta file failed");
for (;;)
    {
    c = fgetc(f);
    if (c == EOF || c == '>')
        break;
    if (isalpha(c))
        {
        /* check for non-DNA char */
        if (ntChars[c] == 0)
            {
            *dna++ = preserveCase ? 'N' : 'n';
            }
        else
            {
            *dna++ = preserveCase ? c : ntChars[c];
            }
        }
    }
if (c == '>')
    ungetc(c, f);
*dna = 0;

*retSeq = newDnaSeq(sequence, dnaSize, name);
if (ferror(f))
    errnoAbort("read of fasta file failed");    
return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %r9, 0x10(%rsp)
movq %r8, %r13
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, 0x8(%rsp)
movq %rdi, %r14
callq 0x6b80
movq %rax, %r12
testq %rbx, %rbx
leaq 0x64a54(%rip), %r15     # 0x8737d
cmovneq %rbx, %r15
xorl %eax, %eax
callq 0x21578
testq %r13, %r13
je 0x2293e
andq $0x0, (%r13)
movq 0x10(%rsp), %rax
andq $0x0, (%rax)
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x6c00
testq %rax, %rax
je 0x2298d
cmpb $0x3e, 0x20(%rsp)
je 0x2299c
testl %ebp, %ebp
jne 0x2294c
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x6c90
testl %eax, %eax
jns 0x229d5
leaq 0x5d0a6(%rip), %rdi     # 0x7fa2a
xorl %eax, %eax
callq 0x22504
jmp 0x229d5
movq %r14, %rdi
callq 0x6e00
xorl %ebx, %ebx
jmp 0x22ad7
testq %r13, %r13
je 0x229af
leaq 0x20(%rsp), %rdi
callq 0x1c306
movq %rax, (%r13)
movq %r14, %rdi
callq 0x6b80
movq %rax, %r12
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x1e59b
movq (%rbx), %r15
incq %r15
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x6bf0
cmpl $-0x1, %eax
je 0x22a05
movl %eax, %ebx
cmpl $0x3e, %eax
je 0x22a05
callq 0x6790
movq (%rax), %rax
movslq %ebx, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xa, %eax
adcq $0x0, %r13
jmp 0x229d8
testq %r13, %r13
jne 0x22a1b
leaq 0x5d034(%rip), %rdi     # 0x7fa45
movq %r15, %rsi
xorl %eax, %eax
callq 0x22186
leaq 0x1(%r13), %rdi
callq 0x28ad7
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x6c90
testl %eax, %eax
jns 0x22a46
leaq 0x5cfeb(%rip), %rdi     # 0x7fa2a
xorl %eax, %eax
callq 0x22504
cmpl $0x0, 0x8(%rsp)
sete %al
shlb $0x5, %al
orb $0x4e, %al
movzbl %al, %eax
movl %eax, 0xc(%rsp)
movq %rbp, %rbx
movq %r14, %rdi
callq 0x6bf0
cmpl $-0x1, %eax
je 0x22ab3
movl %eax, %r12d
cmpl $0x3e, %eax
je 0x22aa8
callq 0x6790
movq (%rax), %rcx
movslq %r12d, %rax
testb $0x4, 0x1(%rcx,%rax,2)
je 0x22a5d
cmpl $0x0, 0x8(%rsp)
leaq 0x92f00(%rip), %rcx     # 0xb5990
movzbl (%rcx,%rax), %eax
cmovel %eax, %r12d
testb %al, %al
cmovel 0xc(%rsp), %r12d
movb %r12b, (%rbx)
incq %rbx
jmp 0x22a5d
pushq $0x3e
popq %rdi
movq %r14, %rsi
callq 0x6150
movb $0x0, (%rbx)
movq %rbp, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x20688
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x6e00
pushq $0x1
popq %rbx
testl %eax, %eax
je 0x22ae9
leaq 0x5cf2e(%rip), %rdi     # 0x7fa10
xorl %eax, %eax
callq 0x22504
movl %ebx, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq