// File: /workspace/github_cpp_makefile_star2_O1/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, -0x8(%rsp)
movq 0x18(%rax), %rcx
movl 0x50(%rdi), %edx
movq %rdi, -0x20(%rsp)
movq 0x58(%rdi), %rax
cmpq %rcx, %rax
cmovbq %rax, %rcx
movq %rcx, -0x10(%rsp)
cmpq %rcx, %rdx
jae 0xd99b
movq -0x20(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rsp)
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
movq -0x18(%rsp), %rcx
movl 0x18(%rcx), %ebx
incl %ebx
movq -0x8(%rsp), %rax
movl 0x18(%rax), %r9d
movq 0x8(%rcx), %rcx
movq 0x8(%rax), %r11
movl $0x0, -0x2c(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rcx, -0x28(%rsp)
leal (%r15,%rbx), %eax
movl %eax, %r13d
shrl %r13d
cmpl %r15d, %r13d
jne 0xd868
cmpl $0x2, %eax
jb 0xd85e
movl %r13d, %eax
cmpl %edx, -0x4(%rcx,%rax,4)
cmovel %r10d, %r13d
xorl %eax, %eax
movl %r13d, %r12d
jmp 0xd95f
leal -0x1(%r13), %eax
movl (%rcx,%rax,4), %esi
cmpl %edx, %esi
jne 0xd880
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
jmp 0xd95f
movl -0x2c(%rsp), %eax
cmpl %r14d, %eax
movl %r14d, %ecx
cmovbl %eax, %ecx
addl %ecx, %esi
leal (%rcx,%rdx), %edi
cmpl %r9d, %edi
jae 0xd8ef
cmpl %r9d, %esi
jae 0xd8ef
addl %edx, %ecx
leaq (%r11,%rcx), %rdi
movl %esi, %r8d
xorl %r10d, %r10d
leal (%r8,%r10), %eax
movb (%r11,%rax), %al
cmpb (%rdi,%r10), %al
jne 0xd8d0
movl %r10d, %eax
leal (%r8,%rax), %ebp
incl %ebp
incq %r10
cmpl %r9d, %ebp
jae 0xd8d0
addl %ecx, %eax
incl %eax
cmpl %r9d, %eax
jb 0xd8a8
movl %ecx, %edi
addl %r10d, %edi
addl %r10d, %esi
movl %r14d, %eax
movl -0x2c(%rsp), %ecx
cmpq %rcx, %rax
cmovbq %rax, %rcx
addl %r10d, %ecx
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
cmpl %r9d, %esi
sete %al
cmpl %r9d, %edi
sete %r8b
orb %al, %r8b
cmpb $0x1, %r8b
jne 0xd918
cmpl %r9d, %edi
je 0xd927
cmpl %r9d, %esi
je 0xd948
movb $0x1, %al
testb %r8b, %r8b
je 0xd938
jmp 0xd95a
movl %esi, %eax
movb (%r11,%rax), %al
movl %edi, %r8d
cmpb (%r11,%r8), %al
jge 0xd938
cmpl %ecx, %r14d
cmoval %r14d, %ecx
movb $0x1, %al
movl %ecx, %r14d
movl %r13d, %r15d
jmp 0xd95a
movl %esi, %eax
movb (%r11,%rax), %sil
movl %edi, %edi
movb $0x1, %al
cmpb (%r11,%rdi), %sil
jle 0xd95a
movl -0x2c(%rsp), %eax
cmpl %ecx, %eax
cmoval %eax, %ecx
movb $0x1, %al
movl %ecx, -0x2c(%rsp)
movl %r13d, %ebx
movq -0x28(%rsp), %rcx
testb %al, %al
jne 0xd83f
cmpl $-0x1, %r12d
je 0xd98e
movl %r12d, %eax
movq -0x20(%rsp), %rsi
movq 0x18(%rsi), %rcx
incl (%rcx,%rax,4)
movq 0x38(%rsi), %rcx
testb $0x64, %dl
je 0xd98b
cmpl $-0x1, (%rcx,%rax,4)
jne 0xd98e
movl %edx, (%rcx,%rax,4)
incl %edx
cmpq %rdx, -0x10(%rsp)
ja 0xd811
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq