// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, 0x8(%rsp)
movq 0x140(%rsi), %r15
cmpq $0x2, %r15
jb 0x4c391
movq %rsi, %r14
movq %rdx, 0x38(%rsp)
movq %rcx, 0x30(%rsp)
leaq 0x150(%rsi), %rax
movq %rax, 0x40(%rsp)
movl $0x1, %r12d
subq %r15, %r12
movl $0x2, %ebx
leaq 0x10(%rsp), %rbp
movq 0x128(%r14), %rcx
movzbl -0x1(%rcx,%rbx), %eax
cmpl $0xd, %eax
je 0x4c398
cmpl $0xa, %eax
je 0x4c398
movb %al, 0x10(%rsp)
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x4dc0a
leaq (%r12,%rbx), %rax
incq %rax
incq %rbx
cmpq $0x2, %rax
jne 0x4c35a
xorl %eax, %eax
jmp 0x4c571
movq %rbx, %r12
movzbl (%rcx,%rbx), %edx
cmpl $0xd, %edx
je 0x4c3a9
cmpl $0xa, %edx
jne 0x4c3b3
leaq 0x1(%r12), %rbx
cmpq %r15, %rbx
jb 0x4c398
leaq 0x1(%r12), %rcx
xorl %eax, %eax
cmpq %r15, %rcx
jae 0x4c571
xorl %r13d, %r13d
cmpb $0xa, %dl
je 0x4c440
addq $0x2, %r12
xorl %r13d, %r13d
movq %rbp, %rbx
cmpb $0x2e, %dl
movzbl %dl, %ebp
movl $0x4e, %eax
cmovel %eax, %ebp
movsbl %bpl, %edi
callq 0x9800
testl %eax, %eax
je 0x4c41f
movq %r13, %rdx
incl %r13d
movq 0x8(%rsp), %rax
cmpl 0x18(%rax), %edx
jl 0x4c41f
movsbq %bpl, %rax
leaq 0x20145(%rip), %rdx     # 0x6c550
movb (%rdx,%rax), %al
movb %al, 0x10(%rsp)
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4dc50
movq %rbx, %rbp
movq 0x128(%r14), %rax
movb -0x1(%rax,%r12), %dl
cmpb $0xa, %dl
je 0x4c440
leaq 0x1(%r12), %rcx
cmpq %r15, %r12
movq %rcx, %r12
jb 0x4c3d2
movq 0x20(%r14), %rax
subl %eax, %r13d
movl %r13d, 0x1a8(%r14)
movq 0x8(%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 0x4c499
leaq 0x60(%r14), %rbx
xorl %r12d, %r12d
leaq 0x10(%rsp), %r15
movb $0x49, 0x10(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4dc0a
incq %r12
cmpq 0x20(%r14), %r12
jb 0x4c480
cmpq $0x0, 0x170(%r14)
jne 0x4c537
leaq 0xf(%rsp), %rsi
leaq 0xaff1(%rip), %rdi      # 0x574a4
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x30(%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 0x4c4c2
cmpq %rbp, %rsi
jbe 0x4c515
leaq 0x11(%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 0x4c4fa
movb $0x0, 0x1(%rsi)
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x91b0
movq 0x40(%rsp), %rdi
movq (%rdi), %rcx
movq %rbx, %rsi
movq %rax, %rdx
callq *0x10(%rcx)
movb $0x1, 0x190(%r14)
movb $0x1, %al
movq 0x38(%rsp), %rcx
cmpb $0x0, 0x190(%rcx)
jne 0x4c571
cmpq $0x0, 0x140(%rcx)
je 0x4c571
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
movq 0x38(%rsp), %rsi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq *0x18(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq