// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/pat.cpp
// Function: FastqPatternSource::nextBatchFromFile(PerThreadReadBuf&, bool, unsigned long)
pair<bool, int> FastqPatternSource::nextBatchFromFile(
	PerThreadReadBuf& pt,
	bool batch_a,
	size_t readi)
{
	int c = 0;
	EList<Read>* readBuf = batch_a ? &pt.bufa_ : &pt.bufb_;
	if(first_) {
		c = getc_wrapper();
		while(c == '\r' || c == '\n') {
			c = getc_wrapper();
		}
		if(c != '@') {
			cerr << "Error: reads file does not look like a FASTQ file" << endl;
			throw 1;
		}
		first_ = false;
		(*readBuf)[readi].readOrigBuf.append('@');
	}
	bool done = false, aborted = false;
	// Read until we run out of input or until we've filled the buffer
	while (readi < pt.max_buf_ && !done) {
		Read::TBuf& buf = (*readBuf)[readi].readOrigBuf;
		assert(readi == 0 || (*readBuf)[readi].readOrigBuf.length() == 0);
		int newlines = 4;
		while(newlines) {
			c = getc_wrapper();
			done = c < 0;
			if(c == '\n' || (done && newlines == 1)) {
				// Saw newline, or EOF that we're
				// interpreting as final newline
				newlines--;
				c = '\n';
			} else if(done) {
				if (newlines == 4) {
					newlines = 0;
				} else {
					aborted = true; // Unexpected EOF
				}
				break;
			}
			buf.append(c);
		}
		if (c > 0) {
			if (interleaved_) {
				// alternate between read buffers
				batch_a = !batch_a;
				readBuf = batch_a ? &pt.bufa_ : &pt.bufb_;
				// increment read counter after each pair gets read
				readi = batch_a ? readi + 1 : readi;
			}
			else {
				readi++;
			}
		}
	}
	if(aborted) {
		readi--;
	}
	return make_pair(done, readi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %rbx
movq %rsi, %r13
movq %rdi, %r15
leaq 0x8(%rsi), %r14
leaq 0x28(%rsi), %r12
movl %edx, 0xc(%rsp)
testl %edx, %edx
movq %r12, %rbp
cmovneq %r14, %rbp
cmpb $0x1, 0x200a3(%rdi)
jne 0x4cadd
movq %r15, %rdi
callq 0x4dc96
cmpl $0xa, %eax
je 0x4ca97
cmpl $0xd, %eax
je 0x4ca97
cmpl $0x40, %eax
jne 0x4cc0c
movb $0x0, 0x200a3(%r15)
movq 0x8(%rbp), %rax
imulq $0x268, %rbx, %rcx      # imm = 0x268
leaq (%rax,%rcx), %rdi
addq $0x120, %rdi            # imm = 0x120
leaq 0xb(%rsp), %rsi
movb $0x40, (%rsi)
callq 0x4dce6
cmpq %rbx, (%r13)
jbe 0x4cbd9
movq %r12, 0x28(%rsp)
movq %r14, 0x30(%rsp)
leaq 0xa(%rsp), %r12
movq %r13, 0x18(%rsp)
movq %rbp, 0x20(%rsp)
movq 0x8(%rbp), %rax
movq %rbx, 0x10(%rsp)
imulq $0x268, %rbx, %rcx      # imm = 0x268
leaq (%rax,%rcx), %rbp
addq $0x120, %rbp            # imm = 0x120
movl $0x4, %ebx
movq %r15, %rdi
callq 0x4dc96
movl %eax, %r14d
testl %eax, %eax
sets %al
cmpl $0x1, %ebx
sete %cl
cmpl $0xa, %r14d
je 0x4cb4e
andb %al, %cl
jne 0x4cb4e
testl %r14d, %r14d
js 0x4cbdf
movl %r14d, %r13d
jmp 0x4cb56
decl %ebx
movl $0xa, %r13d
movb %r13b, 0xa(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4dce6
testl %ebx, %ebx
jne 0x4cb20
testl %r13d, %r13d
je 0x4cbad
cmpb $0x1, 0x200a7(%r15)
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %rbp
jne 0x4cbbe
movl 0xc(%rsp), %ecx
movl %ecx, %eax
xorb $0x1, %al
testb $0x1, %cl
movq 0x30(%rsp), %rbp
cmovneq 0x28(%rsp), %rbp
movzbl %al, %ecx
andl $0x1, %ecx
addq %rcx, %rbx
movl %eax, 0xc(%rsp)
jmp 0x4cbc1
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r13
movq 0x20(%rsp), %rbp
jmp 0x4cbc1
incq %rbx
shrl $0x1f, %r14d
cmpq (%r13), %rbx
jae 0x4cbd4
testb %r14b, %r14b
je 0x4cafb
movl %r14d, %ecx
jmp 0x4cbdb
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x4cbf4
xorl %eax, %eax
cmpl $0x4, %ebx
setne %al
negq %rax
movl $0x1, %ecx
movq 0x10(%rsp), %rbx
addl %ebx, %eax
shlq $0x20, %rax
orq %rcx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1d3dd(%rip), %rdi     # 0x69ff0
leaq 0xa4b2(%rip), %rsi      # 0x570cc
callq 0x9490
movq %rax, %rdi
callq 0x91f0
movl $0x4, %edi
callq 0x9200
movl $0x1, (%rax)
movq 0x1d2fa(%rip), %rsi     # 0x69f38
movq %rax, %rdi
xorl %edx, %edx
callq 0x98f0