// File: BenLangmead[P]bowtie/pat.cpp
// Function: PatternSourcePerThread::nextReadPair()
pair<bool, bool> PatternSourcePerThread::nextReadPair() {
	// Prepare batch
	if(buf_.exhausted()) {
		pair<bool, int> res = nextBatch();
		if(res.first && res.second == 0) {
			return make_pair(false, true);
		}
		last_batch_ = res.first;
		last_batch_size_ = res.second;
		assert_eq(0, buf_.cur_buf_);
	} else {
		buf_.next(); // advance cursor
		assert_gt(buf_.cur_buf_, 0);
	}
	bool this_is_last = buf_.cur_buf_ == last_batch_size_-1;
	if(buf_.rdid() < skip_) {
		return make_pair(false, this_is_last ? last_batch_ : false);
	}
	// Parse read/pair
	assert(!buf_.read_a().readOrigBuf.empty());
	assert(buf_.read_a().empty());
	if(!parse(buf_.read_a(), buf_.read_b())) {
		return make_pair(false, false);
	}
	// Finalize read/pair
	if(paired()) {
		finalizePair(buf_.read_a(), buf_.read_b());
	} else {
		finalize(buf_.read_a());
	}
	return make_pair(true, this_is_last ? last_batch_ : false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x30(%rbp)
addq $0x8, %rdi
callq 0x829a0
testb $0x1, %al
jne 0x7e963
jmp 0x7e9b1
movq -0x30(%rbp), %rdi
callq 0x829e0
movq %rax, -0x18(%rbp)
testb $0x1, -0x18(%rbp)
je 0x7e99a
cmpl $0x0, -0x14(%rbp)
jne 0x7e99a
movb $0x0, -0x19(%rbp)
movb $0x1, -0x1a(%rbp)
leaq -0x19(%rbp), %rdi
leaq -0x1a(%rbp), %rsi
callq 0x65c90
movw %ax, -0x2(%rbp)
jmp 0x7eb07
movq -0x30(%rbp), %rax
movb -0x18(%rbp), %cl
andb $0x1, %cl
movb %cl, 0x60(%rax)
movslq -0x14(%rbp), %rcx
movq %rcx, 0x68(%rax)
jmp 0x7e9be
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x82a50
movq -0x30(%rbp), %rdi
movq 0x50(%rdi), %rax
movq 0x68(%rdi), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movb %al, -0x1b(%rbp)
addq $0x8, %rdi
callq 0x49a20
movq -0x30(%rbp), %rcx
movl 0x70(%rcx), %ecx
cmpq %rcx, %rax
jae 0x7ea29
movb $0x0, -0x1c(%rbp)
testb $0x1, -0x1b(%rbp)
je 0x7ea04
movq -0x30(%rbp), %rax
movb 0x60(%rax), %al
movb %al, -0x31(%rbp)
jmp 0x7ea0b
xorl %eax, %eax
movb %al, -0x31(%rbp)
jmp 0x7ea0b
movb -0x31(%rbp), %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
leaq -0x1c(%rbp), %rdi
leaq -0x1d(%rbp), %rsi
callq 0x65c90
movw %ax, -0x2(%rbp)
jmp 0x7eb07
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x39160
movq -0x30(%rbp), %rdi
movq %rax, -0x40(%rbp)
addq $0x8, %rdi
callq 0x38980
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %rax, %rdx
callq 0x82a70
testb $0x1, %al
jne 0x7ea79
movb $0x0, -0x1e(%rbp)
movb $0x0, -0x1f(%rbp)
leaq -0x1e(%rbp), %rdi
leaq -0x1f(%rbp), %rsi
callq 0x65c90
movw %ax, -0x2(%rbp)
jmp 0x7eb07
movq -0x30(%rbp), %rdi
callq 0x656d0
testb $0x1, %al
jne 0x7ea88
jmp 0x7eab8
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x39160
movq -0x30(%rbp), %rdi
movq %rax, -0x48(%rbp)
addq $0x8, %rdi
callq 0x38980
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq %rax, %rdx
callq 0x7e860
jmp 0x7ead1
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x39160
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x7e690
movb $0x1, -0x20(%rbp)
testb $0x1, -0x1b(%rbp)
je 0x7eae7
movq -0x30(%rbp), %rax
movb 0x60(%rax), %al
movb %al, -0x49(%rbp)
jmp 0x7eaee
xorl %eax, %eax
movb %al, -0x49(%rbp)
jmp 0x7eaee
movb -0x49(%rbp), %al
andb $0x1, %al
movb %al, -0x21(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x21(%rbp), %rsi
callq 0x65c90
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)