// File: BenLangmead[P]bowtie/./aligner.h
// Function: MixedMultiAligner::run(bool, int)
void run(bool verbose = false, int tid = -1) {
#ifdef PER_THREAD_TIMING
		uint64_t ncpu_changeovers = 0;
		uint64_t nnuma_changeovers = 0;

		int current_cpu = 0, current_node = 0;
		get_cpu_and_node(current_cpu, current_node);

		std::stringstream ss;
		std::string msg;
		ss << "thread: " << tid << " time: ";
		msg = ss.str();
		Timer timer(std::cout, msg.c_str());
#endif
		bool first = true;
		bool saw_last_read = false;
		if(n_ == 1) {
			Aligner *al = seOrPe_[0] ? (*alignersSE_)[0] : (*alignersPE_)[0];
			PatternSourcePerThread *ps = (*patsrcs_)[0];
			while(true) {
#ifdef PER_THREAD_TIMING
				int cpu = 0, node = 0;
				get_cpu_and_node(cpu, node);
				if(cpu != current_cpu) {
					ncpu_changeovers++;
					current_cpu = cpu;
				}
				if(node != current_node) {
					nnuma_changeovers++;
					current_node = node;
				}
#endif
				if(!first && !al->done) {
					// Advance an aligner already in progress; this is
					// the common case
					al->advance();
				} else {
					if(saw_last_read) {
						break;
					}
					// Get a new read
					pair<bool, bool> ret = ps->nextReadPair();
					saw_last_read = ret.second;
					if(ret.first && ps->rdid() < qUpto_) {
						if(ps->paired()) {
							// Read currently in buffer is paired-end
							(*alignersPE_)[0]->setQuery(ps);
							al = (*alignersPE_)[0];
							seOrPe_[0] = false; // false -> paired
						} else {
							// Read currently in buffer is single-end
							(*alignersSE_)[0]->setQuery(ps);
							al = (*alignersSE_)[0];
							seOrPe_[0] = true; // true = unpaired
						}
					} else if (ret.first) {
						break;
					}
				}
				first = false;
			}
		} else {
			while(true) {
#ifdef PER_THREAD_TIMING
				int cpu = 0, node = 0;
				get_cpu_and_node(cpu, node);
				if(cpu != current_cpu) {
					ncpu_changeovers++;
					current_cpu = cpu;
				}
				if(node != current_node) {
					nnuma_changeovers++;
					current_node = node;
				}
#endif
				bool saw_last_read = false;
				for(uint32_t i = 0; i < n_; i++) {
					Aligner *al = seOrPe_[i] ? (*alignersSE_)[i] :
											   (*alignersPE_)[i];
					if(!first && !al->done) {
						// Advance an aligner already in progress; this is
						// the common case
						al->advance();
					} else {
						if(saw_last_read) {
							break;
						}
						// Feed a new read to a vacant aligner
						PatternSourcePerThread *ps = (*patsrcs_)[i];
						// Get a new read
						pair<bool, bool> ret = ps->nextReadPair();
						saw_last_read = ret.second;
						if (ret.first && ps->rdid() < qUpto_) {
							if(ps->paired()) {
								// Read currently in buffer is paired-end
								(*alignersPE_)[i]->setQuery(ps);
								seOrPe_[i] = false; // false -> paired
							} else {
								// Read currently in buffer is single-end
								(*alignersSE_)[i]->setQuery(ps);
								seOrPe_[i] = true; // true = unpaired
							}
						} else if (ret.first) {
							break;
						}
					}
				}
				first = false;
			}
		}
#ifdef PER_THREAD_TIMING
		ss.str("");
		ss.clear();
		ss << "thread: " << tid << " cpu_changeovers: " << ncpu_changeovers << std::endl
		   << "thread: " << tid << " node_changeovers: " << nnuma_changeovers << std::endl;
		std::cout << ss.str();
#endif
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movb $0x1, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
cmpl $0x1, 0x8(%rax)
jne 0x33487
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
testb $0x1, (%rax)
je 0x33338
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x33350
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq 0x40(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x369a0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x3338f
movq -0x20(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x3338f
movq -0x20(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x33479
testb $0x1, -0x12(%rbp)
je 0x3339a
jmp 0x33482
movq -0x28(%rbp), %rdi
callq 0x7e940
movw %ax, -0x2a(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x12(%rbp)
testb $0x1, -0x2a(%rbp)
je 0x3346d
movq -0x28(%rbp), %rdi
callq 0x499a0
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x3346d
movq -0x28(%rbp), %rdi
callq 0x656d0
testb $0x1, %al
jne 0x333e1
jmp 0x33427
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq 0x38(%rax), %rax
movb $0x0, (%rax)
jmp 0x3346b
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x50320
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq 0x38(%rax), %rax
movb $0x1, (%rax)
jmp 0x33477
testb $0x1, -0x2a(%rbp)
je 0x33475
jmp 0x33482
jmp 0x33477
jmp 0x33479
movb $0x0, -0x11(%rbp)
jmp 0x33370
jmp 0x335fc
jmp 0x33489
movb $0x0, -0x2b(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x50(%rbp), %rcx
movl -0x30(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x335f3
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x30(%rbp), %ecx
testb $0x1, (%rax,%rcx)
je 0x334d0
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x334e9
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x38(%rbp)
testb $0x1, -0x11(%rbp)
jne 0x33510
movq -0x38(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x33510
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x335e3
testb $0x1, -0x2b(%rbp)
je 0x3351b
jmp 0x335f3
movq -0x50(%rbp), %rax
movq 0x40(%rax), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x369a0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x7e940
movw %ax, -0x42(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movb %al, -0x2b(%rbp)
testb $0x1, -0x42(%rbp)
je 0x335d7
movq -0x40(%rbp), %rdi
callq 0x499a0
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpq %rcx, %rax
jae 0x335d7
movq -0x40(%rbp), %rdi
callq 0x656d0
testb $0x1, %al
jne 0x33577
jmp 0x335a7
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x30(%rbp), %ecx
movb $0x0, (%rax,%rcx)
jmp 0x335d5
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rdi
movl -0x30(%rbp), %eax
movl %eax, %esi
callq 0x50320
movq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movl -0x30(%rbp), %ecx
movb $0x1, (%rax,%rcx)
jmp 0x335e1
testb $0x1, -0x42(%rbp)
je 0x335df
jmp 0x335f3
jmp 0x335e1
jmp 0x335e3
jmp 0x335e5
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x33494
movb $0x0, -0x11(%rbp)
jmp 0x33489
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)