// File: /workspace/github_cpp_makefile_star2_O3/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, 0x28(%rsp)
movq %rdx, %r14
movq %rdi, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x140(%rsi), %rbp
leaq 0x150(%rdx), %rax
movq %rax, 0x30(%rsp)
movb $0x1, %al
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rdx, 0x38(%rsp)
movq %r14, %rcx
testb $0x1, %al
cmovneq 0x10(%rsp), %rcx
movq %rcx, 0x18(%rsp)
jne 0x4bc5d
movq 0x20(%rsp), %rax
cmpb $0x1, 0x28(%rax)
jne 0x4bccc
movq 0x10(%rsp), %rax
movq 0x128(%rax), %r13
movb (%r13,%r15), %al
incq %r15
cmpb $0x9, %al
setne %dl
cmpq %rbp, %r15
setb %cl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4bcc3
movq 0x18(%rsp), %rcx
leaq 0x150(%rcx), %rbx
movb %al, 0xf(%rsp)
movq %rbx, %rdi
leaq 0xf(%rsp), %rsi
callq 0x4dc0a
movq 0x10(%rsp), %rax
movq 0x128(%rax), %r13
movb (%r13,%r15), %al
incq %r15
cmpq %rbp, %r15
setb %cl
cmpb $0x9, %al
je 0x4bcc3
cmpq %rbp, %r15
jb 0x4bc8f
testb %cl, %cl
jne 0x4bcf1
jmp 0x4bed9
movq 0x10(%rsp), %rbx
movq 0x158(%rbx), %rsi
movq 0x170(%rbx), %rdx
movq 0x30(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x128(%rbx), %r13
movq %r12, 0x40(%rsp)
movb (%r13,%r15), %bl
leaq 0x1(%r15), %rax
cmpq %rbp, %rax
setb %cl
xorl %r12d, %r12d
cmpb $0x9, %bl
je 0x4bd81
cmpq %rbp, %rax
jae 0x4bd81
xorl %r12d, %r12d
movsbl %bl, %edi
callq 0x9800
testl %eax, %eax
je 0x4bd61
leal 0x1(%r12), %r14d
movq 0x20(%rsp), %rax
cmpl 0x18(%rax), %r12d
jl 0x4bd5e
movsbq %bl, %rax
leaq 0x20814(%rip), %rcx     # 0x6c550
movb (%rcx,%rax), %al
movb %al, 0xe(%rsp)
movq 0x18(%rsp), %rdi
leaq 0xe(%rsp), %rsi
callq 0x4dc50
movq 0x10(%rsp), %rax
movq 0x128(%rax), %r13
movl %r14d, %r12d
movb 0x1(%r13,%r15), %bl
leaq 0x2(%r15), %rax
cmpq %rbp, %rax
setb %cl
incq %r15
cmpb $0x9, %bl
je 0x4bd7d
cmpq %rbp, %rax
jb 0x4bd15
leaq 0x1(%r15), %rax
xorl %r13d, %r13d
testb %cl, %cl
je 0x4bedc
movq 0x18(%rsp), %r8
movq 0x20(%r8), %rcx
movl %r12d, %edx
subl %ecx, %edx
movl %edx, 0x1a8(%r8)
movq 0x20(%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 0x10(%rsp), %rcx
movq 0x128(%rcx), %rcx
movb (%rcx,%rax), %bl
leaq 0x60(%r8), %r14
movzbl %bl, %eax
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0x4be40
cmpl $0xd, %eax
je 0x4be40
cmpl $0x20, %eax
je 0x4beee
movsbl %bl, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4bf8e
movb %al, 0xd(%rsp)
movq 0x20(%rsp), %rax
cmpl 0x18(%rax), %r13d
jl 0x4be20
movq %r14, %rdi
leaq 0xd(%rsp), %rsi
callq 0x4dc0a
cmpq %rbp, %r15
jae 0x4be3d
movq 0x10(%rsp), %rax
movq 0x128(%rax), %rax
movb (%rax,%r15), %bl
incq %r15
incl %r13d
jmp 0x4bddf
incl %r13d
cmpl %r13d, %r12d
jg 0x4beff
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rsi
jl 0x4bf10
movq 0x20(%rsp), %rax
movslq 0x14(%rax), %rcx
movq 0x18(%rsp), %rdi
movq 0x80(%rdi), %rdx
xorl %eax, %eax
subq %rcx, %rdx
movl $0x0, %ecx
cmovaeq %rdx, %rcx
movq %rcx, 0x80(%rdi)
cmpb $0x9, %bl
sete %cl
xorb $0x1, %sil
testb %sil, %cl
movb $0x1, %r12b
jne 0x4bc40
movq 0x10(%rsp), %rax
movb $0x1, 0x190(%rax)
movb $0x1, %r13b
cmpb $0x0, 0x190(%r14)
jne 0x4bedc
cmpq $0x0, 0x140(%r14)
je 0x4bedc
movq 0x20(%rsp), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq 0x10(%rsp), %rdx
movq 0x28(%rsp), %rcx
callq *0x18(%rax)
movl %eax, %r13d
jmp 0x4bedc
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4bf15
movq 0x18(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4c0f2
callq 0x4c154