// File: /workspace/github_cpp_makefile_star2_O1/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, 0x20(%rsp)
movq %rsi, %r12
movq %rdi, 0x10(%rsp)
movq 0x140(%rsi), %rbp
leaq 0x150(%rdx), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
movq %rsi, 0x18(%rsp)
movq %rdx, 0x30(%rsp)
movq %rax, 0x40(%rsp)
testl %eax, %eax
cmoveq %r12, %rdx
movq %rdx, 0x8(%rsp)
je 0x4d024
movq 0x10(%rsp), %rax
cmpb $0x1, 0x28(%rax)
jne 0x4d093
movq 0x128(%r12), %rax
movb (%rax,%r15), %al
incq %r15
cmpb $0x9, %al
setne %dl
cmpq %rbp, %r15
setb %cl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4d083
movq 0x8(%rsp), %rcx
leaq 0x150(%rcx), %rbx
leaq 0x7(%rsp), %r14
movb %al, 0x7(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4f02e
movq 0x128(%r12), %rax
movb (%rax,%r15), %al
incq %r15
cmpq %rbp, %r15
setb %cl
cmpb $0x9, %al
je 0x4d083
cmpq %rbp, %r15
jb 0x4d056
testb %cl, %cl
jne 0x4d0ae
movsbl %al, %r13d
xorl %r12d, %r12d
jmp 0x4d256
movq 0x158(%r12), %rsi
movq 0x170(%r12), %rdx
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x128(%r12), %rax
movsbl (%rax,%r15), %r13d
cmpl $0x9, %r13d
setne %dl
leaq 0x1(%r15), %rax
cmpq %rbp, %rax
setb %cl
andb %cl, %dl
xorl %ebx, %ebx
cmpb $0x1, %dl
jne 0x4d13f
xorl %ebx, %ebx
movl %r13d, %edi
callq 0x9800
testl %eax, %eax
je 0x4d115
leal 0x1(%rbx), %r14d
movq 0x10(%rsp), %rax
cmpl 0x18(%rax), %ebx
jl 0x4d112
movsbq %r13b, %rax
leaq 0x20454(%rip), %rcx     # 0x6d550
movb (%rcx,%rax), %al
movb %al, 0x6(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rsi
callq 0x4f074
movl %r14d, %ebx
movq 0x128(%r12), %rax
movsbl 0x1(%rax,%r15), %r13d
leaq 0x2(%r15), %rax
cmpq %rbp, %rax
setb %cl
incq %r15
cmpl $0x9, %r13d
je 0x4d13b
cmpq %rbp, %rax
jb 0x4d0d7
leaq 0x1(%r15), %rax
xorl %r12d, %r12d
testb %cl, %cl
je 0x4d214
movq 0x8(%rsp), %r8
movq 0x20(%r8), %rcx
movl %ebx, %edx
subl %ecx, %edx
movl %edx, 0x1a8(%r8)
movq 0x10(%rsp), %rdx
movslq 0x14(%rdx), %rdx
movq %rcx, %rsi
subq %rdx, %rsi
movl $0x0, %edi
cmovaeq %rsi, %rdi
cmovbq %rcx, %rdx
movq %rdi, 0x20(%r8)
movl %edx, 0x1ac(%r8)
addq $0x2, %r15
movq 0x18(%rsp), %rcx
movq 0x128(%rcx), %rcx
movsbl (%rcx,%rax), %r13d
leaq 0x60(%r8), %rax
movq %rax, 0x38(%rsp)
movq %r15, %r14
leal -0x9(%r13), %eax
cmpl $0x2, %eax
jb 0x4d219
cmpl $0xd, %r13d
je 0x4d219
cmpl $0x20, %r13d
je 0x4d2c1
movsbl %r13b, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4d361
movb %al, 0x5(%rsp)
movq 0x10(%rsp), %rax
cmpl 0x18(%rax), %r12d
jl 0x4d1ea
movq 0x38(%rsp), %rdi
leaq 0x5(%rsp), %rsi
callq 0x4f02e
movq %r14, %r15
cmpq %rbp, %r14
jae 0x4d207
leaq 0x1(%r14), %r15
movq 0x18(%rsp), %rax
movq 0x128(%rax), %rax
movsbl (%rax,%r14), %r13d
incl %r12d
cmpq %rbp, %r14
movq %r15, %r14
jb 0x4d1a6
jmp 0x4d21c
movq %rax, %r15
jmp 0x4d256
movq %r14, %r15
cmpl %r12d, %ebx
jg 0x4d2d2
jl 0x4d2e3
movq 0x10(%rsp), %rax
movslq 0x14(%rax), %rax
movq 0x8(%rsp), %rdx
movq 0x80(%rdx), %rcx
subq %rax, %rcx
movl $0x0, %eax
cmovaeq %rcx, %rax
movq %rax, 0x80(%rdx)
movb $0x1, %r12b
testb %r12b, %r12b
movq 0x30(%rsp), %rdx
movq 0x40(%rsp), %rax
je 0x4d2b0
testl %eax, %eax
movq 0x18(%rsp), %r12
jne 0x4d27a
incl %eax
cmpl $0x9, %r13d
je 0x4d007
movb $0x1, 0x190(%r12)
movb $0x1, %al
cmpb $0x0, 0x190(%rdx)
jne 0x4d2b2
cmpq $0x0, 0x140(%rdx)
je 0x4d2b2
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
movq %rdx, %rsi
movq %r12, %rdx
movq 0x20(%rsp), %rcx
callq *0x18(%rax)
jmp 0x4d2b2
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4d2e8
movq 0x8(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4d4c9
callq 0x4d52b