// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/index.c
// Function: mg_idx_cal_quantile
void mg_idx_cal_quantile(const mg_idx_t *gi, int32_t m, float f[], int32_t q[])
{
	int32_t i;
	uint64_t n = 0;
	khint_t *a, k;
	for (i = 0; i < 1<<gi->b; ++i)
		if (gi->B[i].h) n += kh_size((idxhash_t*)gi->B[i].h);
	a = (uint32_t*)malloc(n * 4);
	for (i = 0, n = 0; i < 1<<gi->b; ++i) {
		idxhash_t *h = (idxhash_t*)gi->B[i].h;
		if (h == 0) continue;
		for (k = 0; k < kh_end(h); ++k) {
			if (!kh_exist(h, k)) continue;
			a[n++] = kh_key(h, k)&1? 1 : (uint32_t)kh_val(h, k);
		}
	}
	for (i = 0; i < m; ++i)
		q[i] = ks_ksmall_uint32_t(n, a, (size_t)((1.0 - (double)f[i]) * n));
	free(a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x20736
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x28(%rax)
je 0x20729
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
movl 0x4(%rax), %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x2072b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x206d6
movq -0x30(%rbp), %rdi
shlq $0x2, %rdi
callq 0x2280
movq %rax, -0x38(%rbp)
movl $0x0, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x10(%rcx), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x20875
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x20798
jmp 0x20867
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x207c2
movq -0x48(%rbp), %rax
movl (%rax), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x50(%rbp)
jmp 0x207c9
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x207c9
movl -0x4c(%rbp), %eax
movl -0x50(%rbp), %ecx
cmpl %ecx, %eax
jae 0x20865
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x3c(%rbp), %ecx
shrl $0x5, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl -0x3c(%rbp), %ecx
andl $0x1f, %ecx
shrl %cl, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x207fc
jmp 0x20857
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x20825
movl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x2083e
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x3c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %edx
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x30(%rbp)
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2079f
jmp 0x20867
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x20756
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2091e
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x1c76f(%rip), %xmm0    # 0x3d018
subsd %xmm1, %xmm0
movq %rdi, %xmm1
movaps 0x1c777(%rip), %xmm2    # 0x3d030
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1c77b(%rip), %xmm2    # 0x3d040
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rcx
sarq $0x3f, %rcx
movsd 0x1c731(%rip), %xmm1    # 0x3d020
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rcx, %rax
orq %rax, %rdx
callq 0x16140
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2087c
movq -0x38(%rbp), %rdi
callq 0x2040
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)