// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/pat.cpp
// Function: FastaPatternSource::parse(Read&, Read&, unsigned long) const
bool FastaPatternSource::parse(Read& r, Read& rb, TReadId rdid) const {
	// We assume the light parser has put the raw data for the separate ends
	// into separate Read objects.  That doesn't have to be the case, but
	// that's how we've chosen to do it for FastqPatternSource
	assert(!r.readOrigBuf.empty());
	assert(r.empty());
	int c = -1;
	size_t cur = 1;
	const size_t buflen = r.readOrigBuf.length();

	// Parse read name
	assert(r.name.empty());
	while(cur < buflen) {
		c = r.readOrigBuf[cur++];
		if(c == '\n' || c == '\r') {
			do {
				c = r.readOrigBuf[cur++];
			} while((c == '\n' || c == '\r') && cur < buflen);
			break;
		}
		r.name.append(c);
	}
	if(cur >= buflen) {
		return false; // FASTA ended prematurely
	}

	// Parse sequence
	int nchar = 0;
	assert(r.patFw.empty());
	assert(c != '\n' && c != '\r');
	assert_lt(cur, buflen);
	while(c != '\n' && cur < buflen) {
		if(c == '.') {
			c = 'N';
		}
		if(isalpha(c)) {
			// If it's past the 5'-end trim point
			if(nchar++ >= this->trim5_) {
				r.patFw.append(asc2dna[c]);
			}
		}
		assert_lt(cur, buflen);
		c = r.readOrigBuf[cur++];
	}
	// record amt trimmed from 5' end due to --trim5
	r.trimmed5 = (int)(nchar - r.patFw.length());
	// record amt trimmed from 3' end due to --trim3
	r.trimmed3 = (int)(r.patFw.trimEnd(this->trim3_));

	for(size_t i = 0; i < r.patFw.length(); i++) {
		r.qual.append('I');
	}

	// Set up a default name if one hasn't been set
	if(r.name.empty()) {
		char cbuf[20];
		itoa10<TReadId>(static_cast<TReadId>(rdid), cbuf);
		r.name.install(cbuf);
	}
	r.parsed = true;
	if(!rb.parsed && rb.readOrigBuf.length() > 0) {
		return parse(rb, r, rdid);
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, (%rsp)
movq 0x140(%rsi), %r15
leaq 0x150(%rsi), %rax
movq %rax, 0x18(%rsp)
pushq $0x1
popq %r12
pushq $-0x1
popq %rbp
leaq 0x20(%rsp), %rbx
cmpq %r15, %r12
jae 0x42322
movq 0x128(%r14), %rax
movzbl (%rax,%r12), %ecx
cmpl $0xd, %ecx
je 0x422fb
cmpl $0xa, %ecx
je 0x422fb
movsbl %cl, %ebp
movb %bpl, 0x20(%rsp)
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x43902
incq %r12
jmp 0x422c6
incq %r12
movq %r12, %rcx
movzbl (%rax,%r12), %edx
cmpl $0xd, %edx
je 0x42310
cmpl $0xa, %edx
jne 0x42319
leaq 0x1(%rcx), %r12
cmpq %r15, %r12
jb 0x422fe
movsbl %dl, %ebp
incq %rcx
movq %rcx, %r12
xorl %ebx, %ebx
cmpq %r15, %r12
jae 0x42453
cmpl $0xa, %ebp
je 0x4238f
cmpq %r15, %r12
jae 0x4238f
cmpl $0x2e, %ebp
pushq $0x4e
popq %rax
cmovel %eax, %ebp
movl %ebp, %edi
callq 0x9820
testl %eax, %eax
je 0x42378
leal 0x1(%rbx), %r13d
movq (%rsp), %rax
cmpl 0x18(%rax), %ebx
jl 0x4237b
movslq %ebp, %rax
leaq 0x221fe(%rip), %rcx     # 0x64560
movb (%rcx,%rax), %al
movb %al, 0x20(%rsp)
movq %r14, %rdi
leaq 0x20(%rsp), %rsi
callq 0x43948
jmp 0x4237b
movl %ebx, %r13d
movq 0x128(%r14), %rax
movsbl (%rax,%r12), %ebp
incq %r12
movl %r13d, %ebx
jmp 0x4232d
movq 0x20(%r14), %rcx
subl %ecx, %ebx
movl %ebx, 0x1a8(%r14)
movq (%rsp), %rax
movslq 0x14(%rax), %rdx
xorl %r12d, %r12d
movq %rcx, %rax
subq %rdx, %rax
cmovbq %r12, %rax
cmovbq %rcx, %rdx
movq %rax, 0x20(%r14)
movl %edx, 0x1ac(%r14)
leaq 0x60(%r14), %rbx
leaq 0x20(%rsp), %r15
cmpq %rax, %r12
jae 0x423e7
movb $0x49, 0x20(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x43902
incq %r12
movq 0x20(%r14), %rax
jmp 0x423c9
cmpq $0x0, 0x170(%r14)
jne 0x42418
leaq 0x40(%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, (%rdi)
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x4389b
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x43a20
movb $0x1, 0x190(%r14)
movb $0x1, %bl
movq 0x10(%rsp), %rax
cmpb $0x0, 0x190(%rax)
jne 0x42453
cmpq $0x0, 0x140(%rax)
je 0x42453
movq (%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq 0x8(%rsp), %rcx
callq *0x18(%rax)
movl %eax, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq