// File: /workspace/github_cpp_makefile_star2_O1/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(%r14)
jne 0x312f
movq 0x58(%r14), %rax
movq 0x60(%r14), %rcx
subq %rax, %rcx
je 0x30ef
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x3111
incq %rsi
cmpq %rsi, %rcx
jne 0x30dc
movq 0x70(%r14), %rax
movq 0x78(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rax, %rcx
je 0x32df
movq -0x8(%rax,%rdx,8), %r14
jmp 0x30b7
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x32e3
movq (%rax,%rsi,8), %r14
jmp 0x30b7
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
je 0x3186
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 0x3172
jnp 0x31cf
addq $0x28, %r12
leaq (%rcx,%r15), %rdx
incq %rdx
incq %r15
cmpq $0x1, %rdx
jne 0x3163
leaq 0x3e95(%rip), %rsi      # 0x7022
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 0x32d0
leaq (%rcx,%rcx,4), %rsi
movsd 0x20(%rax,%rsi,8), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x319a
jp 0x319a
cmpq %rcx, %rdx
jbe 0x32d0
movsd 0x20(%rax,%rsi,8), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x32d0
jp 0x32d0
movl %r15d, %ecx
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %rcx, %rdx
jbe 0x319a
movsd 0x48(%rax,%r12), %xmm0
ucomisd -0x30(%rbp), %xmm0
jne 0x319a
jp 0x319a
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x3da3(%rip), %rsi      # 0x7020
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r13, %rdx
cmpq %r15, %rdx
jbe 0x32f1
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
ja 0x3256
jmp 0x319a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x1(%rdx), %rsi
leaq 0x3d8b(%rip), %rdi      # 0x7075
xorl %eax, %eax
callq 0x2250
leaq 0x3d7d(%rip), %rdi      # 0x7075
movq %r15, %rsi
jmp 0x32ea