// File: 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
movq %rsp, %rbp
subq $0x4a0, %rsp            # imm = 0x4A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x18(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rsi
addq $0x98, %rsi
leaq -0x38(%rbp), %rdi
callq 0x26660
movq -0x20(%rbp), %rax
movl 0x70(%rax), %eax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x460(%rbp)
movq -0x20(%rbp), %rdi
addq $0x48, %rdi
callq 0x14440
movq %rax, %rcx
movq -0x460(%rbp), %rax
cmpq %rcx, %rax
jbe 0x257b7
movl $0x3, -0x3c(%rbp)
jmp 0x257cb
movq -0x20(%rbp), %rax
movl 0x70(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x70(%rax)
movl $0x0, -0x3c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x26690
movl -0x3c(%rbp), %eax
testl %eax, %eax
je 0x257e2
jmp 0x257dd
jmp 0x25ba1
movq -0x20(%rbp), %rdi
movl -0x30(%rbp), %esi
movl -0x24(%rbp), %edx
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x468(%rbp)
callq 0x6600
movq -0x468(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6100
jmp 0x2581a
movq -0x20(%rbp), %rsi
addq $0xa0, %rsi
leaq 0x202b1(%rip), %rdx     # 0x45add
leaq -0x228(%rbp), %rdi
callq 0x15d70
jmp 0x2583a
leaq -0x248(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x6450
jmp 0x2584f
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rsi
leaq -0x248(%rbp), %rdx
callq 0x25c80
jmp 0x2586b
leaq 0x20cc0(%rip), %rdx     # 0x46532
leaq -0x1e8(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x16d50
jmp 0x25887
leaq -0x208(%rbp), %rdi
callq 0x69a8
leaq -0x248(%rbp), %rdi
callq 0x69a8
leaq -0x228(%rbp), %rdi
callq 0x69a8
leaq -0x1e8(%rbp), %rdi
callq 0x61b0
movq %rax, %rsi
leaq -0x448(%rbp), %rdi
movl $0x4, %edx
callq 0x64b0
jmp 0x258cd
movq -0x448(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x448(%rbp,%rax), %rdi
callq 0x67d0
movb %al, -0x469(%rbp)
jmp 0x258ed
movb -0x469(%rbp), %al
testb $0x1, %al
jne 0x25a42
jmp 0x258fd
movq 0x2c6ec(%rip), %rdi     # 0x51ff0
leaq 0x20c60(%rip), %rsi     # 0x4656b
callq 0x6410
movq %rax, -0x478(%rbp)
jmp 0x25919
movq -0x478(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x6380
movq %rax, -0x480(%rbp)
jmp 0x25935
movq -0x480(%rbp), %rdi
leaq 0x20319(%rip), %rsi     # 0x45c5c
callq 0x6410
movq %rax, -0x488(%rbp)
jmp 0x25951
movq -0x488(%rbp), %rdi
movq 0x2c609(%rip), %rsi     # 0x51f68
callq 0x6470
jmp 0x25966
movl $0x4, %edi
callq 0x61f0
movq %rax, %rdi
movl $0x1, (%rdi)
movq 0x2c5d0(%rip), %rsi     # 0x51f50
xorl %eax, %eax
movl %eax, %edx
callq 0x67f0
jmp 0x25bb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x25b93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x259f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x259eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x69a8
leaq -0x248(%rbp), %rdi
callq 0x69a8
leaq -0x228(%rbp), %rdi
callq 0x69a8
jmp 0x25b93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
jmp 0x25b87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1c0(%rbp)
movl %eax, -0x1c4(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x66c0
jmp 0x25b87
movq -0x20(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
movslq -0x24(%rbp), %rsi
callq 0x266c0
movq %rax, -0x490(%rbp)
jmp 0x25a5f
movq -0x490(%rbp), %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rdi
callq 0x14440
movl %eax, %esi
movq -0x20(%rbp), %rax
movzbl 0xc0(%rax), %edx
andl $0x1, %edx
leaq -0x448(%rbp), %rdi
callq 0xbd10
jmp 0x25a97
movq $0x0, -0x458(%rbp)
movq -0x458(%rbp), %rax
movq %rax, -0x498(%rbp)
movq -0x450(%rbp), %rdi
callq 0x14440
movq %rax, %rcx
movq -0x498(%rbp), %rax
cmpq %rcx, %rax
jae 0x25b12
movq -0x450(%rbp), %rdi
movq -0x458(%rbp), %rsi
callq 0x19d10
movl (%rax), %esi
movq -0x20(%rbp), %rax
movzbl 0xc0(%rax), %edx
andl $0x1, %edx
leaq -0x448(%rbp), %rdi
callq 0xbd10
jmp 0x25afc
jmp 0x25afe
movq -0x458(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x458(%rbp)
jmp 0x25aa2
leaq -0x448(%rbp), %rdi
callq 0x6670
jmp 0x25b20
movq -0x20(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
movslq -0x24(%rbp), %rsi
callq 0x266c0
movq %rax, -0x4a0(%rbp)
jmp 0x25b3d
movq -0x4a0(%rbp), %rdi
callq 0x266f0
jmp 0x25b4b
movq -0x20(%rbp), %rax
movq 0x128(%rax), %rax
movq -0x30(%rbp), %rcx
movb $0x1, (%rax,%rcx)
leaq -0x448(%rbp), %rdi
callq 0x66c0
leaq -0x1e8(%rbp), %rdi
callq 0x69a8
leaq -0x1b8(%rbp), %rdi
callq 0x6110
jmp 0x25760
leaq -0x1e8(%rbp), %rdi
callq 0x69a8
leaq -0x1b8(%rbp), %rdi
callq 0x6110
jmp 0x25baa
addq $0x4a0, %rsp            # imm = 0x4A0
popq %rbp
retq
movq -0x1c0(%rbp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)