// File: /workspace/github_c_makefile_star2_O3/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 0x710bf(%rip), %r15     # 0x98454
cmovneq %rbx, %r15
xorl %eax, %eax
callq 0x25e47
testq %r13, %r13
je 0x273ad
movq $0x0, (%r13)
movq 0x10(%rsp), %rax
movq $0x0, (%rax)
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x6c00
testq %rax, %rax
je 0x273f5
leaq 0x20(%rsp), %rbx
cmpb $0x3e, 0x20(%rsp)
je 0x27404
testl %ebp, %ebp
je 0x27441
movq %rbx, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x6c00
testq %rax, %rax
jne 0x273d5
movq %r14, %rdi
callq 0x6e00
xorl %ebx, %ebx
jmp 0x27566
testq %r13, %r13
je 0x27417
leaq 0x20(%rsp), %rdi
callq 0x1feba
movq %rax, (%r13)
movq %r14, %rdi
callq 0x6b80
movq %rax, %r12
leaq 0x20(%rsp), %rdi
leaq 0x18(%rsp), %rbx
movq %rbx, %rsi
movl $0x1, %edx
callq 0x226f5
movq (%rbx), %r15
incq %r15
jmp 0x27460
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x6c90
testl %eax, %eax
jns 0x27460
leaq 0x696d1(%rip), %rdi     # 0x90b2a
xorl %eax, %eax
callq 0x26fc7
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x6bf0
cmpl $-0x1, %eax
je 0x27490
movl %eax, %ebx
cmpl $0x3e, %eax
je 0x27490
callq 0x6790
movq (%rax), %rax
movslq %ebx, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xa, %eax
adcq $0x0, %r13
jmp 0x27463
testq %r13, %r13
jne 0x274a6
leaq 0x696a9(%rip), %rdi     # 0x90b45
movq %r15, %rsi
xorl %eax, %eax
callq 0x26bea
leaq 0x1(%r13), %rdi
callq 0x2df1b
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x6c90
testl %eax, %eax
jns 0x274d1
leaq 0x69660(%rip), %rdi     # 0x90b2a
xorl %eax, %eax
callq 0x26fc7
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 0x27540
movl %eax, %r12d
cmpl $0x3e, %eax
je 0x27533
callq 0x6790
movq (%rax), %rcx
movslq %r12d, %rax
testb $0x4, 0x1(%rcx,%rax,2)
je 0x274e8
cmpl $0x0, 0x8(%rsp)
leaq 0x9a455(%rip), %rcx     # 0xc1970
movzbl (%rcx,%rax), %eax
cmovel %eax, %r12d
testb %al, %al
cmovel 0xc(%rsp), %r12d
movb %r12b, (%rbx)
incq %rbx
jmp 0x274e8
movl $0x3e, %edi
movq %r14, %rsi
callq 0x6150
movb $0x0, (%rbx)
movq %rbp, %rdi
movl %r13d, %esi
movq %r15, %rdx
callq 0x24cf8
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
callq 0x6e00
movl $0x1, %ebx
testl %eax, %eax
je 0x27578
leaq 0x6959f(%rip), %rdi     # 0x90b10
xorl %eax, %eax
callq 0x26fc7
movl %ebx, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq