// File: 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
subq $0x110, %rsp            # imm = 0x110
movq %rsi, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x88(%rax)
je 0x32c9
movq -0xb0(%rbp), %rdx
movq -0x8(%rbp), %rax
addq $0x40, %rax
movq %rax, -0xc0(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
leaq -0x10(%rbp), %rsi
callq 0x5740
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x5710
jmp 0x322f
leaq -0x40(%rbp), %rdi
callq 0x5780
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x5090
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x5140
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x57a0
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movl 0xff31(%rip), %ecx      # 0x131b8
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jbe 0x32c4
movq -0x8(%rbp), %rax
movl 0x20(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x20(%rax)
movq -0x8(%rbp), %rdi
callq 0x25c0
jmp 0x32c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x5780
jmp 0x3488
jmp 0x347f
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movslq -0x68(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
callq 0x53c0
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq %rcx, %rax
jae 0x33d7
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
movslq -0x68(%rbp), %rsi
callq 0x53e0
movsd -0xd0(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x33c7
movl $0x1, -0x64(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
movslq -0x68(%rbp), %rsi
callq 0x5550
movq -0xb0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
leaq -0x88(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x20e0
movq -0xe8(%rbp), %rdi
movsd -0xe0(%rbp), %xmm0
movq -0xd8(%rbp), %rsi
callq 0x31c0
jmp 0x339c
leaq -0x88(%rbp), %rdi
callq 0x2140
jmp 0x33d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x2140
jmp 0x3488
jmp 0x33c9
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x32d7
cmpl $0x0, -0x64(%rbp)
jne 0x347d
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0x108(%rbp)
callq 0x5530
movq -0x108(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x5550
movq -0xb0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x100(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
leaq -0xa8(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x20e0
movq -0x100(%rbp), %rdi
movsd -0xf8(%rbp), %xmm0
movq -0xf0(%rbp), %rsi
callq 0x31c0
jmp 0x3455
leaq -0xa8(%rbp), %rdi
callq 0x2140
jmp 0x347d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x2140
jmp 0x3488
jmp 0x347f
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2300
nopw %cs:(%rax,%rax)