// File: /workspace/github_cpp_makefile_star2_O3/deepaktabraham[P]BPlus-Tree/src/tree.cpp
// Function: BPlusTree::Search(float)
void BPlusTree :: Search(float key)
{
	// check if tree is empty
	if(NULL == root)
	{
		outputFile<<"Null"<<endl;
	}

	// if it is a vaild search
	else
	{
		int i = 0;	
		
		// obtain the search path from root to leaf node and push it on to a stack
		stack<Node*>* path = new stack<Node*>;
		Search_Path(root, key, path);
		
		// search for the key in the leaf node, which is at the top of the stack
		vector<float> keys = path->top()->Get_Keys();
		vector< vector <string> > values = path->top()->Get_Values(); 
		vector<float>::iterator index = lower_bound(keys.begin(), keys.end(), key);

		// check if key is found
		if(key == keys[index - keys.begin()])
		{
			// display the values
			for(i = 0; i < values[index - keys.begin()].size() - 1; i++)
			{
				outputFile<<values[index - keys.begin()][i]<<",";
			}
			outputFile<<values[index - keys.begin()][i]<<endl;
		}

		// if key is not found
		else
		{
			outputFile<<"Null"<<endl;
		}

		delete(path);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r14
cmpq $0x0, 0x8(%rdi)
je 0x32c5
movss %xmm0, -0x30(%rbp)
movl $0x50, %edi
callq 0x2170
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movq %rax, %rdi
xorl %esi, %esi
callq 0x3cce
movq 0x8(%r14), %rsi
movq %r14, %rdi
movss -0x30(%rbp), %xmm0
movq %rbx, %rdx
callq 0x2d04
movq 0x30(%rbx), %rax
cmpq 0x38(%rbx), %rax
jne 0x3206
movq 0x48(%rbx), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x8(%rax), %rsi
leaq -0x50(%rbp), %rdi
callq 0x3ede
movq 0x30(%rbx), %rax
cmpq 0x38(%rbx), %rax
jne 0x322a
movq 0x48(%rbx), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x8(%rax), %rsi
movq (%rsi), %rax
leaq -0x68(%rbp), %rdi
callq *0x38(%rax)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq %rax, %r13
testq %rcx, %rcx
movss -0x30(%rbp), %xmm1
jle 0x3278
movq %rax, %r13
movq %rcx, %rdx
shrq %rdx
ucomiss (%r13,%rdx,4), %xmm1
jbe 0x3270
leaq 0x4(%r13,%rdx,4), %r13
notq %rdx
addq %rcx, %rdx
movq %rdx, %rcx
testq %rdx, %rdx
jg 0x325a
movss (%r13), %xmm0
ucomiss %xmm1, %xmm0
jne 0x3313
jp 0x3313
movq %rbx, -0x30(%rbp)
movq %r13, %rcx
subq %rax, %rcx
shrq $0x2, %rcx
movq -0x68(%rbp), %rdx
leaq (%rcx,%rcx,2), %rcx
movq (%rdx,%rcx,8), %rax
movq 0x8(%rdx,%rcx,8), %rcx
subq %rax, %rcx
cmpq $0x20, %rcx
movq %r14, -0x38(%rbp)
jne 0x3357
xorl %r14d, %r14d
jmp 0x33bd
leaq 0x10(%r14), %rbx
leaq 0x2e10(%rip), %rsi      # 0x60e0
movl $0x4, %edx
movq %rbx, %rdi
callq 0x2190
movq 0x10(%r14), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0
addq $0x10, %r14
leaq 0x2dc2(%rip), %rsi      # 0x60e0
movl $0x4, %edx
movq %r14, %rdi
callq 0x2190
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
jmp 0x3405
leaq 0x10(%r14), %r15
movl $0x8, %ebx
xorl %r14d, %r14d
leaq 0x2d7e(%rip), %r12      # 0x60e8
movq -0x8(%rax,%rbx), %rsi
movq (%rax,%rbx), %rdx
movq %r15, %rdi
callq 0x2190
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
incq %r14
movq %r13, %rax
subq -0x50(%rbp), %rax
shrq $0x2, %rax
movq -0x68(%rbp), %rcx
leaq (%rax,%rax,2), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
decq %rcx
addq $0x20, %rbx
cmpq %r14, %rcx
ja 0x336a
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
shlq $0x5, %r14
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
callq 0x2190
movq -0x30(%rbp), %rbx
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x3a4c
movq %rbx, %rdi
callq 0x2150
leaq -0x68(%rbp), %rdi
callq 0x39de
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x342c
callq 0x2150
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x3458
movq %rax, %r14
movq %rbx, %rdi
jmp 0x3461
jmp 0x344c
jmp 0x344c
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x39de
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3466
callq 0x2150
movq %r14, %rdi
callq 0x22a0