// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/pat.cpp
// Function: VectorPatternSource::parse(Read&, Read&, unsigned long) const
bool VectorPatternSource::parse(Read& ra, Read& rb, TReadId rdid) const {
	// Very similar to TabbedPatternSource

	// Light parser (nextBatchFromFile) puts unparsed data
	// into Read& r, even when the read is paired.
	assert(ra.empty());
	assert(!ra.readOrigBuf.empty()); // raw data for read/pair is here
	int c = '\t';
	size_t cur = 0;
	const size_t buflen = ra.readOrigBuf.length();

	// 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 || paired_) {
			// 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;
		}

		// 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]); // ascii to int
				}
			}
			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;
		while(c != '\t' && c != '\n' && c != '\r') {
			if(c == ' ') {
				wrongQualityFormat(r.name);
				return false;
			}
			char cadd = charToPhred33(c, false, false);
			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;
	if(!rb.parsed && rb.readOrigBuf.length() > 0) {
		return parse(rb, ra, rdid);
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x30(%rsp)
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, 0x18(%rsp)
movq 0x140(%rsi), %rbp
leaq 0x150(%rdx), %rax
movq %rax, 0x38(%rsp)
xorl %r15d, %r15d
pushq $0x9
popq %rbx
xorl %eax, %eax
movq %rsi, 0x20(%rsp)
movq %rdx, 0x40(%rsp)
cmpl $0x9, %ebx
jne 0x41e3e
cmpl $0x1, %eax
ja 0x41e3e
movq %r12, %rcx
movl %eax, 0x2c(%rsp)
testl %eax, %eax
cmoveq %r14, %rcx
movq %rcx, 0x10(%rsp)
je 0x41c56
movq 0x18(%rsp), %rax
cmpb $0x1, 0x28(%rax)
jne 0x41ca3
movq 0x128(%r14), %r13
leaq (%r15,%r13), %rax
movq 0x10(%rsp), %rcx
leaq 0x150(%rcx), %rbx
incq %r15
movb (%rax), %al
cmpb $0x9, %al
je 0x41c99
cmpq %rbp, %r15
jae 0x41c99
movb %al, 0xf(%rsp)
movq %rbx, %rdi
leaq 0xf(%rsp), %rsi
callq 0x43902
movq 0x128(%r14), %r13
leaq (%r15,%r13), %rax
jmp 0x41c6d
cmpq %rbp, %r15
jb 0x41cc3
jmp 0x41e7a
movq 0x158(%r14), %rsi
movq 0x170(%r14), %rdx
movq 0x38(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x128(%r14), %r13
leaq (%r15,%r13), %rax
incq %r15
xorl %r12d, %r12d
movsbl (%rax), %ebx
cmpl $0x9, %ebx
je 0x41d32
cmpq %rbp, %r15
jae 0x41d32
movl %ebx, %edi
callq 0x9820
testl %eax, %eax
je 0x41d23
leal 0x1(%r12), %r14d
movq 0x18(%rsp), %rax
cmpl 0x18(%rax), %r12d
jl 0x41d26
movslq %ebx, %rax
leaq 0x22861(%rip), %rcx     # 0x64560
movb (%rcx,%rax), %al
movb %al, 0xe(%rsp)
movq 0x10(%rsp), %rdi
leaq 0xe(%rsp), %rsi
callq 0x43948
movq 0x20(%rsp), %rax
movq 0x128(%rax), %r13
jmp 0x41d26
movl %r12d, %r14d
leaq (%r15,%r13), %rax
incq %r15
movl %r14d, %r12d
jmp 0x41ccd
xorl %r13d, %r13d
cmpq %rbp, %r15
jae 0x41e7d
movq 0x10(%rsp), %rdi
movq 0x20(%rdi), %rax
movl %r12d, %ecx
subl %eax, %ecx
movl %ecx, 0x1a8(%rdi)
movq 0x18(%rsp), %rcx
movslq 0x14(%rcx), %rcx
movq %rax, %rdx
subq %rcx, %rdx
movl $0x0, %esi
cmovaeq %rdx, %rsi
cmovbq %rax, %rcx
movq %rsi, 0x20(%rdi)
movl %ecx, 0x1ac(%rdi)
movq 0x20(%rsp), %rax
movq 0x128(%rax), %rax
movb (%rax,%r15), %al
incq %r15
leaq 0x60(%rdi), %r14
movzbl %al, %eax
leal -0x9(%rax), %ecx
movsbl %al, %ebx
cmpl $0x2, %ecx
jb 0x41df2
cmpl $0xd, %eax
je 0x41df2
cmpl $0x20, %eax
je 0x41e8f
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x41f2d
movb %al, 0xd(%rsp)
movq 0x18(%rsp), %rax
cmpl 0x18(%rax), %r13d
jl 0x41dd2
movq %r14, %rdi
leaq 0xd(%rsp), %rsi
callq 0x43902
cmpq %rbp, %r15
jae 0x41def
movq 0x20(%rsp), %rax
movq 0x128(%rax), %rax
movb (%rax,%r15), %al
incq %r15
incl %r13d
jmp 0x41d8f
incl %r13d
cmpl %r13d, %r12d
jg 0x41ea0
movq 0x20(%rsp), %r14
movq 0x40(%rsp), %r12
jl 0x41eb1
movq 0x18(%rsp), %rax
movslq 0x14(%rax), %rax
movq 0x10(%rsp), %rdx
movq 0x80(%rdx), %rcx
subq %rax, %rcx
movl $0x0, %eax
cmovaeq %rcx, %rax
movq %rax, 0x80(%rdx)
movl 0x2c(%rsp), %eax
incl %eax
jmp 0x41c25
movb $0x1, 0x190(%r14)
movb $0x1, %r13b
cmpb $0x0, 0x190(%r12)
jne 0x41e7d
cmpq $0x0, 0x140(%r12)
je 0x41e7d
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
movq %r12, %rsi
movq %r14, %rdx
movq 0x30(%rsp), %rcx
callq *0x18(%rax)
movl %eax, %r13d
jmp 0x41e7d
xorl %r13d, %r13d
movl %r13d, %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 0x41eb6
movq 0x10(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4208f
callq 0x420ef