// File: /workspace/github_cpp_makefile_star2_O2/JainamS1996[P]Btree_DataStructure/final.cpp
// Function: insertNode(Node*, double, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void insertNode(Node *curNode, double k,string val) {
    if (curNode->isleaf) {
		//cout << "leaf root insert" << endl;
		
		curNode->record.push_back(make_tuple(k,val));
        sort(curNode->record.begin(),curNode->record.end());
		
        curNode->nNodes++;

        //for (int i = 0; i<curNode->record.size();i++) cout<<get<0>(curNode->record.at(i)) << " ";
		//cout << endl;

        if (curNode->record.size() > order-1) {
			//cout << "leaf split" << endl;			
            curNode->nNodes--;
            splitNode(curNode);
        }

		//cout << "leaf root had space" << endl;
    }
    else {
        int flag = 0;
        for (int i = 0; i<curNode->keys.size();i++) {
            if (k < curNode->keys.at(i)) {
                flag = 1;
                insertNode(curNode->children.at(i),k,val);
                break;
            }
        }
        if (flag == 0) {
            insertNode(curNode->children.at(curNode->children.size()-1),k,val);        
        }
        
        // sort(curNode->keys.begin(),curNode->keys.end());
        // if (curNode->keys.size()>order-1) {
        //     curNode->nNodes--;
        //     cout<<"Split karte hai bhai log";
        //     splitNode(curNode);
        
    }
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x70, %rsp
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x0, 0x88(%rdi)
movsd %xmm0, -0x28(%rbp)
je 0x2a60
leaq 0x40(%rbx), %r15
leaq -0x90(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x21f0
movsd -0x28(%rbp), %xmm0
movsd %xmm0, 0x20(%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4cbc
leaq -0x90(%rbp), %rdi
callq 0x20d0
movq 0x40(%rbx), %rdi
movq 0x48(%rbx), %rsi
callq 0x4daa
movl 0x20(%rbx), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x20(%rbx)
movq 0x48(%rbx), %rax
subq 0x40(%rbx), %rax
pushq $0x28
popq %rsi
cqto
idivq %rsi
movslq 0x6734(%rip), %rdx      # 0x9178
decq %rdx
cmpq %rdx, %rax
jbe 0x2b0c
movl %ecx, 0x20(%rbx)
movq %rbx, %rdi
callq 0x24ba
jmp 0x2b0c
leaq 0x58(%rbx), %r12
pushq $-0x1
popq %r15
incq %r15
movq 0x60(%rbx), %rax
subq 0x58(%rbx), %rax
sarq $0x3, %rax
cmpq %r15, %rax
jbe 0x2ac9
movq %r12, %rdi
movq %r15, %rsi
callq 0x38a6
movsd (%rax), %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x2a68
addq $0x70, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x38d2
movq (%rax), %rbx
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x21f0
movq %rbx, %rdi
movsd -0x28(%rbp), %xmm0
movq %r15, %rsi
callq 0x29b7
leaq -0x68(%rbp), %rdi
jmp 0x2b07
leaq 0x70(%rbx), %rdi
movq 0x78(%rbx), %rsi
subq 0x70(%rbx), %rsi
sarq $0x3, %rsi
decq %rsi
callq 0x38d2
movq (%rax), %rbx
leaq -0x48(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x21f0
movq %rbx, %rdi
movsd -0x28(%rbp), %xmm0
movq %r15, %rsi
callq 0x29b7
leaq -0x48(%rbp), %rdi
callq 0x20d0
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x2b35
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
jmp 0x2b35
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x22a0