// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/pat.cpp
// Function: FastaContinuousPatternSource::nextBatchFromFile(PerThreadReadBuf&, bool, unsigned long)
pair<bool, int> FastaContinuousPatternSource::nextBatchFromFile(
	PerThreadReadBuf& pt,
	bool batch_a,
	size_t readi)
{
	int c = -1;
	EList<Read>& readbuf = batch_a ? pt.bufa_ : pt.bufb_;
	while(readi < pt.max_buf_) {
		c = getc_wrapper();
		if(c < 0) {
			break;
		}
		if(c == '>') {
			resetForNextFile();
			c = getc_wrapper();
			bool sawSpace = false;
			while(c != '\n' && c != '\r') {
				if(!sawSpace) {
					sawSpace = isspace(c);
				}
				if(!sawSpace) {
					// Put it in the name prefix buffer so we
					// can re-use this prefix for all the reads
					// that are substrings of this FASTA sequence
					name_prefix_buf_.push_back(c);
				}
				c = getc_wrapper();
			}
			while(c == '\n' || c == '\r') {
				c = getc_wrapper();
			}
			if(c < 0) {
				break;
			}
			name_prefix_buf_.push_back('_');
		}
		int cat = asc2dnacat[c];
		if(cat >= 2) c = 'N';
		if(cat == 0) {
			// Non-DNA, non-IUPAC char; skip
			continue;
		} else {
			// DNA char
			buf_[bufCur_++] = c;
			if(bufCur_ == 1024) {
				bufCur_ = 0; // wrap around circular buf
			}
			if(eat_ > 0) {
				eat_--;
				// Try to keep readCnt_ aligned with the offset
				// into the reference; that lets us see where
				// the sampling gaps are by looking at the read
				// name
				if(!beginning_) {
					cur_++;
				}
				continue;
			}
			// install name
			readbuf[readi].readOrigBuf.append(name_prefix_buf_.c_str());
			itoa10<TReadId>(cur_ - last_, name_int_buf_);
			readbuf[readi].readOrigBuf.append(name_int_buf_);
			readbuf[readi].readOrigBuf.append('\t');
			// install sequence
			for(size_t i = 0; i < length_; i++) {
				if(length_ - i <= bufCur_) {
					c = buf_[bufCur_ - (length_ - i)];
				} else {
					// Rotate
					c = buf_[bufCur_ - (length_ - i) + 1024];
				}
				readbuf[readi].readOrigBuf.append(c);
			}
			eat_ = freq_-1;
			cur_++;
			beginning_ = false;
			readi++;
		}
	}
	return make_pair(c < 0, readi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
xorb $0x1, %dl
movzbl %dl, %eax
shll $0x5, %eax
orq $0x8, %rax
movq %rax, 0x10(%rsp)
leaq 0x204c8(%rdi), %r12
leaq 0x204e8(%rdi), %rax
movq %rax, 0x28(%rsp)
pushq $-0x1
popq %rbp
leaq 0x222b4(%rip), %rbx     # 0x64760
pushq $0x4e
popq %r13
movq %r14, 0x18(%rsp)
movq 0x20(%rsp), %rax
cmpq (%rax), %r14
jae 0x426fb
movq %r15, %rdi
callq 0x4398e
movl %eax, %ebp
testl %eax, %eax
js 0x426fb
cmpl $0x3e, %ebp
jne 0x42557
movl %r13d, %r14d
movq %rbx, %r13
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x4398e
movl %eax, %ebp
cmpl $0xd, %eax
je 0x42523
cmpl $0xa, %ebp
je 0x42523
testb $0x1, %bl
jne 0x42510
movl %ebp, %edi
callq 0x9070
testl %eax, %eax
setne %bl
testb $0x1, %bl
jne 0x424eb
movsbl %bpl, %esi
movq %r12, %rdi
callq 0x9440
jmp 0x424eb
movq %r13, %rbx
movl %r14d, %r13d
movq 0x18(%rsp), %r14
cmpl $0xd, %ebp
je 0x42538
cmpl $0xa, %ebp
jne 0x42544
movq %r15, %rdi
callq 0x4398e
movl %eax, %ebp
jmp 0x4252e
testl %ebp, %ebp
js 0x426fb
movq %r12, %rdi
pushq $0x5f
popq %rsi
callq 0x9440
movl %ebp, %eax
movb (%rbx,%rax), %al
cmpb $0x2, %al
cmovael %r13d, %ebp
testb %al, %al
je 0x424b5
movq 0x20500(%r15), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x20500(%r15)
movb %bpl, 0x200c1(%r15,%rax)
cmpq $0x400, 0x20500(%r15) # imm = 0x400
jne 0x42599
andq $0x0, 0x20500(%r15)
movq 0x200b8(%r15), %rax
testq %rax, %rax
je 0x425c9
decq %rax
movq %rax, 0x200b8(%r15)
cmpb $0x0, 0x200c0(%r15)
jne 0x424b5
incq 0x20508(%r15)
jmp 0x424b5
movq 0x20(%rsp), %rbx
imulq $0x268, %r14, %r14      # imm = 0x268
movq 0x10(%rsp), %rax
movq 0x8(%rbx,%rax), %rdi
addq %r14, %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
movq 0x204c8(%r15), %rsi
callq 0x438da
movq 0x20508(%r15), %rax
subq 0x20510(%r15), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x28(%rsp), %r13
movq %r13, %rsi
callq 0x4389b
movq 0x10(%rsp), %rax
movq 0x8(%rbx,%rax), %rdi
addq %r14, %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
movq %r13, %rsi
callq 0x438da
movq 0x10(%rsp), %rax
movq 0x8(%rbx,%rax), %rdi
movq %r14, %r13
addq %r14, %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
movb $0x9, 0xf(%rsp)
leaq 0xf(%rsp), %rsi
callq 0x439de
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x200a8(%r15), %rax
cmpq %rax, %r14
jae 0x426ce
leaq (%rbx,%rax), %rcx
movq 0x20500(%r15), %rdx
movq %rdx, %rsi
subq %rax, %rsi
leaq (%r14,%rsi), %rax
cmpq %rdx, %rcx
leaq 0x400(%r14,%rsi), %rcx
cmovbeq %rax, %rcx
movsbl 0x200c1(%r15,%rcx), %ebp
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
movq 0x8(%rcx,%rax), %rax
leaq (%rax,%r13), %rdi
addq $0x120, %rdi            # imm = 0x120
movb %bpl, 0xe(%rsp)
leaq 0xe(%rsp), %rsi
callq 0x439de
incq %r14
decq %rbx
jmp 0x42664
movq 0x200b0(%r15), %rax
decq %rax
movq %rax, 0x200b8(%r15)
incq 0x20508(%r15)
movb $0x0, 0x200c0(%r15)
movq 0x18(%rsp), %r14
incq %r14
jmp 0x424a5
shrl $0x1f, %ebp
shlq $0x20, %r14
orq %rbp, %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop