// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
subq $0x98, %rsp
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x30(%rbp)
cvttsd2si %xmm1, %r14d
leaq 0x2b88(%rip), %r15      # 0x4d80
movq %r15, -0xa8(%rbp)
movl $0x0, -0x90(%rbp)
movq $0x0, -0x88(%rbp)
movl %r14d, -0xa0(%rbp)
leaq (,%r14,8), %rax
testl %r14d, %r14d
movq $-0x1, %rbx
cmovnsq %rax, %rbx
movq %rbx, %rdi
callq 0x1030
movq %rax, -0x98(%rbp)
testl %r14d, %r14d
jle 0x2257
xorl %ecx, %ecx
movq $0x0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0x2247
xorl %eax, %eax
movq %rax, -0x80(%rbp)
movq %r15, -0x78(%rbp)
movl $0x0, -0x60(%rbp)
movq %rax, -0x58(%rbp)
movl %r14d, -0x70(%rbp)
movq %rbx, %rdi
callq 0x1030
movq %rax, -0x68(%rbp)
testl %r14d, %r14d
jle 0x2293
xorl %ecx, %ecx
movq $0x0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r14
jne 0x2283
movq $0x0, -0x50(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x10a0
movsd %xmm0, -0x38(%rbp)
xorpd %xmm1, %xmm1
movsd -0x20(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x22dc
leaq -0x78(%rbp), %rdi
callq 0x1358
leaq -0xa8(%rbp), %rdi
callq 0x1358
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movsd -0x38(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0xa8(%rbp), %rbx
leaq -0x78(%rbp), %r14
movsd %xmm1, -0x28(%rbp)
movq %rbx, %rdi
movapd %xmm1, %xmm0
callq 0x13a6
movsd -0x20(%rbp), %xmm0
subsd -0x28(%rbp), %xmm0
movq %r14, %rdi
callq 0x13a6
movsd -0x20(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
addsd 0xce5(%rip), %xmm1      # 0x3010
ucomisd %xmm1, %xmm0
jae 0x22f6
movsd 0xd07(%rip), %xmm0      # 0x3040
movsd -0x20(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm2
ucomisd %xmm0, %xmm2
jae 0x2435
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jb 0x22b9
cvttsd2si -0x20(%rbp), %ebx
leaq -0xa8(%rbp), %r14
movsd 0xcd5(%rip), %xmm1      # 0x3048
movsd -0x38(%rbp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
mulsd 0xcb7(%rip), %xmm0      # 0x3040
movsd %xmm0, -0x38(%rbp)
leaq -0x78(%rbp), %r15
movsd %xmm2, -0x28(%rbp)
movq %r14, %rdi
movapd %xmm2, %xmm0
movl %ebx, %esi
callq 0x125c
movsd -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
movsd -0x40(%rbp), %xmm1
addsd %xmm2, %xmm1
movsd %xmm1, -0x30(%rbp)
ucomisd %xmm1, %xmm0
jb 0x2507
addsd -0x38(%rbp), %xmm2
ucomisd %xmm0, %xmm2
jb 0x2507
movsd %xmm2, -0x48(%rbp)
movq %r15, %rdi
movapd %xmm3, %xmm0
movl %ebx, %esi
callq 0x125c
movsd -0x28(%rbp), %xmm2
divsd -0x20(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jb 0x24c9
movsd -0x48(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x24c9
addsd 0xbef(%rip), %xmm2      # 0x3010
movsd -0x20(%rbp), %xmm0
ucomisd %xmm2, %xmm0
jae 0x2392
jmp 0x22b9
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jb 0x22b9
cvttsd2si -0x20(%rbp), %ebx
leaq -0xa8(%rbp), %r14
leaq -0x78(%rbp), %r15
movsd %xmm0, -0x28(%rbp)
movq %r14, %rdi
movl %ebx, %esi
callq 0x125c
movsd -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm3
movapd %xmm3, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, -0x30(%rbp)
ucomisd %xmm2, %xmm0
jne 0x2526
jp 0x2526
movapd %xmm3, %xmm0
movq %r15, %rdi
movl %ebx, %esi
callq 0x125c
movsd -0x28(%rbp), %xmm2
movsd -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x24e8
jp 0x24e8
movapd %xmm2, %xmm0
addsd 0xb52(%rip), %xmm0      # 0x3010
ucomisd %xmm0, %xmm1
jae 0x2453
jmp 0x22b9
leaq 0xcd1(%rip), %rdi       # 0x31a1
leaq 0xbd4(%rip), %rsi       # 0x30ab
leaq 0xc99(%rip), %rcx       # 0x3177
movl $0xd4, %edx
callq 0x1080
leaq 0xcb2(%rip), %rdi       # 0x31a1
leaq 0xbb5(%rip), %rsi       # 0x30ab
leaq 0xc7a(%rip), %rcx       # 0x3177
movl $0xc4, %edx
callq 0x1080
leaq 0xc5c(%rip), %rdi       # 0x316a
leaq 0xb96(%rip), %rsi       # 0x30ab
leaq 0xc5b(%rip), %rcx       # 0x3177
movl $0xd0, %edx
callq 0x1080
leaq 0xc3d(%rip), %rdi       # 0x316a
leaq 0xb77(%rip), %rsi       # 0x30ab
leaq 0xc3c(%rip), %rcx       # 0x3177
movl $0xc0, %edx
callq 0x1080
movq %rax, %rbx
jmp 0x255a
jmp 0x254e
jmp 0x254e
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x1358
leaq -0xa8(%rbp), %rdi
callq 0x1358
movq %rbx, %rdi
callq 0x1110