// File: 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
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x8(%rbp), %rax
testb $0x1, 0x88(%rax)
jne 0x3a21
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
callq 0x53c0
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x39d7
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
movslq -0x28(%rbp), %rsi
callq 0x53e0
movsd -0x50(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x39c7
movl $0x1, -0x24(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
movslq -0x28(%rbp), %rsi
callq 0x5550
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x20(%rbp), %rsi
callq 0x3910
jmp 0x39d7
jmp 0x39c9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x394c
cmpl $0x0, -0x24(%rbp)
jne 0x3a1c
movq -0x8(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
callq 0x5530
movq -0x58(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x5550
movq (%rax), %rdi
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x20(%rbp), %rsi
callq 0x3910
jmp 0x3cdc
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movslq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0x3a97
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x30(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd -0x68(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3a8a
movl -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x3a97
jmp 0x3a8c
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3a2f
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x69(%rbp)
jne 0x3abb
cmpq $0x0, -0x8(%rbp)
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x3ac7
jmp 0x3ca3
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4f20
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x3c8b
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd (%rax), %xmm0
ucomisd -0x10(%rbp), %xmm0
jb 0x3c72
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movsd (%rax), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x3c72
cmpl $0x0, -0x34(%rbp)
jne 0x3bdc
movq -0x20(%rbp), %rdi
leaq 0x94b1(%rip), %rsi      # 0xd00c
callq 0x21b0
movq %rax, -0x88(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movq -0x88(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x2330
movq %rax, %rdi
leaq 0x946a(%rip), %rsi      # 0xd004
callq 0x21b0
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x57e0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x2180
movq %rax, %rdi
leaq 0x94a5(%rip), %rsi      # 0xd077
callq 0x21b0
jmp 0x3c69
movq -0x20(%rbp), %rdi
leaq 0x9424(%rip), %rsi      # 0xd00b
callq 0x21b0
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x5250
movq -0x98(%rbp), %rdi
movsd (%rax), %xmm0
callq 0x2330
movq %rax, %rdi
leaq 0x93de(%rip), %rsi      # 0xd004
callq 0x21b0
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
addq $0x40, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x4fc0
movq %rax, %rdi
callq 0x57e0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x2180
movq %rax, %rdi
leaq 0x9413(%rip), %rsi      # 0xd077
callq 0x21b0
movl $0x1, -0x34(%rbp)
jmp 0x3c7b
movl $0x1, -0x38(%rbp)
jmp 0x3c8b
jmp 0x3c7d
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3acd
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x8(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x3aa5
cmpl $0x0, -0x34(%rbp)
jne 0x3cca
movq -0x20(%rbp), %rdi
leaq 0x9352(%rip), %rsi      # 0xd006
callq 0x21b0
movq %rax, %rdi
movq 0xf2fd(%rip), %rsi      # 0x12fc0
callq 0x21e0
jmp 0x3cda
movq -0x20(%rbp), %rdi
movq 0xf2eb(%rip), %rsi      # 0x12fc0
callq 0x21e0
jmp 0x3cdc
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)