// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/index.c
// Function: worker_post
static void worker_post(void *g, long i, int tid)
{
	int n, n_keys;
	size_t j, start_a, start_p;
	idxhash_t *h;
	mm_idx_t *mi = (mm_idx_t*)g;
	mm_idx_bucket_t *b = &mi->B[i];
	if (b->a.n == 0) return;

	// sort by minimizer
	radix_sort_128x(b->a.a, b->a.a + b->a.n);

	// count and preallocate
	for (j = 1, n = 1, n_keys = 0, b->n = 0; j <= b->a.n; ++j) {
		if (j == b->a.n || b->a.a[j].x>>8 != b->a.a[j-1].x>>8) {
			++n_keys;
			if (n > 1) b->n += n;
			n = 1;
		} else ++n;
	}
	h = kh_init(idx);
	kh_resize(idx, h, n_keys);
	b->p = (uint64_t*)calloc(b->n, 8);

	// create the hash table
	for (j = 1, n = 1, start_a = start_p = 0; j <= b->a.n; ++j) {
		if (j == b->a.n || b->a.a[j].x>>8 != b->a.a[j-1].x>>8) {
			khint_t itr;
			int absent;
			mm128_t *p = &b->a.a[j-1];
			itr = kh_put(idx, h, p->x>>8>>mi->b<<1, &absent);
			assert(absent && j == start_a + n);
			if (n == 1) {
				kh_key(h, itr) |= 1;
				kh_val(h, itr) = p->y;
			} else {
				int k;
				for (k = 0; k < n; ++k)
					b->p[start_p + k] = b->a.a[start_a + k].y;
				radix_sort_64(&b->p[start_p], &b->p[start_p + n]); // sort by position; needed as in-place radix_sort_128x() is not stable
				kh_val(h, itr) = (uint64_t)start_p<<32 | n;
				start_p += n;
			}
			start_a = j, n = 1;
		} else ++n;
	}
	b->h = h;
	assert(b->n == (int32_t)start_p);

	// deallocate and clear b->a
	kfree(0, b->a.a);
	b->a.n = b->a.m = 0, b->a.a = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
imulq $0x30, -0x10(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xe37e
jmp 0xe70e
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x50(%rbp), %rax
movq (%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5ad0
movq $0x1, -0x28(%rbp)
movl $0x1, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x50(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
ja 0xe45e
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
je 0xe41d
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x8, %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x28(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x8, %rcx
cmpq %rcx, %rax
je 0xe442
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x18(%rbp)
jle 0xe439
movl -0x18(%rbp), %ecx
movq -0x50(%rbp), %rax
addl 0x18(%rax), %ecx
movl %ecx, 0x18(%rax)
movl $0x1, -0x18(%rbp)
jmp 0xe44b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe44d
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xe3c2
callq 0xa500
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0xa520
movq -0x50(%rbp), %rax
movslq 0x18(%rax), %rdi
movl $0x8, %esi
callq 0x2220
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movq $0x1, -0x28(%rbp)
movl $0x1, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
ja 0xe69e
movq -0x28(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
je 0xe50e
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x8, %rax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x28(%rbp), %rdx
subq $0x1, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rcx
shrq $0x8, %rcx
cmpq %rcx, %rax
je 0xe682
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rax
movq (%rax), %rsi
shrq $0x8, %rsi
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, %ecx
shrq %cl, %rsi
shlq %rsi
leaq -0x58(%rbp), %rdx
callq 0xaa00
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0xe56e
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x18(%rbp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jne 0xe56e
jmp 0xe58d
leaq 0x48cc0(%rip), %rdi     # 0x57235
leaq 0x48925(%rip), %rsi     # 0x56ea1
movl $0x101, %edx            # imm = 0x101
leaq 0x48cc8(%rip), %rcx     # 0x57250
callq 0x21a0
cmpl $0x1, -0x18(%rbp)
jne 0xe5c6
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
orq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
jmp 0xe671
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xe615
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movslq -0x64(%rbp), %rdx
addq %rdx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movslq -0x64(%rbp), %rsi
addq %rsi, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xe5cd
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x38(%rbp), %rax
movslq -0x18(%rbp), %rcx
addq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x5f90
movq -0x38(%rbp), %rdx
shlq $0x20, %rdx
movslq -0x18(%rbp), %rax
orq %rax, %rdx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movslq -0x18(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x1, -0x18(%rbp)
jmp 0xe68b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xe68d
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xe4af
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl %ecx, %eax
jne 0xe6bb
jmp 0xe6da
leaq 0x48bb2(%rip), %rdi     # 0x57274
leaq 0x487d8(%rip), %rsi     # 0x56ea1
movl $0x111, %edx            # imm = 0x111
leaq 0x48b7b(%rip), %rcx     # 0x57250
callq 0x21a0
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x1a8c0
movq -0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x50(%rbp), %rax
movq $0x0, (%rax)
movq -0x50(%rbp), %rax
movq $0x0, 0x10(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)