// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rcx, 0x28(%rsp)
movq %rsi, %r14
movq %rdi, 0x20(%rsp)
movq 0x140(%rsi), %r12
cmpq $0x2, %r12
movq %rdx, 0x30(%rsp)
jb 0x4d795
leaq 0x150(%r14), %rbx
movl $0x1, %r15d
subq %r12, %r15
movl $0x2, %ebp
movq 0x128(%r14), %rax
movzbl -0x1(%rax,%rbp), %r13d
cmpl $0xd, %r13d
je 0x4d773
cmpl $0xa, %r13d
je 0x4d773
movb %r13b, (%rsp)
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x4f02e
leaq (%r15,%rbp), %rax
incq %rax
incq %rbp
cmpq $0x2, %rax
jne 0x4d732
movsbl %r13b, %ebp
movq %r12, %r15
jmp 0x4d7a0
movq %rbp, %r15
movzbl (%rax,%rbp), %ecx
cmpl $0xd, %ecx
je 0x4d784
cmpl $0xa, %ecx
jne 0x4d78d
leaq 0x1(%r15), %rbp
cmpq %r12, %rbp
jb 0x4d773
movsbl %cl, %ebp
incq %r15
jmp 0x4d7a0
movl $0x1, %r15d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r13d, %r13d
cmpq %r12, %r15
jae 0x4d94c
cmpl $0xa, %ebp
je 0x4d818
incq %r15
xorl %r13d, %r13d
cmpl $0x2e, %ebp
movl $0x4e, %eax
cmovel %eax, %ebp
movl %ebp, %edi
callq 0x9800
testl %eax, %eax
je 0x4d7fa
leal 0x1(%r13), %ebx
movq 0x20(%rsp), %rax
cmpl 0x18(%rax), %r13d
jl 0x4d7f7
movslq %ebp, %rax
leaq 0x1fd6a(%rip), %rcx     # 0x6d550
movb (%rcx,%rax), %al
movb %al, (%rsp)
movq %r14, %rdi
movq %rsp, %rsi
callq 0x4f074
movl %ebx, %r13d
movq 0x128(%r14), %rax
movsbl -0x1(%rax,%r15), %ebp
cmpl $0xa, %ebp
je 0x4d818
leaq 0x1(%r15), %rax
cmpq %r12, %r15
movq %rax, %r15
jb 0x4d7b7
movq 0x20(%r14), %rax
subl %eax, %r13d
movl %r13d, 0x1a8(%r14)
movq 0x20(%rsp), %rcx
movslq 0x14(%rcx), %rcx
xorl %edx, %edx
movq %rax, %rsi
subq %rcx, %rsi
cmovaeq %rsi, %rdx
cmovbq %rax, %rcx
movq %rdx, 0x20(%r14)
movl %ecx, 0x1ac(%r14)
jbe 0x4d86e
leaq 0x60(%r14), %rbx
xorl %r15d, %r15d
movq %rsp, %r13
movb $0x49, (%rsp)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4f02e
incq %r15
cmpq 0x20(%r14), %r15
jb 0x4d856
cmpq $0x0, 0x170(%r14)
jne 0x4d913
leaq 0x150(%r14), %r13
leaq -0x1(%rsp), %rsi
leaq 0xab6d(%rip), %rdi      # 0x583fc
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x28(%rsp), %rcx
movq %rcx, %rax
mulq %r8
shrq $0x3, %rdx
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
movq %rcx, %r9
subq %rax, %r9
movb (%rdi,%r9), %al
movb %al, 0x1(%rsi)
incq %rsi
cmpq $0x9, %rcx
movq %rdx, %rcx
ja 0x4d89e
movq %rsp, %rax
cmpq %rax, %rsi
jbe 0x4d8f4
leaq 0x1(%rsp), %rax
movq %rsi, %rcx
movb -0x1(%rax), %dl
movb (%rcx), %dil
movb %dil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x4d8d9
movb $0x0, 0x1(%rsi)
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x91b0
movq (%r13), %rcx
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x10(%rcx)
movb $0x1, 0x190(%r14)
movb $0x1, %r13b
movq 0x30(%rsp), %rsi
cmpb $0x0, 0x190(%rsi)
jne 0x4d94c
cmpq $0x0, 0x140(%rsi)
je 0x4d94c
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rdx
movq 0x28(%rsp), %rcx
callq *0x18(%rax)
movl %eax, %r13d
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq