// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movq 0x140(%rsi), %r15
leaq 0x150(%rsi), %r13
movl $0x3, %ebp
movq 0x128(%r14), %rbx
movzbl -0x2(%rbx,%rbp), %eax
cmpl $0xd, %eax
je 0x4cca5
cmpl $0xa, %eax
je 0x4cca5
movb %al, (%rsp)
movq %r13, %rdi
movq %rsp, %rsi
callq 0x4dc0a
incq %rbp
jmp 0x4cc79
incq %rbp
movzbl -0x1(%rbx,%rbp), %eax
cmpl $0xd, %eax
je 0x4cca2
cmpl $0xa, %eax
je 0x4cca2
movq %r13, 0x18(%rsp)
movq %r12, 0x38(%rsp)
movq %r14, 0x30(%rsp)
cmpb $0x2b, %al
setne %cl
cmpq %r15, %rbp
setb %dl
andb %cl, %dl
xorl %r13d, %r13d
cmpb $0x1, %dl
jne 0x4cd40
xorl %r13d, %r13d
cmpb $0x2e, %al
movzbl %al, %r14d
movl $0x4e, %eax
cmovel %eax, %r14d
movsbl %r14b, %edi
callq 0x9800
testl %eax, %eax
je 0x4cd31
leal 0x1(%r13), %r12d
movq 0x38(%rsp), %rax
cmpl 0x18(%rax), %r13d
jl 0x4cd2e
movsbq %r14b, %rax
leaq 0x1f83f(%rip), %rcx     # 0x6c550
movb (%rcx,%rax), %al
movb %al, (%rsp)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x4dc50
movq 0x128(%rbx), %rbx
movl %r12d, %r13d
movb (%rbx,%rbp), %al
incq %rbp
cmpb $0x2b, %al
je 0x4cd40
cmpq %r15, %rbp
jb 0x4ccdb
movq 0x30(%rsp), %r14
movq 0x20(%r14), %rax
subl %eax, %r13d
movl %r13d, 0x1a8(%r14)
movq 0x38(%rsp), %r13
movslq 0x14(%r13), %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 (%rbx,%rbp), %eax
incq %rbp
cmpl $0xd, %eax
je 0x4cd88
cmpl $0xa, %eax
jne 0x4cd77
cmpq %r15, %rbp
jae 0x4cda7
cmpb $0xd, %al
je 0x4cd99
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x4cda7
movb (%rbx,%rbp), %al
incq %rbp
cmpq %r15, %rbp
jb 0x4cd8d
movq %r15, %rbp
cmpb $0x1, 0x200a6(%r13)
jne 0x4ce8e
movsbl %al, %ebx
leaq 0x60(%r14), %r12
xorl %r10d, %r10d
movabsq $0x100002600, %r9       # imm = 0x100002600
leaq 0x1fe30(%rip), %r8      # 0x6cc00
movq %rsp, %rsi
movl $0x2600, %r11d          # imm = 0x2600
movq 0x128(%r14), %rax
xorl %edx, %edx
cmpl $0xd, %ebx
ja 0x4cdf1
btl %ebx, %r11d
jb 0x4cf56
leal (%rdx,%rdx,4), %ecx
leal (%rbx,%rcx,2), %edx
addl $-0x30, %edx
movzbl (%rax,%rbp), %ecx
incq %rbp
movsbl %cl, %ebx
cmpq $0x20, %rcx
ja 0x4cde2
btq %rcx, %r9
jae 0x4cde2
cmpb $0x1, 0x200a4(%r13)
jne 0x4ce2c
xorl %r15d, %r15d
cmpl $-0xa, %edx
jl 0x4ce41
addl $0xa, %edx
movzbl (%r8,%rdx), %r15d
jmp 0x4ce41
cmpl $0x5d, %edx
movl $0x5d, %r15d
cmovll %edx, %r15d
testl %edx, %edx
js 0x4d051
addb $0x21, %r15b
movb %r15b, (%rsp)
cmpb $0x20, %cl
jne 0x4ce55
movsbl (%rax,%rbp), %ebx
incq %rbp
cmpl 0x18(%r13), %r10d
jl 0x4ce86
movq %r12, %rdi
movl %r10d, 0x24(%rsp)
movq %r8, %r15
callq 0x4dc0a
movl $0x2600, %r11d          # imm = 0x2600
movq %rsp, %rsi
movq %r15, %r8
movabsq $0x100002600, %r9       # imm = 0x100002600
movl 0x24(%rsp), %r10d
incl %r10d
jmp 0x4cdd9
movzbl 0x200a4(%r13), %esi
movzbl 0x200a5(%r13), %edx
movsbl %al, %edi
callq 0x4bf8e
cmpl $0x0, 0x1a8(%r14)
jg 0x4cebe
leaq 0x60(%r14), %rdi
movq %rsp, %rsi
movb %al, (%rsi)
callq 0x4dc0a
cmpq %r15, %rbp
jae 0x4cf25
leaq 0x60(%r14), %rbx
movl $0x1, %r12d
movq 0x128(%r14), %rax
movzbl (%rax,%rbp), %eax
cmpl $0xa, %eax
je 0x4cf25
cmpl $0xd, %eax
je 0x4cf25
cmpl $0x20, %eax
je 0x4d038
movzbl 0x200a4(%r13), %esi
movzbl 0x200a5(%r13), %edx
movsbl %al, %edi
callq 0x4bf8e
cmpl 0x1a8(%r14), %r12d
jl 0x4cf1a
movb %al, (%rsp)
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x4dc0a
incq %rbp
incl %r12d
cmpq %rbp, %r15
jne 0x4cecd
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 0x4d042
ja 0x4d04c
cmpq $0x0, 0x170(%r14)
jne 0x4cff5
leaq -0x1(%rsp), %rsi
leaq 0xa534(%rip), %rdi      # 0x574a4
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 0x4cf7f
movq %rsp, %rax
cmpq %rax, %rsi
jbe 0x4cfd5
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 0x4cfba
movb $0x0, 0x1(%rsi)
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x91b0
movq 0x18(%rsp), %rdi
movq (%rdi), %rcx
movq %rbx, %rsi
movq %rax, %rdx
callq *0x10(%rcx)
movb $0x1, 0x190(%r14)
movb $0x1, %al
movq 0x40(%rsp), %rsi
cmpb $0x0, 0x190(%rsi)
jne 0x4d029
cmpq $0x0, 0x140(%rsi)
je 0x4d029
movq (%r13), %rax
movq %r13, %rdi
movq %r14, %rdx
movq 0x28(%rsp), %rcx
callq *0x18(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
callq 0x4bf15
movq 0x18(%rsp), %rdi
callq 0x4c0f2
callq 0x4c154
movq 0x1cf98(%rip), %rdi     # 0x69ff0
leaq 0xa425(%rip), %rsi      # 0x57484
callq 0x9490
movq %rax, %rdi
movl %r15d, %esi
callq 0x9910
leaq 0x95f8(%rip), %rsi      # 0x5666e
movq %rax, %rdi
callq 0x9490
movq %rax, %rdi
callq 0x91f0
movl $0x4, %edi
callq 0x9200
movl $0x1, (%rax)
movq 0x1ce9b(%rip), %rsi     # 0x69f38
movq %rax, %rdi
xorl %edx, %edx
callq 0x98f0
nop