// File: /workspace/github_cpp_makefile_star2_O3/BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::GetLevel(int, BFHash&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, bool*)
inline string db::GetLevel( int i, BFHash & bfHash, string & key, bool * result )
{
	// Binary search for fense pointer
	//auto bs_start = high_resolution_clock::now();
	int bf_no = binary_search(key, fence_pointers[i]);
	//auto bs_end = high_resolution_clock::now();
	//bs_duration += duration_cast<microseconds>(bs_end - bs_start);	

 		//auto other_start = high_resolution_clock::now();

	// no matching sst
	if(bf_no < 0){
		*result = false;
 		//auto other_end = high_resolution_clock::now();
		//other_duration += duration_cast<microseconds>(other_end - other_start);
		return "";
	}
	//auto hash_start = high_resolution_clock::now();
	vector<uint64_t>* hash_digests = bfHash.getLevelwiseHashDigest(i);
	//auto hash_end = high_resolution_clock::now();
	//hash_duration += duration_cast<microseconds>(hash_end - hash_start);	


	bool bf_result = QueryFilter( i, bf_no, hash_digests, bf_prime[i][bf_no]);
		
	//cout << "QueryFilter result : " << i << " " << bf_no << " " << bf_result << endl;

	if( bf_result==false ){
		total_n++;
		//n_vec[i]++;
		*result = false;
 		//auto other_end = high_resolution_clock::now();
		//other_duration += duration_cast<microseconds>(other_end - other_start);
		return "";
	}

	int index_pos = GetFromIndex( i, bf_no, key );

	bool data_result = false;
	string data = GetFromData( i, bf_no, index_pos, key, &data_result );

	// false positive
	if (data_result == false){
		total_fp++;
		//fp_vec[i]++;
		total_n++;
		//n_vec[i]++;
	}else{

		total_p++;
	}
	

	*result = data_result;
 		//auto other_end = high_resolution_clock::now();
		//other_duration += duration_cast<microseconds>(other_end - other_start);
	return data;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x18(%rsp)
movq %r8, %r12
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, 0x20(%rsp)
leaq 0x78(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r8), %rsi
movq 0x8(%r8), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0x6c14
movl %ebp, 0x14(%rsp)
movslq %ebp, %rbp
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
shlq $0x3, %rdx
addq 0x140(%r15), %rdx
movq %r13, %rsi
callq 0xac76
movl %eax, %r13d
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0xd7a5
callq 0x53d0
testl %r13d, %r13d
js 0xd8b3
movq %r14, %rdi
movl %ebp, %esi
callq 0x116e6
movq 0x158(%r15), %rcx
movq (%rcx,%rbp,8), %rcx
movl %r13d, %edx
movq (%rcx,%rdx,8), %r8
movq %r15, %rdi
movl %ebp, %esi
movl %r13d, %edx
movq %rax, %rcx
callq 0xe696
testb %al, %al
je 0xd8ac
leaq 0x58(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x6c14
movq %r15, %rdi
movl 0x14(%rsp), %esi
movl %r13d, %edx
movq %r14, %rcx
callq 0xe796
movl %eax, %ebp
movq 0x48(%rsp), %rdi
cmpq %rbx, %rdi
je 0xd827
callq 0x53d0
leaq 0x13(%rsp), %rbx
movb $0x0, (%rbx)
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x6c14
movq %rbx, (%rsp)
movq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl 0x14(%rsp), %edx
movl %r13d, %ecx
movl %ebp, %r8d
movq %r14, %r9
callq 0xe886
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd886
callq 0x53d0
movb 0x13(%rsp), %al
movl $0x1a0, %ecx            # imm = 0x1A0
testb %al, %al
jne 0xd89f
incq 0x1a8(%r15)
movl $0x198, %ecx            # imm = 0x198
incq (%r15,%rcx)
movq 0x18(%rsp), %rcx
movb %al, (%rcx)
jmp 0xd8d9
incq 0x198(%r15)
movq 0x18(%rsp), %rax
movb $0x0, (%rax)
movq 0x20(%rsp), %rbx
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x1bb8b(%rip), %rdx     # 0x29459
movq %rbx, %rdi
movq %rdx, %rsi
callq 0xf95c
movq %rbx, %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
jne 0xd919
jmp 0xd91e
movq %rax, %r14
movq 0x48(%rsp), %rdi
jmp 0xd914
movq %rax, %r14
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0xd91e
callq 0x53d0
movq %r14, %rdi
callq 0x56b0