// File: /workspace/github_cpp_makefile_star2_O3/BenLangmead[P]bowtie/./blockwise_sa.h
// Function: void BinarySorting_worker<SString<char>>(void*)
static void BinarySorting_worker(void *vp)
{
	BinarySortingParam<TStr>* param = (BinarySortingParam<TStr>*)vp;
	const TStr& t = *(param->t);
	size_t len = t.length();
	const EList<TIndexOffU>& sampleSuffs = *(param->sampleSuffs);
	EList<TIndexOffU>& bucketSzs = param->bucketSzs;
	EList<TIndexOffU>& bucketReps = param->bucketReps;
	ASSERT_ONLY(size_t numBuckets = bucketSzs.size());
	size_t begin = param->begin;
	size_t end = param->end;
	// Iterate through every suffix in the text, determine which
	// bucket it falls into by doing a binary search across the
	// sorted list of samples, and increment a counter associated
	// with that bucket.  Also, keep one representative for each
	// bucket so that we can split it later.  We loop in ten
	// stretches so that we can print out a helpful progress
	// message.  (This step can take a long time.)
	for(TIndexOffU i = (TIndexOffU)begin; i < end && i < len; i++) {
		TIndexOffU r = binarySASearch(t, i, sampleSuffs);
		if(r == std::numeric_limits<TIndexOffU>::max()) continue; // r was one of the samples
		assert_lt(r, numBuckets);
		bucketSzs[r]++;
		assert_lt(bucketSzs[r], len);
		if(bucketReps[r] == OFF_MASK || (i & 100) == 0) {
			bucketReps[r] = i; // clobbers previous one, but that's OK
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdi), %rax
movq %rax, -0x18(%rsp)
movq 0x18(%rax), %rcx
movl 0x50(%rdi), %edx
movq %rdi, -0x28(%rsp)
movq 0x58(%rdi), %rax
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, -0x8(%rsp)
cmpq %rcx, %rdx
jae 0xd89a
movq -0x28(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x10(%rsp)
movl 0x18(%rcx), %edi
incl %edi
movl %edi, %r15d
shrl %r15d
cmpl $0x2, %edi
jae 0xd793
movl %r15d, %r8d
movl %r8d, %eax
movq -0x28(%rsp), %rsi
movq 0x18(%rsi), %rcx
incl (%rcx,%rax,4)
movq 0x38(%rsi), %rcx
testb $0x64, %dl
je 0xd77d
cmpl $-0x1, (%rcx,%rax,4)
jne 0xd780
movl %edx, (%rcx,%rax,4)
incl %edx
cmpq %rdx, -0x8(%rsp)
movq -0x10(%rsp), %rcx
ja 0xd74c
jmp 0xd89a
movq -0x18(%rsp), %rax
movl 0x18(%rax), %r11d
movq 0x8(%rcx), %r10
movq 0x8(%rax), %rbx
xorl %r8d, %r8d
xorl %ebp, %ebp
xorl %r14d, %r14d
leal -0x1(%r15), %eax
movl (%r10,%rax,4), %r13d
cmpl %edx, %r13d
je 0xd780
cmpl %ebp, %r14d
movl %ebp, %r12d
cmovbl %r14d, %r12d
addl %r12d, %r13d
leal (%r12,%rdx), %eax
cmpl %r11d, %r13d
jae 0xd82a
cmpl %r11d, %eax
jae 0xd82a
movq %rdi, -0x20(%rsp)
addl %edx, %r12d
leaq (%rbx,%r12), %rax
movl %r13d, %esi
xorl %r9d, %r9d
leal (%rsi,%r9), %ecx
movb (%rbx,%rcx), %cl
cmpb (%rax,%r9), %cl
jne 0xd80d
movl %r9d, %ecx
leal (%rsi,%rcx), %edi
incl %edi
incq %r9
cmpl %r11d, %edi
jae 0xd80d
addl %r12d, %ecx
incl %ecx
cmpl %r11d, %ecx
jb 0xd7e6
movl %r12d, %eax
addl %r9d, %eax
addl %r9d, %r13d
movl %ebp, %ecx
movl %r14d, %r12d
cmpq %r12, %rcx
cmovbq %rcx, %r12
addl %r9d, %r12d
movq -0x20(%rsp), %rdi
cmpl %r11d, %r13d
je 0xd845
cmpl %r11d, %eax
je 0xd845
movl %r13d, %ecx
movl %eax, %eax
movb (%rbx,%rax), %al
cmpb %al, (%rbx,%rcx)
jl 0xd84a
jg 0xd85e
jmp 0xd86b
cmpl %r11d, %eax
jne 0xd859
cmpl %r12d, %ebp
cmoval %ebp, %r12d
movl %r12d, %ebp
movl %r15d, %r8d
jmp 0xd86b
cmpl %r11d, %r13d
jne 0xd86b
cmpl %r12d, %r14d
cmoval %r14d, %r12d
movl %r12d, %r14d
movl %r15d, %edi
leal (%r8,%rdi), %eax
movl %eax, %r15d
shrl %r15d
cmpl %r8d, %r15d
jne 0xd7ac
cmpl $0x2, %eax
jb 0xd75f
movl %r8d, %eax
cmpl %edx, -0x4(%r10,%rax,4)
jne 0xd75f
jmp 0xd780
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq