// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movq %rsi, %r13
movsd %xmm0, -0x38(%rbp)
movq %rdi, %r14
pushq $-0x1
popq %rbx
cmpb $0x0, 0x88(%r14)
jne 0x2c55
leaq 0x58(%r14), %r12
movq %rbx, %r15
incq %r15
movq 0x60(%r14), %rax
subq 0x58(%r14), %rax
sarq $0x3, %rax
cmpq %r15, %rax
jbe 0x2c38
movq %r12, %rdi
movq %r15, %rsi
callq 0x38a6
movsd (%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0x2c02
addq $0x70, %r14
movq %r14, %rdi
movq %r15, %rsi
jmp 0x2c4b
leaq 0x70(%r14), %rdi
movq 0x78(%r14), %rsi
subq 0x70(%r14), %rsi
sarq $0x3, %rsi
decq %rsi
callq 0x38d2
movq (%rax), %r14
jmp 0x2bf1
movq %r13, -0x30(%rbp)
leaq 0x40(%r14), %r15
pushq $0x1
popq %r12
pushq $0x28
popq %rbx
leaq -0x1(%r12), %r13
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
idivq %rbx
cmpq %r13, %rax
jbe 0x2c99
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x2c94
jnp 0x2cae
incq %r12
jmp 0x2c64
leaq 0x3382(%rip), %rsi      # 0x6022
movq -0x30(%rbp), %rdi
callq 0x2180
movq %rax, %rdi
jmp 0x2cf7
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x2160
movl %r12d, %r13d
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
idivq %rbx
cmpq %r13, %rax
jbe 0x2d17
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x2cf3
jnp 0x2d0a
movq -0x30(%rbp), %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
idivq %rbx
cmpq %r13, %rax
jbe 0x2d8e
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jne 0x2d8e
jp 0x2d8e
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
idivq %rbx
cmpq %r12, %rax
jbe 0x2cf3
movq %r15, %rdi
movq %r12, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
movq -0x30(%rbp), %rdi
jne 0x2cf7
jp 0x2cf7
leaq 0x32b5(%rip), %rsi      # 0x6020
callq 0x2180
movq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x3830
movq %r13, %rdi
movq %rax, %rsi
callq 0x2160
incq %r12
jmp 0x2d35
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq