// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/pat.cpp
// Function: FastqPatternSource::parse(Read&, Read&, unsigned long) const
bool FastqPatternSource::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;
	size_t cur = 1;
	const size_t buflen = r.readOrigBuf.length();

	// Parse read name
	assert(r.name.empty());
	while(true) {
		assert_lt(cur, buflen);
		c = r.readOrigBuf[cur++];
		if(c == '\n' || c == '\r') {
			do {
				c = r.readOrigBuf[cur++];
			} while(c == '\n' || c == '\r');
			break;
		}
		r.name.append(c);
	}

	// Parse sequence
	int nchar = 0;
	assert(r.patFw.empty());
	while(c != '+' && 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_));

	assert_eq('+', c);
	do {
		assert_lt(cur, buflen);
		c = r.readOrigBuf[cur++];
	} while(c != '\n' && c != '\r');
	while(cur < buflen && (c == '\n' || c == '\r')) {
		c = r.readOrigBuf[cur++];
	}

	assert(r.qual.empty());
	int nqual = 0;
	if (intQuals_) {
		int cur_int = 0;
		while(c != '\t' && c != '\n' && c != '\r') {
			cur_int *= 10;
			cur_int += (int)(c - '0');
			c = r.readOrigBuf[cur++];
			if(c == ' ' || c == '\t' || c == '\n' || c == '\r') {
				char cadd = intToPhred33(cur_int, solQuals_);
				cur_int = 0;
				if (c == ' ')
					c = r.readOrigBuf[cur++];
				assert_geq(cadd, 33);
				if(++nqual > this->trim5_) {
					r.qual.append(cadd);
				}
			}
		}
	} else {
		c = charToPhred33(c, solQuals_, phred64Quals_);
		if(nqual++ >= r.trimmed5) {
			r.qual.append(c);
		}
		while(cur < buflen) {
			c = r.readOrigBuf[cur++];
			if (c == ' ') {
				wrongQualityFormat(r.name);
				return false;
			}
			if(c == '\r' || c == '\n') {
				break;
			}
			c = charToPhred33(c, solQuals_, phred64Quals_);
			if(nqual++ >= r.trimmed5) {
				r.qual.append(c);
			}
		}
		r.qual.trimEnd(r.trimmed3);
		if(r.qual.length() < r.patFw.length()) {
			tooFewQualities(r.name);
			return false;
		} else if(r.qual.length() > r.patFw.length()) {
			tooManyQualities(r.name);
			return false;
		}
	}

	// 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 $0x58, %rsp
movq %rcx, 0x38(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movq 0x140(%rsi), %r13
leaq 0x150(%rsi), %rax
movq %rax, 0x18(%rsp)
pushq $0x3
popq %r15
leaq 0x20(%rsp), %rbx
movq 0x128(%r14), %rbp
movzbl -0x2(%rbp,%r15), %eax
cmpl $0xd, %eax
je 0x42acc
cmpl $0xa, %eax
je 0x42acc
movb %al, 0x20(%rsp)
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x43902
incq %r15
jmp 0x42a9c
incq %r15
movzbl -0x1(%rbp,%r15), %eax
cmpl $0xd, %eax
je 0x42ac9
cmpl $0xa, %eax
je 0x42ac9
movq %r12, 0x10(%rsp)
movq %r14, 0x8(%rsp)
xorl %r12d, %r12d
cmpb $0x2b, %al
je 0x42b56
cmpq %r13, %r15
jae 0x42b56
cmpb $0x2e, %al
movzbl %al, %ebx
pushq $0x4e
popq %rax
cmovel %eax, %ebx
movsbl %bl, %edi
callq 0x9820
testl %eax, %eax
je 0x42b46
leal 0x1(%r12), %r14d
movq 0x10(%rsp), %rax
cmpl 0x18(%rax), %r12d
jl 0x42b49
movsbq %bl, %rax
leaq 0x21a3c(%rip), %rcx     # 0x64560
movb (%rcx,%rax), %al
movb %al, 0x20(%rsp)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x43948
movq 0x128(%rbx), %rbp
jmp 0x42b49
movl %r12d, %r14d
movb (%rbp,%r15), %al
incq %r15
movl %r14d, %r12d
jmp 0x42ae9
movq 0x8(%rsp), %r14
movq 0x20(%r14), %rax
subl %eax, %r12d
movl %r12d, 0x1a8(%r14)
movq 0x10(%rsp), %r12
movslq 0x14(%r12), %rcx
xorl %edx, %edx
movq %rax, %rsi
subq %rcx, %rsi
cmovaeq %rsi, %rdx
cmovbq %rax, %rcx
movq %rdx, 0x20(%r14)
movl %ecx, 0x1ac(%r14)
movzbl (%rbp,%r15), %eax
incq %r15
cmpl $0xd, %eax
je 0x42bb7
cmpl $0xa, %eax
jne 0x42b8e
jmp 0x42bb7
cmpb $0xd, %al
je 0x42baf
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x42bbc
movb (%rbp,%r15), %al
incq %r15
cmpq %r13, %r15
jb 0x42ba3
cmpb $0x1, 0x200a6(%r12)
jne 0x42c7a
movsbl %al, %r13d
leaq 0x60(%r14), %rax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
movabsq $0x100002600, %rbp      # imm = 0x100002600
movl $0x2600, %esi           # imm = 0x2600
movq 0x128(%r14), %rax
xorl %edi, %edi
cmpl $0xd, %r13d
ja 0x42c02
btl %r13d, %esi
jb 0x42d45
imull $0xa, %edi, %ecx
leal (%rcx,%r13), %edi
addl $-0x30, %edi
movzbl (%rax,%r15), %r12d
incq %r15
movsbl %r12b, %r13d
cmpq $0x20, %r12
ja 0x42bf2
btq %r12, %rbp
jae 0x42bf2
movq 0x10(%rsp), %rax
movzbl 0x200a4(%rax), %esi
callq 0x42dd8
movb %al, 0x20(%rsp)
cmpb $0x20, %r12b
jne 0x42c55
movq 0x8(%rsp), %r14
movq 0x128(%r14), %rax
movsbl (%rax,%r15), %r13d
incq %r15
jmp 0x42c5a
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rax
cmpl 0x18(%rax), %ebx
jl 0x42c73
movq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x43902
incl %ebx
jmp 0x42be4
movzbl 0x200a4(%r12), %esi
movzbl 0x200a5(%r12), %edx
movsbl %al, %edi
callq 0x41f2d
cmpl $0x0, 0x1a8(%r14)
jg 0x42cae
leaq 0x60(%r14), %rdi
leaq 0x20(%rsp), %rsi
movb %al, (%rsi)
callq 0x43902
leaq 0x60(%r14), %rbp
pushq $0x1
popq %rbx
cmpq %r13, %r15
jae 0x42d14
movq 0x128(%r14), %rax
movzbl (%rax,%r15), %eax
cmpl $0xa, %eax
je 0x42d14
cmpl $0xd, %eax
je 0x42d14
cmpl $0x20, %eax
je 0x42dbf
movzbl 0x200a4(%r12), %esi
movzbl 0x200a5(%r12), %edx
movsbl %al, %edi
callq 0x41f2d
cmpl 0x1a8(%r14), %ebx
jl 0x42d0d
movb %al, 0x20(%rsp)
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x43902
incq %r15
incl %ebx
jmp 0x42cb5
movslq 0x1ac(%r14), %rax
movq 0x20(%r14), %rcx
movq 0x80(%r14), %rdx
xorl %esi, %esi
subq %rax, %rdx
cmovaeq %rdx, %rsi
movq %rsi, 0x80(%r14)
cmpq %rcx, %rsi
jb 0x42dc9
ja 0x42dd3
movq 0x8(%rsp), %r14
cmpq $0x0, 0x170(%r14)
jne 0x42d7b
leaq 0x50(%rsp), %rdi
movq 0x38(%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, %al
movq 0x48(%rsp), %rsi
cmpb $0x0, 0x190(%rsi)
movq 0x10(%rsp), %rdi
jne 0x42db0
cmpq $0x0, 0x140(%rsi)
je 0x42db0
movq (%rdi), %rax
movq %r14, %rdx
movq 0x38(%rsp), %rcx
callq *0x18(%rax)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
callq 0x41eb6
movq 0x18(%rsp), %rdi
callq 0x4208f
callq 0x420ef