// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x0, 0x88(%rdi)
jne 0x30d8
movq 0x58(%r14), %rax
movq 0x60(%r14), %rdx
subq %rax, %rdx
je 0x3087
sarq $0x3, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %ecx, %ecx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x30ac
incq %rsi
addq $-0x8, %rcx
cmpq %rsi, %rdx
jne 0x3070
movq 0x70(%r14), %rax
movq 0x78(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
leaq -0x1(%rdx), %rsi
cmpq %rax, %rcx
je 0x3257
leaq (%rax,%rsi,8), %rax
jmp 0x30c7
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x3257
subq %rcx, %rax
movq (%rax), %r14
cmpb $0x0, 0x88(%r14)
je 0x3053
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
je 0x312f
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r13, %rdx
xorl %r12d, %r12d
cmpq $0x1, %rdx
movl $0x0, %ecx
sbbq %rdx, %rcx
movl $0x1, %r15d
movsd 0x20(%rax,%r12), %xmm1
ucomisd %xmm0, %xmm1
jne 0x311b
jnp 0x3178
addq $0x28, %r12
leaq (%rcx,%r15), %rdx
incq %rdx
incq %r15
cmpq $0x1, %rdx
jne 0x310c
leaq 0x2eec(%rip), %rsi      # 0x6022
movl $0x4, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2100
movsd %xmm0, -0x30(%rbp)
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq %rbx, %rdi
callq 0x21d0
movl %r15d, %ecx
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rcx, %rdx
jbe 0x3248
leaq (%rcx,%rcx,4), %rcx
movsd 0x20(%rax,%rcx,8), %xmm0
movsd -0x30(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jne 0x3143
jp 0x3143
jmp 0x3230
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x2e47(%rip), %rsi      # 0x6020
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x3265
movq 0x28(%rax,%r12), %rsi
movq 0x30(%rax,%r12), %rdx
movq %rbx, %rdi
callq 0x21d0
incq %r15
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r13, %rcx
addq $0x28, %r12
cmpq %r15, %rcx
movsd -0x30(%rbp), %xmm1
jbe 0x3143
movsd 0x48(%rax,%r12), %xmm0
ucomisd %xmm1, %xmm0
jne 0x3143
jnp 0x31ca
jmp 0x3143
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2e17(%rip), %rdi      # 0x6075
xorl %eax, %eax
callq 0x2250
leaq 0x2e09(%rip), %rdi      # 0x6075
movq %r15, %rsi
jmp 0x325e