// File: 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
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x458(%rbp)
cmpl $0x1, 0x68(%rax)
jle 0x22ed3
movq -0x458(%rbp), %rdi
addq $0xc8, %rdi
callq 0x25570
cmpq $0x0, %rax
jne 0x22ed1
movq -0x458(%rbp), %rdi
addq $0x48, %rdi
callq 0x14440
movq %rax, %rdi
addq $0x1, %rdi
callq 0x6040
movq %rax, %rcx
movq -0x458(%rbp), %rax
movq %rcx, 0x128(%rax)
movq $0x0, -0x18(%rbp)
movq -0x458(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x460(%rbp)
addq $0x48, %rdi
callq 0x14440
movq %rax, %rcx
movq -0x460(%rbp), %rax
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0x22d88
movq -0x458(%rbp), %rax
movq 0x128(%rax), %rax
movq -0x18(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x22d36
movq -0x458(%rbp), %rax
movq %rax, %rdi
addq $0x108, %rdi            # imm = 0x108
movslq 0x68(%rax), %rsi
callq 0x25590
movq -0x458(%rbp), %rax
movq %rax, %rdi
addq $0xe8, %rdi
movslq 0x68(%rax), %rsi
callq 0x25610
movl $0x0, -0x1c(%rbp)
movq -0x458(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x68(%rcx), %eax
jge 0x22ecf
movq -0x458(%rbp), %rdi
addq $0xe8, %rdi
movq %rdi, -0x478(%rbp)
movslq -0x1c(%rbp), %rsi
callq 0x25690
movq -0x458(%rbp), %rcx
movq -0x478(%rbp), %rdi
movq %rcx, (%rax)
movslq -0x1c(%rbp), %rsi
movl %esi, %eax
movl %eax, -0x484(%rbp)
callq 0x25690
movl -0x484(%rbp), %edx
movq %rax, %rcx
movq -0x458(%rbp), %rax
movl %edx, 0x8(%rcx)
addq $0xc8, %rax
movq %rax, -0x480(%rbp)
movl $0x8, %edi
callq 0x6430
movq -0x478(%rbp), %rdi
movq %rax, -0x470(%rbp)
movslq -0x1c(%rbp), %rsi
callq 0x25690
movq %rax, -0x468(%rbp)
jmp 0x22e60
movq -0x470(%rbp), %rdi
movq -0x468(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x28b7(%rip), %rsi      # 0x25730
leaq -0x30(%rbp), %rdx
callq 0x25bc0
jmp 0x22e84
movq -0x480(%rbp), %rdi
movq -0x470(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x256c0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22dc3
movq -0x470(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x8, %esi
callq 0x6440
jmp 0x233b4
jmp 0x22ed1
jmp 0x22ed3
movq -0x458(%rbp), %rax
cmpl $-0x1, 0x3c(%rax)
je 0x22eff
movq -0x458(%rbp), %rax
movl 0x3c(%rax), %ecx
movl %ecx, -0x40(%rbp)
movl $0xffffffff, 0x3c(%rax) # imm = 0xFFFFFFFF
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x233a8
jmp 0x22f01
movq -0x458(%rbp), %rdi
movl 0x38(%rdi), %eax
movq %rax, -0x490(%rbp)
addq $0x18, %rdi
callq 0x14440
movq -0x490(%rbp), %rcx
movq %rax, %rdx
movb $0x1, %al
cmpq %rdx, %rcx
movb %al, -0x485(%rbp)
jae 0x22f4f
movq -0x458(%rbp), %rdi
addq $0x18, %rdi
callq 0x14440
cmpq $0x0, %rax
sete %al
movb %al, -0x485(%rbp)
movb -0x485(%rbp), %al
testb $0x1, %al
jne 0x22f5e
jmp 0x23381
movq -0x458(%rbp), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
testb $0x1, %al
jne 0x22fcb
movl $0x10, %edi
callq 0x61f0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x498(%rbp)
leaq 0x23594(%rip), %rsi     # 0x46521
callq 0x60b0
jmp 0x22f94
movq -0x498(%rbp), %rdi
movq 0x2f02e(%rip), %rsi     # 0x51fd0
movq 0x2f017(%rip), %rdx     # 0x51fc0
callq 0x67f0
movq -0x498(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x62a0
jmp 0x233b4
movq -0x458(%rbp), %rax
cmpl $0x1, 0x68(%rax)
jne 0x22fff
movq -0x458(%rbp), %rdi
movl 0x70(%rdi), %esi
movq (%rdi), %rax
xorl %edx, %edx
callq *0x28(%rax)
movq -0x458(%rbp), %rax
movl 0x70(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x70(%rax)
jmp 0x23365
jmp 0x23001
movq -0x458(%rbp), %rcx
movq 0x128(%rcx), %rax
movl 0x6c(%rcx), %ecx
movb (%rax,%rcx), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x2301d
jmp 0x2302f
leaq 0x23d7c(%rip), %rdi     # 0x46da0
xorl %eax, %eax
movl %eax, %esi
callq 0x6170
jmp 0x23001
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x6600
movq -0x458(%rbp), %rax
movq -0x4a0(%rbp), %rdi
movl 0x6c(%rax), %esi
callq 0x65f0
jmp 0x2305a
movq -0x458(%rbp), %rsi
addq $0xa0, %rsi
leaq 0x22a6e(%rip), %rdx     # 0x45add
leaq -0x218(%rbp), %rdi
callq 0x15d70
jmp 0x2307d
leaq -0x238(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x6450
jmp 0x23092
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
leaq -0x238(%rbp), %rdx
callq 0x25c80
jmp 0x230ae
leaq 0x2347d(%rip), %rdx     # 0x46532
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x16d50
jmp 0x230ca
leaq -0x1f8(%rbp), %rdi
callq 0x69a8
leaq -0x238(%rbp), %rdi
callq 0x69a8
leaq -0x218(%rbp), %rdi
callq 0x69a8
leaq -0x1d8(%rbp), %rdi
callq 0x61b0
movq %rax, %rsi
leaq -0x440(%rbp), %rdi
movl $0x4, %edx
callq 0x68b0
jmp 0x23110
movq -0x440(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x440(%rbp,%rax), %rdi
callq 0x67d0
movb %al, -0x4a1(%rbp)
jmp 0x23130
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0x23261
jmp 0x23140
movq 0x2eea9(%rip), %rdi     # 0x51ff0
leaq 0x233e8(%rip), %rsi     # 0x46536
callq 0x6410
movq %rax, -0x4b0(%rbp)
jmp 0x2315c
movq -0x4b0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x6380
movq %rax, -0x4b8(%rbp)
jmp 0x23178
movq -0x4b8(%rbp), %rdi
leaq 0x22ad6(%rip), %rsi     # 0x45c5c
callq 0x6410
movq %rax, -0x4c0(%rbp)
jmp 0x23194
movq -0x4c0(%rbp), %rdi
movq 0x2edc6(%rip), %rsi     # 0x51f68
callq 0x6470
jmp 0x231a9
movl $0x4, %edi
callq 0x61f0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x2ed8d(%rip), %rsi     # 0x51f50
xorl %eax, %eax
movl %eax, %edx
callq 0x67f0
jmp 0x233bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x23357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x23222
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x23216
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x69a8
leaq -0x238(%rbp), %rdi
callq 0x69a8
leaq -0x218(%rbp), %rdi
callq 0x69a8
jmp 0x23357
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2334b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x6120
jmp 0x2334b
leaq -0x440(%rbp), %rdi
xorl %esi, %esi
callq 0x12400
movl %eax, -0x4c4(%rbp)
jmp 0x23277
movq -0x458(%rbp), %rdi
movl -0x4c4(%rbp), %eax
movl %eax, %eax
movq %rax, -0x448(%rbp)
addq $0x18, %rdi
movq -0x448(%rbp), %rsi
callq 0x25d50
jmp 0x2329f
movq $0x0, -0x450(%rbp)
movq -0x450(%rbp), %rax
cmpq -0x448(%rbp), %rax
jae 0x23303
leaq -0x440(%rbp), %rdi
xorl %esi, %esi
callq 0x12400
movl %eax, -0x4c8(%rbp)
jmp 0x232d0
movq -0x458(%rbp), %rdi
addq $0x18, %rdi
movq -0x450(%rbp), %rsi
callq 0x14410
movl -0x4c8(%rbp), %ecx
movl %ecx, (%rax)
movq -0x450(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x450(%rbp)
jmp 0x232aa
leaq -0x440(%rbp), %rdi
callq 0x60e0
jmp 0x23311
leaq -0x1d8(%rbp), %rdi
callq 0x61b0
movq %rax, %rdi
callq 0x6890
leaq -0x440(%rbp), %rdi
callq 0x6120
leaq -0x1d8(%rbp), %rdi
callq 0x69a8
leaq -0x1b8(%rbp), %rdi
callq 0x6110
jmp 0x23365
leaq -0x1d8(%rbp), %rdi
callq 0x69a8
leaq -0x1b8(%rbp), %rdi
callq 0x6110
jmp 0x233b4
movq -0x458(%rbp), %rax
movl 0x6c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x6c(%rax)
movl $0x0, 0x38(%rax)
jmp 0x22f01
movq -0x458(%rbp), %rcx
movq %rcx, %rdi
addq $0x18, %rdi
movl 0x38(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x38(%rcx)
movl %eax, %eax
movl %eax, %esi
callq 0x14410
movl (%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x6850
nopl (%rax)