// File: BU-DiSC[P]BF-Shared-Hashing/db.cpp
// Function: db::Get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool*)
string db::Get( string key, bool * result )
{
	std::chrono::time_point<std::chrono::high_resolution_clock>  total_end;
	std::chrono::time_point<std::chrono::high_resolution_clock>  total_start = high_resolution_clock::now();

	string value;
	BFHash bfHash(key);
	//for ( int i=0 ; i<num_levels ; i++ ){
	int i = 0;

	while(true){

		value = GetLevel( i, bfHash, key, result );
		if ( *result == true ){
			num_lookups++;
			BFHash::reset = true;
 			total_end = high_resolution_clock::now();
			total_duration += duration_cast<microseconds>(total_end - total_start);
			return value;
		}
		i++;
		if(i >= num_levels){
			break;
		}

	}
	*result = false;
	BFHash::reset = true;

	num_lookups++;
 	total_end = high_resolution_clock::now();
	total_duration += duration_cast<microseconds>(total_end - total_start);
	
	return "";
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdx, 0x40(%rsp)
movq %rdi, 0x28(%rsp)
movq %rdi, %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0x130(%rsp)
movq %rsi, 0x128(%rsp)
movq %rdx, 0x120(%rsp)
movq %rcx, 0x118(%rsp)
movq 0x128(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x11e40
callq 0x60b0
movq %rax, 0x108(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x6700
movq 0x40(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x11ba0
jmp 0xe221
movl $0x0, 0xb8(%rsp)
jmp 0xe22e
movq 0x40(%rsp), %r8
movq 0x38(%rsp), %rsi
movl 0xb8(%rsp), %edx
movq 0x118(%rsp), %r9
leaq 0x98(%rsp), %rdi
leaq 0xc8(%rsp), %rcx
callq 0x11e70
jmp 0xe25e
leaq 0xe8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x65f0
leaq 0x98(%rsp), %rdi
callq 0x6340
movq 0x118(%rsp), %rax
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0xe399
movq 0x38(%rsp), %rax
movl 0x1e0(%rax), %ecx
incl %ecx
movl %ecx, 0x1e0(%rax)
leaq 0x72226(%rip), %rax     # 0x804d8
movb $0x1, (%rax)
callq 0x60b0
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x7a60
movq %rax, 0x20(%rsp)
jmp 0xe2ee
movq 0x20(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x7a30
movq %rax, 0x18(%rsp)
jmp 0xe309
movq 0x18(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x8c(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x7ab0
jmp 0xe32d
movq 0x38(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq 0x8c(%rsp), %rsi
callq 0x7af0
jmp 0xe348
movq 0x28(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x6310
movl $0x1, 0x74(%rsp)
jmp 0xe4c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
jmp 0xe4fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
jmp 0xe4ee
movq 0x38(%rsp), %rcx
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
movl 0xb8(%rsp), %eax
cmpl 0xdc(%rcx), %eax
jl 0xe3c0
jmp 0xe3c5
jmp 0xe22c
movq 0x38(%rsp), %rax
movq 0x118(%rsp), %rcx
movb $0x0, (%rcx)
leaq 0x720fc(%rip), %rcx     # 0x804d8
movb $0x1, (%rcx)
movl 0x1e0(%rax), %ecx
incl %ecx
movl %ecx, 0x1e0(%rax)
callq 0x60b0
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x110(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x7a60
movq %rax, 0x10(%rsp)
jmp 0xe420
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7a30
movq %rax, 0x8(%rsp)
jmp 0xe43b
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x64(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x7ab0
jmp 0xe456
movq 0x38(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq 0x64(%rsp), %rsi
callq 0x7af0
jmp 0xe46e
leaq 0x4f(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x6860
movq 0x28(%rsp), %rdi
movq (%rsp), %rdx
leaq 0x55f3e(%rip), %rsi     # 0x643ca
callq 0x66f0
jmp 0xe493
leaq 0x4f(%rsp), %rdi
callq 0x6570
movl $0x1, 0x74(%rsp)
jmp 0xe4c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0x4f(%rsp), %rdi
callq 0x6570
jmp 0xe4ee
leaq 0xc8(%rsp), %rdi
callq 0x11c90
leaq 0xe8(%rsp), %rdi
callq 0x6340
movq 0x30(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
retq
leaq 0xc8(%rsp), %rdi
callq 0x11c90
leaq 0xe8(%rsp), %rdi
callq 0x6340
movq 0xc0(%rsp), %rdi
callq 0x6850
nopw %cs:(%rax,%rax)