// File: /workspace/github_cpp_makefile_star2_O2/JainamS1996[P]Btree_DataStructure/final.cpp
// Function: search(Node*, double, double, std::basic_ofstream<char, std::char_traits<char>>&)
void search(Node *curNode,double k,double l,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,l,o_file);
                break;
            }
        }
        if (flag == 0) {
            search(curNode->children.at(curNode->children.size()-1),k,l,o_file);  
        }
    }
    else {
        int x = 0;

        for (int i = 0 ;i<curNode->record.size();i++) {
            if (k <= get<0>(curNode->record.at(i))) {
                x = i;
                break;
            }
        }  
  
        int found = 0;
        int flag = 0;

        while (flag == 0 && curNode != NULL) {
            for (int i = x ; i < curNode->record.size(); i++) {
                if (get<0>(curNode->record.at(i)) >= k && get<0>(curNode->record.at(i)) <= l) {
					if(found == 0)                    
						o_file << "(" <<get<0>(curNode->record.at(i))<<","<< get<1>(curNode->record.at(i))<< ")";
					else 
						o_file << ",(" <<get<0>(curNode->record.at(i))<<","<< get<1>(curNode->record.at(i))<< ")";
                    found = 1;
                }
                else {
                    flag = 1;
                    break;
                }    
            }

            curNode = curNode->next;
            x = 0;
        }
       
	    if (found == 0) {
            o_file << "Null" <<endl;
        }
		else o_file << endl;
    }
                   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movsd %xmm1, -0x38(%rbp)
movsd %xmm0, -0x30(%rbp)
movq %rdi, %r14
pushq $-0x1
popq %r13
cmpb $0x0, 0x88(%r14)
jne 0x2e26
leaq 0x58(%r14), %r12
movq %r13, %r15
incq %r15
movq 0x60(%r14), %rax
subq 0x58(%r14), %rax
sarq $0x3, %rax
cmpq %r15, %rax
jbe 0x2e09
movq %r12, %rdi
movq %r15, %rsi
callq 0x38a6
movsd (%rax), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x2dd3
addq $0x70, %r14
movq %r14, %rdi
movq %r15, %rsi
jmp 0x2e1c
leaq 0x70(%r14), %rdi
movq 0x78(%r14), %rsi
subq 0x70(%r14), %rsi
sarq $0x3, %rsi
decq %rsi
callq 0x38d2
movq (%rax), %r14
jmp 0x2dc2
leaq 0x40(%r14), %r12
xorl %r15d, %r15d
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r15, %rax
jbe 0x2e5e
movq %r12, %rdi
movq %r15, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x30(%rbp), %xmm0
jae 0x2e61
incq %r15
jmp 0x2e2d
xorl %r15d, %r15d
movl %r15d, %r13d
xorl %r12d, %r12d
xorl %eax, %eax
testl %eax, %eax
jne 0x2f59
testq %r14, %r14
je 0x2f59
leaq 0x40(%r14), %r15
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r13, %rax
jbe 0x2f4b
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
ucomisd -0x30(%rbp), %xmm0
jb 0x2f46
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd -0x38(%rbp), %xmm0
ucomisd 0x20(%rax), %xmm0
jb 0x2f46
testl %r12d, %r12d
leaq 0x3154(%rip), %rsi      # 0x6027
leaq 0x314e(%rip), %rax      # 0x6028
cmoveq %rax, %rsi
movq %rbx, %rdi
callq 0x2180
movq %rax, %r12
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movsd 0x20(%rax), %xmm0
movq %r12, %rdi
callq 0x2260
movq %rax, %rdi
leaq 0x3115(%rip), %rsi      # 0x6020
callq 0x2180
movq %rax, %r12
movq %r15, %rdi
movq %r13, %rsi
callq 0x3830
movq %r12, %rdi
movq %rax, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x3160(%rip), %rsi      # 0x6093
callq 0x2180
incq %r13
pushq $0x1
popq %rax
movl %eax, %r12d
jmp 0x2e7e
pushq $0x1
popq %rax
jmp 0x2f4d
xorl %eax, %eax
movq 0x30(%r14), %r14
xorl %r13d, %r13d
jmp 0x2e69
testl %r12d, %r12d
jne 0x2f70
leaq 0x30bd(%rip), %rsi      # 0x6022
movq %rbx, %rdi
callq 0x2180
movq %rax, %rbx
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0