// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/pat.cpp
// Function: TabbedPatternSource::parse(Read&, Read&, unsigned long) const
bool TabbedPatternSource::parse(Read& ra, Read& rb, TReadId rdid) const {
	// Light parser (nextBatchFromFile) puts unparsed data
	// into Read& r, even when the read is paired.
	assert(ra.empty());
	assert(rb.empty());
	assert(!ra.readOrigBuf.empty()); // raw data for read/pair is here
	assert(rb.readOrigBuf.empty());
	int c = '\t';
	size_t cur = 0;
	const size_t buflen = ra.readOrigBuf.length();
	bool paired = false;

	// Loop over the two ends
	for(int endi = 0; endi < 2 && c == '\t'; endi++) {
		Read& r = ((endi == 0) ? ra : rb);
		assert(r.name.empty());
		// Parse name if (a) this is the first end, or
		// (b) this is tab6
		if(endi < 1 || secondName_) {
			// Parse read name
			c = ra.readOrigBuf[cur++];
			while(c != '\t' && cur < buflen) {
				r.name.append(c);
				c = ra.readOrigBuf[cur++];
			}
			assert_eq('\t', c);
			if(cur >= buflen) {
				return false; // record ended prematurely
			}
		} else if(endi > 0) {
			// if this is the second end and we're parsing
			// tab5, copy name from first end
			rb.name = ra.name; // not a deep copy
		}

		paired = endi > 0;

		// Parse sequence
		assert(r.patFw.empty());
		c = ra.readOrigBuf[cur++];
		int nchar = 0;
		while(c != '\t' && cur < buflen) {
			if(isalpha(c)) {
				assert_in(toupper(c), "ACGTN");
				if(nchar++ >= this->trim5_) {
					assert_neq(0, asc2dnacat[c]);
					r.patFw.append(asc2dna[c]);
				}
			}
			c = ra.readOrigBuf[cur++];
		}
		assert_eq('\t', c);
		if(cur >= buflen) {
			return false; // record ended prematurely
		}
		// 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_));

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbp
movq %rdi, 0x8(%rsp)
movq 0x140(%rsi), %r13
movq %rdx, 0x20(%rsp)
leaq 0x150(%rdx), %rax
movq %rax, 0x30(%rsp)
movb $0x1, %al
xorl %edx, %edx
xorl %ecx, %ecx
xorl %ebx, %ebx
movq %rsi, 0x18(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x20(%rsp), %rdx
testb $0x1, %al
cmovneq %rbp, %rdx
movq %rdx, 0x10(%rsp)
movb %cl, 0x3(%rsp)
jne 0x4d260
movq 0x8(%rsp), %rax
cmpb $0x1, 0x200a6(%rax)
jne 0x4d2c3
movq 0x128(%rbp), %r14
movb (%r14,%rbx), %al
incq %rbx
cmpb $0x9, %al
setne %dl
cmpq %r13, %rbx
setb %cl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4d2ba
movq 0x10(%rsp), %rcx
leaq 0x150(%rcx), %r12
movb %al, 0x7(%rsp)
movq %r12, %rdi
leaq 0x7(%rsp), %rsi
callq 0x4dc0a
movq 0x128(%rbp), %r14
movb (%r14,%rbx), %al
incq %rbx
cmpq %r13, %rbx
setb %cl
cmpb $0x9, %al
je 0x4d2ba
cmpq %r13, %rbx
jb 0x4d28c
testb %cl, %cl
jne 0x4d2e3
jmp 0x4d597
movq 0x158(%rbp), %rsi
movq 0x170(%rbp), %rdx
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x128(%rbp), %r14
movb (%r14,%rbx), %bpl
leaq 0x1(%rbx), %rax
cmpq %r13, %rax
setb %cl
xorl %r12d, %r12d
cmpb $0x9, %bpl
je 0x4d370
cmpq %r13, %rax
jae 0x4d370
xorl %r12d, %r12d
movsbl %bpl, %edi
callq 0x9800
testl %eax, %eax
je 0x4d34f
leal 0x1(%r12), %r15d
movq 0x8(%rsp), %rax
cmpl 0x18(%rax), %r12d
jl 0x4d34c
movsbq %bpl, %rax
leaq 0x1f226(%rip), %rcx     # 0x6c550
movb (%rcx,%rax), %al
movb %al, 0x6(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x6(%rsp), %rsi
callq 0x4dc50
movq 0x18(%rsp), %rax
movq 0x128(%rax), %r14
movl %r15d, %r12d
movb 0x1(%r14,%rbx), %bpl
leaq 0x2(%rbx), %rax
cmpq %r13, %rax
setb %cl
incq %rbx
cmpb $0x9, %bpl
je 0x4d36c
cmpq %r13, %rax
jb 0x4d302
leaq 0x1(%rbx), %rax
testb %cl, %cl
movq 0x18(%rsp), %rbp
je 0x4d597
movq 0x10(%rsp), %r9
movq 0x20(%r9), %rcx
movl %r12d, %edx
subl %ecx, %edx
movl %edx, 0x1a8(%r9)
movq 0x8(%rsp), %r8
movslq 0x14(%r8), %rdx
movq %rcx, %rsi
subq %rdx, %rsi
movl $0x0, %edi
cmovaeq %rsi, %rdi
cmovbq %rcx, %rdx
movq %rdi, 0x20(%r9)
movl %edx, 0x1ac(%r9)
addq $0x2, %rbx
movq 0x128(%rbp), %rcx
movsbl (%rcx,%rax), %edi
leaq 0x60(%r9), %rax
movq %rax, 0x28(%rsp)
cmpb $0x0, 0x200a5(%r8)
je 0x4d49e
xorl %r15d, %r15d
movq 0x128(%rbp), %rcx
xorl %eax, %eax
cmpl $0xd, %edi
ja 0x4d3fe
movl $0x2600, %edx           # imm = 0x2600
btl %edi, %edx
jb 0x4d528
cmpq %r13, %rbx
jae 0x4d528
leal (%rax,%rax,4), %eax
leal (%rdi,%rax,2), %eax
addl $-0x30, %eax
movzbl (%rcx,%rbx), %edx
incq %rbx
movsbl %dl, %edi
cmpq $0x20, %rdx
ja 0x4d3eb
movabsq $0x100002600, %rsi      # imm = 0x100002600
btq %rdx, %rsi
jae 0x4d3eb
movq 0x8(%rsp), %rcx
cmpb $0x1, 0x200a3(%rcx)
jne 0x4d455
xorl %ebp, %ebp
cmpl $-0xa, %eax
jl 0x4d468
addl $0xa, %eax
leaq 0x1f7b1(%rip), %rcx     # 0x6cc00
movzbl (%rcx,%rax), %ebp
jmp 0x4d468
cmpl $0x5d, %eax
movl $0x5d, %ebp
cmovll %eax, %ebp
testl %eax, %eax
js 0x4d5cf
addb $0x21, %bpl
movb %bpl, 0x5(%rsp)
movq 0x8(%rsp), %rax
cmpl 0x18(%rax), %r15d
jl 0x4d491
movq %rdi, %r14
movq 0x28(%rsp), %rdi
leaq 0x5(%rsp), %rsi
callq 0x4dc0a
movq %r14, %rdi
incl %r15d
movq 0x18(%rsp), %rbp
jmp 0x4d3e2
xorl %r15d, %r15d
leal -0x9(%rdi), %eax
cmpl $0x2, %eax
jb 0x4d528
cmpl $0xd, %edi
je 0x4d528
cmpl $0x20, %edi
je 0x4d5a8
movq %r12, %r14
movq %rbp, %r12
movl %r15d, %ebp
movq 0x8(%rsp), %r15
movzbl 0x200a3(%r15), %esi
movzbl 0x200a4(%r15), %edx
movq %rdi, 0x40(%rsp)
movsbl %dil, %edi
callq 0x4bf8e
movb %al, 0x4(%rsp)
cmpl 0x18(%r15), %ebp
movl %ebp, %r15d
jl 0x4d4ff
movq 0x28(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x4dc0a
cmpq %r13, %rbx
movq %r12, %rbp
jae 0x4d51d
movq 0x128(%rbp), %rax
movsbl (%rax,%rbx), %edi
incq %rbx
incl %r15d
movq %r14, %r12
jmp 0x4d4a1
incl %r15d
movq %r14, %r12
movq 0x40(%rsp), %rdi
cmpl %r15d, %r12d
jg 0x4d5b9
jl 0x4d5ca
movq 0x8(%rsp), %rax
movslq 0x14(%rax), %rcx
movq 0x10(%rsp), %rsi
movq 0x80(%rsi), %rdx
xorl %eax, %eax
subq %rcx, %rdx
movl $0x0, %ecx
cmovaeq %rdx, %rcx
movq %rcx, 0x80(%rsi)
cmpl $0x9, %edi
sete %dl
movq 0x38(%rsp), %rsi
xorb $0x1, %sil
movb $0x1, %cl
testb %sil, %dl
movb $0x1, %dl
jne 0x4d237
movb $0x1, 0x190(%rbp)
movq 0x20(%rsp), %rax
movb 0x3(%rsp), %cl
movb %cl, 0x190(%rax)
movb $0x1, %al
jmp 0x4d599
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4bf15
movq 0x10(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4c0f2
callq 0x4c154
movq 0x1ca1a(%rip), %rdi     # 0x69ff0
leaq 0x9ea7(%rip), %rsi      # 0x57484
callq 0x9490
movq %rax, %rdi
movl %ebp, %esi
callq 0x9910
leaq 0x907b(%rip), %rsi      # 0x5666e
movq %rax, %rdi
callq 0x9490
movq %rax, %rdi
callq 0x91f0
movl $0x4, %edi
callq 0x9200
movl $0x1, (%rax)
movq 0x1c91e(%rip), %rsi     # 0x69f38
movq %rax, %rdi
xorl %edx, %edx
callq 0x98f0