// File: BenLangmead[P]bowtie/pat.cpp
// Function: FastaContinuousPatternSource::parse(Read&, Read&, unsigned long) const
bool FastaContinuousPatternSource::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();

	// Parse read name
	c = ra.readOrigBuf[cur++];
	while(c != '\t' && cur < buflen) {
		ra.name.append(c);
		c = ra.readOrigBuf[cur++];
	}
	assert_eq('\t', c);
	if(cur >= buflen) {
		return false; // record ended prematurely
	}

	// Parse sequence
	assert(ra.patFw.empty());
	int nchar = 0;
	while(cur < buflen) {
		c = ra.readOrigBuf[cur++];
		if(isalpha(c)) {
			assert_in(toupper(c), "ACGTN");
			if(nchar++ >= this->trim5_) {
				assert_neq(0, asc2dnacat[c]);
				ra.patFw.append(asc2dna[c]); // ascii to int
			}
		}
	}
	// record amt trimmed from 5' end due to --trim5
	ra.trimmed5 = (int)(nchar - ra.patFw.length());
	// record amt trimmed from 3' end due to --trim3
	ra.trimmed3 = (int)(ra.patFw.trimEnd(this->trim3_));

	// Make fake qualities
	assert(ra.qual.empty());
	for(size_t i = 0; i < ra.patFw.length(); i++) {
		ra.qual.append('I');
	}

	ra.parsed = true;
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x9, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
callq 0x82fb0
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x38(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
callq 0x82fd0
movsbl (%rax), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x9, -0x2c(%rbp)
movb %al, -0x69(%rbp)
je 0x80ff4
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
setb %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x80ffd
jmp 0x8103e
movq -0x18(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
movl -0x2c(%rbp), %eax
movb %al, -0x41(%rbp)
leaq -0x41(%rbp), %rsi
callq 0x82ff0
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x38(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
callq 0x82fd0
movsbl (%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x80fdb
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jb 0x81051
movb $0x0, -0x1(%rbp)
jmp 0x81165
movl $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x810ca
movq -0x18(%rbp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq -0x38(%rbp), %rsi
movq %rsi, %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
callq 0x82fd0
movsbl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %edi
callq 0xaa30
cmpl $0x0, %eax
je 0x810c8
movq -0x68(%rbp), %rcx
movl -0x48(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x48(%rbp)
cmpl 0x18(%rcx), %eax
jl 0x810c6
movq -0x18(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq 0x295f9(%rip), %rax     # 0xaa6b0
movb (%rax,%rcx), %al
movb %al, -0x49(%rbp)
leaq -0x49(%rbp), %rsi
callq 0x83060
jmp 0x810c8
jmp 0x81058
movslq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2ef90
movq -0x78(%rbp), %rcx
movq %rax, %rdx
movq -0x68(%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)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2ef90
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x81156
movq -0x18(%rbp), %rdi
addq $0x60, %rdi
movb $0x49, -0x59(%rbp)
leaq -0x59(%rbp), %rsi
callq 0x82ff0
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x81116
movq -0x18(%rbp), %rax
movb $0x1, 0x190(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)