// File: /workspace/github_cpp_makefile_star2_O1/ashlall[P]StreamStats/Test/GK_test.cpp
// Function: test_reverseQuantile(double, double)
void test_reverseQuantile(double stream_size, double sample_size)
{
	GK m(sample_size);
	GK n(sample_size);
	double epsilon = log(stream_size)/sample_size;
	//cout << "e: " << error<<endl;
	bool check1, check2;
	double hold1, hold2;

	for(double i = 0; i<=stream_size; i++)
	{
		m.insert(i);
		n.insert(stream_size-i);
	}

	//If the sample_size is large enough, then the reverse quantile lookup should return the EXACT index. Here, we transformed into probability.
	if (sample_size >= stream_size*3)
	{
		for(double i = 0; i<=stream_size; i++)
		{ 
			hold1 = ((m.reverseQuantile(i, stream_size))/stream_size);
			check1 = (hold1 == i/stream_size);
			assert(check1==true);

			hold2 = ((n.reverseQuantile(i, stream_size))/stream_size);
			check2 = (hold2 == i/stream_size);
			assert(check2==true);
		}
	}

	//Theoratically, the reverse quantile lookup will generate 3epsilon.

	else
	{
		for(double i = 0; i<=stream_size; i++)
		{ 
			hold1 = ((m.reverseQuantile(i, stream_size))/stream_size);
			check1 = ((hold1 >= i/stream_size - 3*epsilon) &&  (hold1 <= i/stream_size + 3*epsilon));
			assert(check1==true);

			hold2 = ((n.reverseQuantile(i, stream_size))/stream_size);
			check2 = ((hold2 >= i/stream_size - 3*epsilon) &&  (hold2 <= i/stream_size + 3*epsilon));
			assert(check2==true);
		}			
	}		
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movsd %xmm1, -0x40(%rbp)
cvttsd2si %xmm1, %r14d
movsd %xmm0, -0x30(%rbp)
leaq 0x2b38(%rip), %r12      # 0x4d80
movq %r12, -0xb8(%rbp)
movl $0x0, -0xa0(%rbp)
movq $0x0, -0x98(%rbp)
movl %r14d, -0xb0(%rbp)
movslq %r14d, %r13
leaq (,%r13,8), %rax
testl %r13d, %r13d
movq $-0x1, %rbx
cmovnsq %rax, %rbx
movq %rbx, %rdi
callq 0x1030
movq %rax, -0xa8(%rbp)
movl %r14d, %r15d
testl %r13d, %r13d
jle 0x22b4
xorl %eax, %eax
movq -0xa8(%rbp), %rcx
movq $0x0, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0x229d
xorl %eax, %eax
movq %rax, -0x90(%rbp)
movq %r12, -0x88(%rbp)
movl $0x0, -0x70(%rbp)
movq %rax, -0x68(%rbp)
movl %r14d, -0x80(%rbp)
movq %rbx, %rdi
callq 0x1030
movq %rax, -0x78(%rbp)
testl %r14d, %r14d
jle 0x22fa
xorl %eax, %eax
movq -0x78(%rbp), %rcx
movq $0x0, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0x22e6
movq $0x0, -0x60(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x10a0
movsd %xmm0, -0x48(%rbp)
xorpd %xmm0, %xmm0
movsd -0x30(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x2369
leaq -0xb8(%rbp), %rbx
leaq -0x88(%rbp), %r14
movq %rbx, %rdi
movsd %xmm0, -0x38(%rbp)
callq 0x13ae
movsd -0x30(%rbp), %xmm1
movapd %xmm1, %xmm0
subsd -0x38(%rbp), %xmm0
movq %r14, %rdi
callq 0x13ae
movsd -0x30(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
addsd 0xcad(%rip), %xmm0      # 0x3010
ucomisd %xmm0, %xmm1
jae 0x232e
movsd 0xccf(%rip), %xmm0      # 0x3040
movsd -0x30(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd -0x40(%rbp), %xmm2
ucomisd %xmm0, %xmm2
jae 0x2478
movapd %xmm2, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jb 0x250a
cvttsd2si -0x30(%rbp), %ebx
movsd -0x48(%rbp), %xmm1
divsd %xmm0, %xmm1
leaq -0xb8(%rbp), %r14
movsd 0xc90(%rip), %xmm0      # 0x3048
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
mulsd 0xc77(%rip), %xmm1      # 0x3040
movsd %xmm1, -0x48(%rbp)
leaq -0x88(%rbp), %r15
movsd %xmm2, -0x38(%rbp)
movq %r14, %rdi
movapd %xmm2, %xmm0
movl %ebx, %esi
callq 0x125c
movsd -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
movsd -0x50(%rbp), %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, -0x40(%rbp)
ucomisd %xmm1, %xmm0
jb 0x2572
addsd -0x48(%rbp), %xmm2
ucomisd %xmm0, %xmm2
jb 0x2572
movsd %xmm2, -0x58(%rbp)
movq %r15, %rdi
movapd %xmm3, %xmm0
movl %ebx, %esi
callq 0x125c
movsd -0x38(%rbp), %xmm2
divsd -0x30(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jb 0x2534
movsd -0x58(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x2534
addsd 0xbac(%rip), %xmm2      # 0x3010
movsd -0x30(%rbp), %xmm0
ucomisd %xmm2, %xmm0
jae 0x23d5
jmp 0x250a
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x250a
cvttsd2si -0x30(%rbp), %ebx
leaq -0xb8(%rbp), %r14
leaq -0x88(%rbp), %r15
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
movl %ebx, %esi
callq 0x125c
movsd -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, -0x40(%rbp)
ucomisd %xmm2, %xmm0
jne 0x2591
jp 0x2591
movapd %xmm3, %xmm0
movq %r15, %rdi
movl %ebx, %esi
callq 0x125c
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
ucomisd -0x40(%rbp), %xmm0
jne 0x2553
jp 0x2553
movapd %xmm2, %xmm0
addsd 0xb0c(%rip), %xmm0      # 0x3010
ucomisd %xmm0, %xmm1
jae 0x2499
leaq -0x88(%rbp), %rdi
callq 0x135c
leaq -0xb8(%rbp), %rdi
callq 0x135c
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc66(%rip), %rdi       # 0x31a1
leaq 0xb69(%rip), %rsi       # 0x30ab
leaq 0xc2e(%rip), %rcx       # 0x3177
movl $0xd4, %edx
callq 0x1080
leaq 0xc47(%rip), %rdi       # 0x31a1
leaq 0xb4a(%rip), %rsi       # 0x30ab
leaq 0xc0f(%rip), %rcx       # 0x3177
movl $0xc4, %edx
callq 0x1080
leaq 0xbf1(%rip), %rdi       # 0x316a
leaq 0xb2b(%rip), %rsi       # 0x30ab
leaq 0xbf0(%rip), %rcx       # 0x3177
movl $0xd0, %edx
callq 0x1080
leaq 0xbd2(%rip), %rdi       # 0x316a
leaq 0xb0c(%rip), %rsi       # 0x30ab
leaq 0xbd1(%rip), %rcx       # 0x3177
movl $0xc0, %edx
callq 0x1080
movq %rax, %rbx
jmp 0x25c8
jmp 0x25b9
jmp 0x25b9
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x135c
leaq -0xb8(%rbp), %rdi
callq 0x135c
movq %rbx, %rdi
callq 0x1110