// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rsi, %r13
movapd %xmm1, -0x60(%rbp)
movq %rdi, %r14
cmpb $0x0, 0x88(%r14)
jne 0x3391
movq 0x58(%r14), %rax
movq 0x60(%r14), %rcx
subq %rax, %rcx
je 0x3351
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %esi, %esi
movsd (%rax,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
ja 0x3373
incq %rsi
cmpq %rsi, %rcx
jne 0x333e
movq 0x70(%r14), %rax
movq 0x78(%r14), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rax, %rcx
je 0x35b2
movq -0x8(%rax,%rdx,8), %r14
jmp 0x3319
movq 0x70(%r14), %rax
movq 0x78(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x35b6
movq (%rax,%rsi,8), %r14
jmp 0x3319
movq 0x40(%r14), %rax
movq 0x48(%r14), %rcx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
subq %rax, %rcx
je 0x33db
sarq $0x3, %rcx
imulq %rsi, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x20, %rax
xorl %edx, %edx
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
jae 0x33d6
incq %rdx
addq $0x28, %rax
cmpq %rdx, %rcx
jne 0x33be
xorl %edx, %edx
movslq %edx, %r15
jmp 0x33de
xorl %r15d, %r15d
testq %r14, %r14
je 0x3557
xorl %eax, %eax
movq %r13, -0x38(%rbp)
movapd %xmm0, -0x50(%rbp)
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %rsi, %rdx
cmpq %r15, %rdx
jbe 0x3535
leaq (,%r15,8), %rdx
leaq (%rdx,%rdx,4), %rbx
movsd 0x20(%rcx,%rbx), %xmm2
movapd %xmm0, %xmm1
cmplepd %xmm2, %xmm1
cmplepd -0x60(%rbp), %xmm2
andpd %xmm1, %xmm2
movd %xmm2, %ecx
movl %ecx, -0x2c(%rbp)
testb $0x1, %cl
je 0x353a
testl %eax, %eax
je 0x3458
movl $0x2, %edx
movq %r13, %rdi
leaq 0x3bd1(%rip), %rsi      # 0x7027
jmp 0x3467
movl $0x1, %edx
movq %r13, %rdi
leaq 0x3bc1(%rip), %rsi      # 0x7028
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %r12 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r12, %rdx
cmpq %r15, %rdx
jbe 0x35a1
movsd 0x20(%rax,%rbx), %xmm0
movq %r13, %rdi
callq 0x2280
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3b6e(%rip), %rsi      # 0x7020
callq 0x21d0
movq 0x40(%r14), %rax
movq 0x48(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
cmpq %r15, %rdx
jbe 0x35a1
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
movq %r13, %rdi
callq 0x21d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x3bca(%rip), %rsi      # 0x70bd
callq 0x21d0
incq %r15
movq 0x40(%r14), %rcx
movq 0x48(%r14), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdx
addq $0x28, %rbx
movl $0x1, %eax
cmpq %r15, %rdx
movq -0x38(%rbp), %r13
movapd -0x50(%rbp), %xmm0
ja 0x341a
jmp 0x353a
movb $0x1, %cl
movl %ecx, -0x2c(%rbp)
testb $0x1, -0x2c(%rbp)
je 0x3553
movq 0x30(%r14), %r14
movl $0x0, %r15d
testq %r14, %r14
jne 0x33f2
testl %eax, %eax
jne 0x356b
leaq 0x3ac4(%rip), %rsi      # 0x7022
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 $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2100
leaq 0x3acd(%rip), %rdi      # 0x7075
movq %r15, %rsi
xorl %eax, %eax
callq 0x2250
leaq -0x1(%rdx), %rsi
leaq 0x3ab8(%rip), %rdi      # 0x7075
jmp 0x35ab