// File: /workspace/github_cpp_makefile_star2_O1/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, 0x38(%rsp)
movq %rdx, 0x40(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq 0x140(%rsi), %r15
leaq 0x150(%rsi), %rax
movq %rax, 0x28(%rsp)
movl $0x3, %ebp
leaq 0x10(%rsp), %r12
movq 0x128(%r14), %rcx
movzbl -0x2(%rcx,%rbp), %eax
cmpl $0xd, %eax
je 0x4e0a6
cmpl $0xa, %eax
je 0x4e0a6
movb %al, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x4f02e
incq %rbp
jmp 0x4e077
incq %rbp
movzbl -0x1(%rcx,%rbp), %eax
cmpl $0xd, %eax
je 0x4e0a3
cmpl $0xa, %eax
je 0x4e0a3
movq %rbx, 0x8(%rsp)
cmpb $0x2b, %al
setne %cl
cmpq %r15, %rbp
setb %dl
andb %cl, %dl
xorl %ebx, %ebx
cmpb $0x1, %dl
jne 0x4e132
xorl %ebx, %ebx
cmpb $0x2e, %al
movzbl %al, %r12d
movl $0x4e, %eax
cmovel %eax, %r12d
movsbl %r12b, %edi
callq 0x9800
testl %eax, %eax
je 0x4e11c
leal 0x1(%rbx), %r13d
movq 0x8(%rsp), %rax
cmpl 0x18(%rax), %ebx
jl 0x4e119
movsbq %r12b, %rax
leaq 0x1f44b(%rip), %rcx     # 0x6d550
movb (%rcx,%rax), %al
movb %al, 0x10(%rsp)
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4f074
movl %r13d, %ebx
movq 0x128(%r14), %rax
movb (%rax,%rbp), %al
incq %rbp
cmpb $0x2b, %al
je 0x4e132
cmpq %r15, %rbp
jb 0x4e0d0
movq 0x20(%r14), %rax
movq 0x128(%r14), %rcx
subl %eax, %ebx
movl %ebx, 0x1a8(%r14)
movq 0x8(%rsp), %r8
movslq 0x14(%r8), %rdx
xorl %esi, %esi
movq %rax, %rdi
subq %rdx, %rdi
cmovaeq %rdi, %rsi
cmovbq %rax, %rdx
movq %rsi, 0x20(%r14)
movl %edx, 0x1ac(%r14)
movzbl (%rcx,%rbp), %eax
incq %rbp
cmpl $0xd, %eax
je 0x4e17b
cmpl $0xa, %eax
jne 0x4e16a
leaq 0x10(%rsp), %r12
cmpq %r15, %rbp
jae 0x4e19f
cmpb $0xd, %al
je 0x4e191
movzbl %al, %edx
cmpl $0xa, %edx
jne 0x4e19f
movb (%rcx,%rbp), %al
incq %rbp
cmpq %r15, %rbp
jb 0x4e185
movq %r15, %rbp
cmpb $0x1, 0x200a6(%r8)
jne 0x4e2a9
movsbl %al, %ebx
leaq 0x60(%r14), %rdi
xorl %r9d, %r9d
movabsq $0x100002600, %r8       # imm = 0x100002600
leaq 0x1fa38(%rip), %r10     # 0x6dc00
leaq 0x10(%rsp), %r11
movl $0x5d, %r13d
movl $0x2600, %esi           # imm = 0x2600
movq 0x128(%r14), %rax
xorl %edx, %edx
cmpl $0xd, %ebx
ja 0x4e1ef
btl %ebx, %esi
jb 0x4e379
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 0x4e1e1
btq %rcx, %r8
jae 0x4e1e1
movq 0x8(%rsp), %rsi
cmpb $0x1, 0x200a4(%rsi)
jne 0x4e22e
xorl %r15d, %r15d
cmpl $-0xa, %edx
jl 0x4e238
addl $0xa, %edx
movzbl (%r10,%rdx), %r15d
jmp 0x4e238
cmpl $0x5d, %edx
cmovgel %r13d, %edx
movl %edx, %r15d
testl %r15d, %r15d
js 0x4e465
addb $0x21, %r15b
movb %r15b, 0x10(%rsp)
cmpb $0x20, %cl
jne 0x4e256
movsbl (%rax,%rbp), %ebx
incq %rbp
movl $0x2600, %esi           # imm = 0x2600
movq 0x8(%rsp), %rax
cmpl 0x18(%rax), %r9d
jl 0x4e2a1
movl %r9d, 0x34(%rsp)
movq %r11, %rsi
movq %r8, %r12
movq %rdi, %r15
movq %r11, %r13
callq 0x4f02e
movq %r13, %r11
movl $0x5d, %r13d
leaq 0x1f974(%rip), %r10     # 0x6dc00
movq %r15, %rdi
movl $0x2600, %esi           # imm = 0x2600
movq %r12, %r8
leaq 0x10(%rsp), %r12
movl 0x34(%rsp), %r9d
incl %r9d
jmp 0x4e1d8
movzbl 0x200a4(%r8), %esi
movzbl 0x200a5(%r8), %edx
movsbl %al, %edi
callq 0x4d361
cmpl $0x0, 0x1a8(%r14)
jg 0x4e2db
leaq 0x60(%r14), %rdi
leaq 0x10(%rsp), %rsi
movb %al, (%rsi)
callq 0x4f02e
cmpq %r15, %rbp
jae 0x4e348
leaq 0x60(%r14), %rbx
movl $0x1, %r13d
movq 0x128(%r14), %rax
movzbl (%rax,%rbp), %eax
cmpl $0xa, %eax
je 0x4e348
cmpl $0xd, %eax
je 0x4e348
cmpl $0x20, %eax
je 0x4e45b
movq 0x8(%rsp), %rcx
movzbl 0x200a4(%rcx), %esi
movzbl 0x200a5(%rcx), %edx
movsbl %al, %edi
callq 0x4d361
cmpl 0x1a8(%r14), %r13d
jl 0x4e33d
movb %al, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4f02e
incq %rbp
incl %r13d
cmpq %rbp, %r15
jne 0x4e2ea
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 0x4e4bb
ja 0x4e4c5
cmpq $0x0, 0x170(%r14)
jne 0x4e417
leaq 0xf(%rsp), %rsi
leaq 0xa069(%rip), %rdi      # 0x583fc
movabsq $-0x3333333333333333, %r8 # imm = 0xCCCCCCCCCCCCCCCD
movq 0x38(%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 0x4e3a2
cmpq %r12, %rsi
jbe 0x4e3f5
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 0x4e3da
movb $0x0, 0x1(%rsi)
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x91b0
movq 0x28(%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)
movq 0x8(%rsp), %rdi
jne 0x4e44c
cmpq $0x0, 0x140(%rsi)
je 0x4e44c
movq (%rdi), %rax
movq %r14, %rdx
movq 0x38(%rsp), %rcx
callq *0x18(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %rdi
callq 0x4d2e8
movq 0x1cb84(%rip), %rdi     # 0x6aff0
leaq 0x9f69(%rip), %rsi      # 0x583dc
callq 0x9490
movq %rax, %rdi
movl %r15d, %esi
callq 0x9910
leaq 0x9104(%rip), %rsi      # 0x5758e
movq %rax, %rdi
callq 0x9490
movq %rax, %rdi
callq 0x91f0
movl $0x4, %edi
callq 0x9200
movl $0x1, (%rax)
movq 0x1ca87(%rip), %rsi     # 0x6af38
movq %rax, %rdi
xorl %edx, %edx
callq 0x98f0
movq 0x28(%rsp), %rdi
callq 0x4d4c9
callq 0x4d52b