// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movsd %xmm1, -0x40(%rbp)
movq %rdi, %r14
cmpb $0x0, 0x88(%rdi)
jne 0x331f
movq 0x58(%r14), %rax
movq 0x60(%r14), %rdx
subq %rax, %rdx
je 0x32ce
sarq $0x3, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %ecx, %ecx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x32f3
incq %rsi
addq $-0x8, %rcx
cmpq %rsi, %rdx
jne 0x32b7
movq 0x70(%r14), %rax
movq 0x78(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
leaq -0x1(%rdx), %rsi
cmpq %rax, %rcx
je 0x3510
leaq (%rax,%rsi,8), %rax
jmp 0x330e
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x3510
subq %rcx, %rax
movq (%rax), %r14
cmpb $0x0, 0x88(%r14)
je 0x329a
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rdx
xorl %eax, %eax
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
subq %rcx, %rdx
je 0x3374
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
addq $0x20, %rcx
xorl %esi, %esi
movsd (%rcx), %xmm1
ucomisd %xmm0, %xmm1
jae 0x3366
incq %rsi
addq $0x28, %rcx
cmpq %rsi, %rdx
jne 0x334e
xorl %esi, %esi
testq %r14, %r14
je 0x34ba
movslq %esi, %r15
jmp 0x3377
xorl %r15d, %r15d
movq %r13, -0x38(%rbp)
movsd %xmm0, -0x30(%rbp)
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r15, %rdx
jbe 0x34a3
leaq (,%r15,8), %rdx
leaq (%rdx,%rdx,4), %rbx
movsd 0x20(%rcx,%rbx), %xmm2
ucomisd %xmm0, %xmm2
jb 0x34b6
movsd -0x40(%rbp), %xmm1
ucomisd %xmm2, %xmm1
jb 0x34b6
testl %eax, %eax
je 0x33dc
movl $0x2, %edx
movq %r13, %rdi
leaq 0x2c4d(%rip), %rsi      # 0x6027
jmp 0x33eb
movl $0x1, %edx
movq %r13, %rdi
leaq 0x2c3d(%rip), %rsi      # 0x6028
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r15, %rdx
jbe 0x3504
movsd 0x20(%rax,%rbx), %xmm0
movq %r13, %rdi
callq 0x2280
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2bf4(%rip), %rsi      # 0x6020
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r15, %rdx
jbe 0x3504
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
movq %r13, %rdi
callq 0x21d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2c50(%rip), %rsi      # 0x60bd
callq 0x21d0
incq %r15
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
addq $0x28, %rbx
movl $0x1, %eax
cmpq %r15, %rdx
movq -0x38(%rbp), %r13
movsd -0x30(%rbp), %xmm0
ja 0x33a8
movq 0x30(%r14), %r14
movl $0x0, %r15d
testq %r14, %r14
jne 0x3380
testl %eax, %eax
jne 0x34ce
leaq 0x2b61(%rip), %rsi      # 0x6022
movl $0x4, %edx
movq %r13, %rdi
callq 0x21d0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2100
leaq 0x2b6a(%rip), %rdi      # 0x6075
movq %r15, %rsi
jmp 0x3517
leaq 0x2b5e(%rip), %rdi      # 0x6075
xorl %eax, %eax
callq 0x2250