// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./blockwise_sa.h
// Function: KarkkainenBlockwiseSA<SString<char>>::nextSuffix()
virtual TIndexOffU nextSuffix() {
		// Launch threads if not
		if(this->_nthreads > 1) {
			if(_threads.size() == 0) {
				_done = new volatile bool[_sampleSuffs.size()+1];
				for (size_t i = 0; i < _sampleSuffs.size() + 1; i++) {
					_done[i] = false;
				}
				_itrBuckets.resize(this->_nthreads);
				_tparams.resize(this->_nthreads);
				for(int tid = 0; tid < this->_nthreads; tid++) {
					_tparams[tid].first = this;
					_tparams[tid].second = tid;
#if (__cplusplus >= 201103L)
					_threads.push_back(new std::thread(nextBlock_Worker, (void*)&_tparams[tid]));
#else
					_threads.push_back(new tthread::thread(nextBlock_Worker, (void*)&_tparams[tid]));
#endif
				}
				assert_eq(_threads.size(), (size_t)this->_nthreads);
			}
		}
		if(this->_itrPushedBackSuffix != OFF_MASK) {
			TIndexOffU tmp = this->_itrPushedBackSuffix;
			this->_itrPushedBackSuffix = OFF_MASK;
			return tmp;
		}
		while(this->_itrBucketPos >= this->_itrBucket.size() ||
		      this->_itrBucket.size() == 0)
		{
			if(!hasMoreBlocks()) {
				throw out_of_range("No more suffixes");
			}
			if(this->_nthreads == 1) {
				nextBlock((int)_cur);
				_cur++;
			} else {
				while(!_done[this->_itrBucketIdx]) {
					SLEEP(1);
				}
				// Read suffixes from a file
				std::ostringstream number; number << this->_itrBucketIdx;
				const string fname = _base_fname + "." + number.str() + ".sa";
				ifstream sa_file(fname.c_str(), ios::binary);
				if(!sa_file.good()) {
					cerr << "Could not open file for reading a reference graph: \"" << fname << "\"" << endl;
					throw 1;
				}
				size_t numSAs = readU<TIndexOffU>(sa_file, false /* don't endian swap */);
				this->_itrBucket.resize(numSAs);
				for(size_t i = 0; i < numSAs; i++) {
					this->_itrBucket[i] = readU<TIndexOffU>(sa_file, false);
				}
				sa_file.close();
				std::remove(fname.c_str());
			}
			this->_itrBucketIdx++;
			this->_itrBucketPos = 0;
		}
		return this->_itrBucket[this->_itrBucketPos++];
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f8, %rsp            # imm = 0x3F8
movq %rdi, %rbx
cmpl $0x2, 0x68(%rdi)
jl 0x12d06
cmpq $0x0, 0xe0(%rbx)
je 0x12ece
movl 0x3c(%rbx), %eax
cmpl $-0x1, %eax
je 0x12d17
orl $-0x1, 0x3c(%rbx)
jmp 0x12ebc
leaq 0x18(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0xa0(%rbx), %rax
movq %rax, 0x10(%rsp)
movl 0x38(%rbx), %eax
leaq 0x58(%rsp), %rbp
leaq 0x1f0(%rsp), %r14
leaq 0x140ed(%rip), %r15     # 0x26e30
movl %eax, %eax
cmpq %rax, 0x30(%rbx)
ja 0x12eaf
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x30(%rax)
testb %al, %al
je 0x12fa3
cmpl $0x1, 0x68(%rbx)
jne 0x12d7c
movl 0x70(%rbx), %esi
movq (%rbx), %rax
movq %rbx, %rdi
xorl %edx, %edx
callq *0x28(%rax)
incl 0x70(%rbx)
jmp 0x12ea1
movq 0x128(%rbx), %rax
movl 0x6c(%rbx), %ecx
cmpb $0x0, (%rax,%rcx)
jne 0x12d98
movq %r15, %rdi
xorl %esi, %esi
callq 0x5140
jmp 0x12d7c
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0x5490
movl 0x6c(%rbx), %esi
movq %r12, %rdi
callq 0x51e0
leaq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
leaq 0x12dac(%rip), %rdx     # 0x25b6d
callq 0xc191
movq %rbp, %rdi
leaq 0x80(%rsp), %rsi
callq 0x5580
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
movq %rbp, %rdx
callq 0x146ea
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
leaq 0x137cd(%rip), %rdx     # 0x265c2
callq 0xcaa8
movq %r14, %rdi
callq 0x5778
movq %rbp, %rdi
callq 0x5778
leaq 0x38(%rsp), %rdi
callq 0x5778
movq 0x18(%rsp), %rsi
movq %r14, %rdi
pushq $0x4
popq %rdx
callq 0x56b0
movq 0x1f0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x210(%rsp,%rax)
jne 0x12fd3
movq %r14, %rdi
callq 0xb069
movl %eax, %r13d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x14752
xorl %r12d, %r12d
cmpq %r12, %r13
je 0x12e73
movq %r14, %rdi
callq 0xb069
movq 0x20(%rbx), %rcx
movl %eax, (%rcx,%r12,4)
incq %r12
jmp 0x12e59
movq %r14, %rdi
callq 0x50a0
movq 0x18(%rsp), %rdi
callq 0x56a0
movq %r14, %rdi
callq 0x50f0
leaq 0x18(%rsp), %rdi
callq 0x5778
leaq 0x78(%rsp), %rdi
callq 0x50e0
incl 0x6c(%rbx)
andl $0x0, 0x38(%rbx)
xorl %eax, %eax
jmp 0x12d43
leal 0x1(%rax), %ecx
movl %ecx, 0x38(%rbx)
movq 0x20(%rbx), %rcx
movl (%rcx,%rax,4), %eax
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc8(%rbx), %r14
movq 0x60(%rbx), %r15
leaq 0x1(%r15), %rdi
callq 0x5030
movq %rax, 0x128(%rbx)
xorl %eax, %eax
incq %r15
cmpq %r15, %rax
jae 0x12f07
movq 0x128(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incq %rax
movq 0x60(%rbx), %r15
jmp 0x12eeb
leaq 0x108(%rbx), %rdi
movslq 0x68(%rbx), %rsi
callq 0x142ea
leaq 0xe8(%rbx), %rdi
movslq 0x68(%rbx), %rsi
callq 0x1432c
xorl %r12d, %r12d
leaq 0x1f0(%rsp), %rbp
xorl %r13d, %r13d
movslq 0x68(%rbx), %rax
cmpq %rax, %r13
jge 0x12d06
movq 0xf0(%rbx), %rax
movq %rbx, (%rax,%r12)
movq 0xf0(%rbx), %rax
movl %r13d, 0x8(%rax,%r12)
pushq $0x8
popq %rdi
callq 0x5370
movq %rax, %r15
movq 0xf0(%rbx), %rax
addq %r12, %rax
movq %rax, 0x78(%rsp)
movq %r15, %rdi
leaq 0x143f(%rip), %rsi      # 0x143bc
leaq 0x78(%rsp), %rdx
callq 0x14670
movq %r15, 0x1f0(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x1436e
incq %r13
addq $0x10, %r12
jmp 0x12f35
pushq $0x10
popq %rdi
callq 0x5190
movq %rax, %r14
leaq 0x135fc(%rip), %rsi     # 0x265b1
movq %rax, %rdi
callq 0x5080
movq 0x1f004(%rip), %rsi     # 0x31fc8
movq 0x1efed(%rip), %rdx     # 0x31fb8
movq %r14, %rdi
callq 0x5630
movq 0x1f016(%rip), %rdi     # 0x31ff0
leaq 0x135e5(%rip), %rsi     # 0x265c6
callq 0x5350
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x52d0
leaq 0x12cf2(%rip), %rsi     # 0x25cec
movq %rax, %rdi
callq 0x5350
movq %rax, %rdi
callq 0x5180
pushq $0x4
popq %rdi
callq 0x5190
movl $0x1, (%rax)
movq 0x1ef41(%rip), %rsi     # 0x31f60
movq %rax, %rdi
xorl %edx, %edx
callq 0x5630
jmp 0x13042
movq %rax, %rbx
jmp 0x1305c
movq %rax, %rbx
jmp 0x13096
movq %rax, %rbx
movq %r14, %rdi
callq 0x5220
jmp 0x130aa
movq %rax, %rbx
jmp 0x130a0
movq %rax, %rbx
jmp 0x13066
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x5778
leaq 0x58(%rsp), %rdi
callq 0x5778
leaq 0x38(%rsp), %rdi
jmp 0x1309b
jmp 0x13086
movq %rax, %rbx
jmp 0x130aa
movq %rax, %rbx
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x5380
jmp 0x130aa
jmp 0x13086
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x50f0
leaq 0x18(%rsp), %rdi
callq 0x5778
leaq 0x78(%rsp), %rdi
callq 0x50e0
movq %rbx, %rdi
callq 0x5680