// File: BenLangmead[P]bowtie/pat.cpp
// Function: RawPatternSource::parse(Read&, Read&, unsigned long) const
bool RawPatternSource::parse(Read& r, Read& rb, TReadId rdid) const {
	assert(r.empty());
	assert(!r.readOrigBuf.empty());
	size_t cur = 0;
	const size_t buflen = r.readOrigBuf.length();

	// Parse sequence
	assert(r.patFw.empty());
	int nchar = 0;
	int c = r.readOrigBuf[cur++];


	cur--;
	while(cur < buflen) {
		c = r.readOrigBuf[cur++];
		if(isalpha(c)) {
			assert_in(toupper(c), "ACGTN");
			if(nchar++ >= this->trim5_) {
				assert_neq(0, asc2dnacat[c]);
				r.patFw.append(asc2dna[c]);
			}
		}
	}
	assert_eq(cur, buflen);
	// 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_));

	// Give the name field a dummy value
	char cbuf[20];
	itoa10<TReadId>(rdid, cbuf);
	r.name.install(cbuf);

	// Give the base qualities dummy values
	assert(r.qual.empty());
	const size_t len = r.patFw.length();
	for(size_t i = 0; i < len; i++) {
		r.qual.append('I');
	}
	r.parsed = true;
	if(!rb.parsed && !rb.readOrigBuf.empty()) {
		return parse(rb, r, rdid);
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x82fb0
movq %rax, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x30(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
callq 0x82fd0
movsbl (%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x825f9
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x30(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
callq 0x82fd0
movsbl (%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %edi
callq 0xaa30
cmpl $0x0, %eax
je 0x825f7
movq -0x80(%rbp), %rcx
movl -0x3c(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x3c(%rbp)
cmpl 0x18(%rcx), %eax
jl 0x825f5
movq -0x18(%rbp), %rdi
movslq -0x40(%rbp), %rcx
leaq 0x280ca(%rip), %rax     # 0xaa6b0
movb (%rax,%rcx), %al
movb %al, -0x41(%rbp)
leaq -0x41(%rbp), %rsi
callq 0x83060
jmp 0x825f7
jmp 0x82587
movslq -0x3c(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2ef90
movq -0x88(%rbp), %rcx
movq %rax, %rdx
movq -0x80(%rbp), %rax
subq %rdx, %rcx
movl %ecx, %edx
movq -0x18(%rbp), %rcx
movl %edx, 0x1a8(%rcx)
movq -0x18(%rbp), %rdi
movslq 0x14(%rax), %rsi
callq 0x830d0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1ac(%rax)
leaq -0x60(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x82eb0
movq -0x18(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
leaq -0x60(%rbp), %rsi
callq 0x83250
movq -0x18(%rbp), %rdi
callq 0x2ef90
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x826a6
movq -0x18(%rbp), %rdi
addq $0x60, %rdi
movb $0x49, -0x71(%rbp)
leaq -0x71(%rbp), %rsi
callq 0x82ff0
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x82679
movq -0x18(%rbp), %rax
movb $0x1, 0x190(%rax)
movq -0x20(%rbp), %rax
testb $0x1, 0x190(%rax)
jne 0x826ef
movq -0x20(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x35980
testb $0x1, %al
jne 0x826ef
movq -0x80(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq (%rdi), %rax
callq *0x18(%rax)
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x826f3
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)