// File: /workspace/github_cpp_makefile_star2_O1/shreyas-gopalakrishna[P]Concurrent-Skip-list/skip_list.cpp
// Function: SkipList::range[abi:cxx11](int, int)
map<int, string> SkipList::range(int start_key, int end_key){

    map<int, string> range_output;

    if(start_key > end_key){
        return range_output;
    }

    Node *curr = head;

    for (int level = max_level; level >= 0; level--){
        while (curr->next[level] != NULL && start_key > curr->next[level]->get_key()){
            if(curr->get_key() >= start_key && curr->get_key() <= end_key){
                range_output.insert(make_pair(curr->get_key(), curr->get_value()));
            }
            curr = curr->next[level];
        }
    }

    while(curr != NULL && end_key >= curr->get_key()){
        if(curr->get_key() >= start_key && curr->get_key() <= end_key){
            range_output.insert(make_pair(curr->get_key(), curr->get_value()));
        }
        curr = curr->next[0];
    }

    return range_output;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %ebp
leaq 0x8(%rdi), %rax
movl $0x0, 0x8(%rdi)
xorl %ecx, %ecx
movq %rcx, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x20(%rdi)
movq %rdi, 0x50(%rsp)
movq %rcx, 0x28(%rdi)
cmpl %ebp, %edx
jg 0x5c6d
movl %edx, %r14d
movq (%rsi), %r15
movslq 0x58bb(%rip), %rbx      # 0xb304
testq %rbx, %rbx
js 0x5b74
movq 0x28(%r15), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
je 0x5b64
leaq 0x28(%r15), %r13
callq 0x4bea
cmpl %r14d, %eax
jge 0x5b64
movq %r15, %rdi
callq 0x4bea
cmpl %r14d, %eax
jl 0x5b47
movq %r15, %rdi
callq 0x4bea
cmpl %ebp, %eax
jg 0x5b47
movq %r15, %rdi
callq 0x4bea
movl %eax, %r12d
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x4bf0
movl %r12d, 0x28(%rsp)
leaq 0x40(%rsp), %rdx
movq %rdx, 0x30(%rsp)
movq 0x8(%rsp), %rax
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x5add
movq %rax, 0x30(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x5ae3
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rcx, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5ff2
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5b2b
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5b47
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
movq (%r13), %rax
movq (%rax,%rbx,8), %r15
leaq 0x28(%r15), %r13
movq 0x28(%r15), %rax
movq (%rax,%rbx,8), %rdi
testq %rdi, %rdi
jne 0x5a67
leaq -0x1(%rbx), %rax
testq %rbx, %rbx
movq %rax, %rbx
jg 0x5a52
testq %r15, %r15
leaq 0x18(%rsp), %rbx
je 0x5c6d
leaq 0x8(%rsp), %r13
movq %r15, %rdi
callq 0x4bea
cmpl %ebp, %eax
jg 0x5c6d
movq %r15, %rdi
callq 0x4bea
cmpl %r14d, %eax
jl 0x5c5d
movq %r15, %rdi
callq 0x4bea
cmpl %ebp, %eax
jg 0x5c5d
movq %r15, %rdi
callq 0x4bea
movl %eax, %r12d
movq %r13, %rdi
movq %r15, %rsi
callq 0x4bf0
movl %r12d, 0x28(%rsp)
leaq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rsp), %rax
cmpq %rbx, %rax
je 0x5bf8
movq %rax, 0x30(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x40(%rsp)
jmp 0x5bfe
movups (%rbx), %xmm0
movups %xmm0, (%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rbx, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x5ff2
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5c46
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x5c5d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x28(%r15), %rax
movq (%rax), %r15
testq %r15, %r15
jne 0x5b87
movq 0x50(%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5c89
jmp 0x5cca
jmp 0x5cca
jmp 0x5cca
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5ca8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2220
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5ccd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2220
jmp 0x5ccd
jmp 0x5cca
jmp 0x5cca
movq %rax, %r14
movq 0x50(%rsp), %rdi
callq 0x4176
movq %r14, %rdi
callq 0x2320
nop