// File: /workspace/github_c_makefile_star2_O0/Tarsnap[P]kivaloo/liball/../lib/datastruct/hazenquantile.h
// Function: hazenquantile
static inline void
hazenquantile(size_t N, double x, size_t * i, double * r)
{
	double q;

	/* Sanity-check. */
	assert(N > 0);
	assert((0 <= x) && (x <= 1));

	/* Scale to [0, N]. */
	q = (double)(N) * x;

	/* In most cases, i is equal to q rounded to nearest, minus one. */
	*i = (size_t)(q + 0.5) - 1;

	/* In most cases, r is the fractional part of q + 0.5. */
	*r = (q + 0.5) - (double)(*i + 1);

	/* The endpoints need special treatment. */
	if (*i == (size_t)(-1)) {
		/* In the case q < 0.5, quantile = S_0. */
		*i = 0;
		*r = 0.0;
	} else if (*i == N - 1) {
		/* In the case q > N - 0.5, quantile = S_{N-1}. */
		*i = N - 1;
		*r = 0.0;
	}

	/* Sanity-check. */
	assert((double)*i + *r <= (double)(N-1));
	assert((0.0 <= *r) && (*r < 1.0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
jbe 0x21f2
jmp 0x2211
leaq 0x21f1(%rip), %rdi      # 0x43ea
leaq 0x21f0(%rip), %rsi      # 0x43f0
movl $0x25, %edx
leaq 0x2206(%rip), %rcx      # 0x4412
callq 0x10d0
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x2230
movsd 0x1de9(%rip), %xmm0     # 0x4010
ucomisd -0x10(%rbp), %xmm0
jb 0x2230
jmp 0x224f
leaq 0x2212(%rip), %rdi      # 0x4449
leaq 0x21b2(%rip), %rsi      # 0x43f0
movl $0x26, %edx
leaq 0x21c8(%rip), %rcx      # 0x4412
callq 0x10d0
movq -0x8(%rbp), %xmm0
movaps 0x1de5(%rip), %xmm3     # 0x4040
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x1de9(%rip), %xmm2     # 0x4050
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x10(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0x206f(%rip), %xmm1     # 0x4300
addsd %xmm1, %xmm0
movaps %xmm0, %xmm4
cvttsd2si %xmm4, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
movsd 0x1d74(%rip), %xmm4     # 0x4020
subsd %xmm4, %xmm0
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rax, %rcx
decq %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movsd -0x28(%rbp), %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movq (%rax), %rax
incq %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
cmpq $-0x1, (%rax)
jne 0x231e
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x234e
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x234c
movq -0x8(%rbp), %rcx
subq $0x1, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x234e
movq -0x18(%rbp), %rax
movq (%rax), %xmm1
movaps 0x1ce3(%rip), %xmm3     # 0x4040
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x1ce7(%rip), %xmm2     # 0x4050
subpd %xmm2, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
addsd %xmm0, %xmm1
movq -0x8(%rbp), %rax
decq %rax
movq %rax, %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x23ab
jmp 0x23ca
leaq 0x20ac(%rip), %rdi      # 0x445e
leaq 0x2037(%rip), %rsi      # 0x43f0
movl $0x3d, %edx
leaq 0x204d(%rip), %rcx      # 0x4412
callq 0x10d0
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x23ef
movq -0x20(%rbp), %rax
movsd 0x1c29(%rip), %xmm0     # 0x4010
ucomisd (%rax), %xmm0
jbe 0x23ef
jmp 0x240e
leaq 0x2089(%rip), %rdi      # 0x447f
leaq 0x1ff3(%rip), %rsi      # 0x43f0
movl $0x3e, %edx
leaq 0x2009(%rip), %rcx      # 0x4412
callq 0x10d0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)