// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./blockwise_sa.h
// Function: KarkkainenBlockwiseSA<SString<char>>::nextBlock_Worker(void*)
static void nextBlock_Worker(void *vp) {

		pair<KarkkainenBlockwiseSA*, int> param = *(pair<KarkkainenBlockwiseSA*, int>*)vp;
		KarkkainenBlockwiseSA* sa = param.first;
		int tid = param.second;
		while(true) {
			size_t cur = 0;
			{
				ThreadSafe ts(&sa->_mutex);
				cur = sa->_cur;
				if(cur > sa->_sampleSuffs.size()) break;
				sa->_cur++;
			}
			sa->nextBlock((int)cur, tid);
			// Write suffixes into a file
			std::ostringstream number; number << cur;
			const string fname = sa->_base_fname + "." + number.str() + ".sa";
			ofstream sa_file(fname.c_str(), ios::binary);
			if(!sa_file.good()) {
				cerr << "Could not open file for writing a reference graph: \"" << fname << "\"" << endl;
				throw 1;
			}
			const EList<TIndexOffU>& bucket = sa->_itrBuckets[tid];
			writeU<TIndexOffU>(sa_file, (TIndexOffU)bucket.size(), sa->_bigEndian);
			for(size_t i = 0; i < bucket.size(); i++) {
				writeU<TIndexOffU>(sa_file, bucket[i], sa->_bigEndian);
			}
			sa_file.close();
			sa->_itrBuckets[tid].clear();
			sa->_done[cur] = true;
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f8, %rsp            # imm = 0x3F8
movq (%rdi), %rbx
movslq 0x8(%rdi), %rax
leaq 0x98(%rbx), %rcx
movq %rcx, 0x18(%rsp)
leaq 0xa0(%rbx), %rcx
movq %rcx, 0x8(%rsp)
leaq 0x80(%rsp), %rbp
leaq 0x40(%rsp), %r12
movq %rax, 0x10(%rsp)
shlq $0x5, %rax
movq %rax, (%rsp)
movq %r12, %r15
movq 0x18(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x2327a
movl 0x70(%rbx), %r13d
movq 0x60(%rbx), %r12
pushq $0x3
popq %r14
cmpq %r13, %r12
jb 0x14436
leal 0x1(%r13), %eax
movl %eax, 0x70(%rbx)
xorl %r14d, %r14d
movq %rbp, %rdi
callq 0x14b42
cmpq %r13, %r12
movq %r15, %r12
jb 0x14594
movq (%rbx), %rax
movq %rbx, %rdi
movl %r13d, %esi
movq 0x10(%rsp), %rdx
callq *0x28(%rax)
leaq 0x280(%rsp), %r14
movq %r14, %rdi
callq 0x5490
movq %r14, %rdi
movq %r13, %rsi
callq 0x51e0
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rsi
leaq 0x116e3(%rip), %rdx     # 0x25b6d
callq 0xc191
movq %r12, %rdi
leaq 0x288(%rsp), %rsi
callq 0x5580
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x146ea
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
leaq 0x12106(%rip), %rdx     # 0x265c2
callq 0xcaa8
movq %rbp, %rdi
callq 0x5778
movq %r12, %rdi
callq 0x5778
movq %r14, %rdi
callq 0x5778
movq 0x20(%rsp), %rsi
movq %rbp, %rdi
pushq $0x4
popq %rdx
callq 0x53b0
movq 0x80(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0xa0(%rsp,%rax)
movq (%rsp), %r12
jne 0x145af
movq 0x110(%rbx), %r14
movl 0x18(%r14,%r12), %esi
movzbl 0xc0(%rbx), %edx
movq %rbp, %rdi
callq 0x80de
addq %r12, %r14
xorl %r12d, %r12d
cmpq 0x18(%r14), %r12
jae 0x1454a
movq 0x8(%r14), %rax
movl (%rax,%r12,4), %esi
movzbl 0xc0(%rbx), %edx
movq %rbp, %rdi
callq 0x80de
incq %r12
jmp 0x14528
movq %rbp, %rdi
callq 0x54e0
movq (%rsp), %rcx
movq 0x110(%rbx), %rax
andq $0x0, 0x18(%rax,%rcx)
movq 0x128(%rbx), %rax
movb $0x1, (%rax,%r13)
movq %rbp, %rdi
callq 0x5520
leaq 0x20(%rsp), %rdi
callq 0x5778
leaq 0x280(%rsp), %rdi
callq 0x50e0
xorl %r14d, %r14d
movq %r15, %r12
testl %r14d, %r14d
je 0x14406
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1da3a(%rip), %rdi     # 0x31ff0
leaq 0x1203e(%rip), %rsi     # 0x265fb
callq 0x5350
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x52d0
leaq 0x11716(%rip), %rsi     # 0x25cec
movq %rax, %rdi
callq 0x5350
movq %rax, %rdi
callq 0x5180
pushq $0x4
popq %rdi
callq 0x5190
movl $0x1, (%rax)
movq 0x1d965(%rip), %rsi     # 0x31f60
movq %rax, %rdi
xorl %edx, %edx
callq 0x5630
movq %rax, %rbx
jmp 0x1462d
movq %rax, %rbx
jmp 0x14637
jmp 0x14611
movq %rax, %rbx
jmp 0x1465a
jmp 0x14640
movq %rax, %rbx
jmp 0x14650
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5778
leaq 0x40(%rsp), %rdi
callq 0x5778
leaq 0x60(%rsp), %rdi
jmp 0x14655
jmp 0x14640
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5520
leaq 0x20(%rsp), %rdi
callq 0x5778
leaq 0x280(%rsp), %rdi
callq 0x50e0
movq %rbx, %rdi
callq 0x5680
nop