// File: JainamS1996[P]Btree_DataStructure/final.cpp
// Function: search(Node*, double, std::basic_ofstream<char, std::char_traits<char>>&)
void search(Node *curNode,double k,ofstream& o_file) {
    if (!curNode->isleaf) {
        int flag = 0;
        for (int i = 0; i<curNode->keys.size();i++) {
            if (k < curNode->keys.at(i)) {
                flag = 1;
                search(curNode->children.at(i),k,o_file);
                break;
            }
        }
        if (flag == 0) {
            search(curNode->children.at(curNode->children.size()-1),k,o_file);  
        }
    }
    else {
        //cout<<"I am a sahab tbh"<<curNode->record.size()<<endl;
        int found = 0;
        for (int i = 0 ;i<curNode->record.size();i++) {
            if (k == get<0>(curNode->record.at(i))) {
				o_file << get<1>(curNode->record.at(i));

				if(i+1 < curNode->record.size() && k != get<0>(curNode->record.at(i+1))){
					// single value in key
					 o_file << endl;
				}
				else if(i+1 < curNode->record.size() && k == get<0>(curNode->record.at(i+1))){
					// multiple values with same key
					while(i+1 < curNode->record.size() && k == get<0>(curNode->record.at(i+1))){
	                	o_file << "," << get<1>(curNode->record.at(++i));
					}
					o_file << endl;
				}				

    	        found = 1;
                break;
            }
        }
        if (found == 0)
        {
            o_file << "Null" <<endl;
        }            
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x88(%rax)
jne 0x3672
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movslq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
callq 0x53c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x362d
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
movslq -0x20(%rbp), %rsi
callq 0x53e0
movsd -0x38(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x361d
movl $0x1, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
movslq -0x20(%rbp), %rsi
callq 0x5550
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rsi
callq 0x3570
jmp 0x362d
jmp 0x361f
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x35a7
cmpl $0x0, -0x1c(%rbp)
jne 0x366d
movq -0x8(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x5530
movq -0x40(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x5550
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
movq -0x18(%rbp), %rsi
callq 0x3570
jmp 0x38fc
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x38d5
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x28(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd -0x50(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x38c5
jp 0x38c5
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x28(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x57e0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
callq 0x2180
movl -0x28(%rbp), %eax
addl $0x1, %eax
cltq
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
jae 0x377b
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd -0x68(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x3766
jp 0x3766
jmp 0x377b
movq -0x18(%rbp), %rdi
movq 0xf84f(%rip), %rsi      # 0x12fc0
callq 0x21e0
jmp 0x38bc
movl -0x28(%rbp), %eax
addl $0x1, %eax
cltq
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0x38ba
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd -0x78(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x38ba
jp 0x38ba
jmp 0x37e3
movl -0x28(%rbp), %eax
addl $0x1, %eax
cltq
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq -0x88(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x79(%rbp)
jae 0x3855
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd -0x90(%rbp), %xmm0
ucomisd (%rax), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x385e
jmp 0x38aa
movq -0x18(%rbp), %rdi
leaq 0x979b(%rip), %rsi      # 0xd004
callq 0x21b0
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movslq %eax, %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x57e0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x2180
jmp 0x37e3
movq -0x18(%rbp), %rdi
movq 0xf70b(%rip), %rsi      # 0x12fc0
callq 0x21e0
jmp 0x38bc
movl $0x1, -0x24(%rbp)
jmp 0x38d5
jmp 0x38c7
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3680
cmpl $0x0, -0x24(%rbp)
jne 0x38fa
movq -0x18(%rbp), %rdi
leaq 0x9720(%rip), %rsi      # 0xd006
callq 0x21b0
movq %rax, %rdi
movq 0xf6cb(%rip), %rsi      # 0x12fc0
callq 0x21e0
jmp 0x38fc
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)