// File: millanek[P]evo/./process_vcf_annotation_tools.h
// Function: BedCoordinateFeatures::getFeaturesinRegion(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int)
std::vector<std::vector <string> > getFeaturesinRegion(const string& scaffold, const int start, const int end) {
        std::vector<std::vector <string> > allFeatures;
        try {
            std::vector<std::vector<int> > featuresThisSc = BedFeatureMap.at(scaffold);
            //std::cerr << "There are " << aGThisSc[0].size() << " accessible intervals" << std::endl;
            /*for (std::map<std::string, std::vector<std::vector<int> > >::iterator i = accessibleGenomeMap.begin(); i != accessibleGenomeMap.end(); i++) {
             std::cerr << "There is scaffold: " << i->first << " in the map" << std::endl;
             } */
            
            
            // Binary search to find the first feature whose end coordinate is greater
            // or equal to the start of the region in question
            std::vector<int>::iterator itStart = lower_bound(featuresThisSc[1].begin(),featuresThisSc[1].end(),start);
            std::vector<int>::size_type index = std::distance(featuresThisSc[1].begin(), itStart);
            // Now check that the start coordinate of the feature is within
            
            // Sum the lengths
            while (featuresThisSc[0][index] <= end) {
                std::vector <string> feature;
                feature.push_back(scaffold); feature.push_back(numToString(featuresThisSc[0][index]));
                feature.push_back(numToString(featuresThisSc[1][index]));
                index++;
            }
            return allFeatures;
        } catch (const std::out_of_range& oor) {
            std::cerr << "No features on scaffold: " << scaffold << std::endl;
            return allFeatures;
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x108(%rbp)
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x3f5f0
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0x703f0
movq %rax, -0xf0(%rbp)
jmp 0x6bbd0
movq -0xf0(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x70490
jmp 0x6bbe2
leaq -0x40(%rbp), %rdi
movq %rdi, -0x120(%rbp)
movl $0x1, %esi
movq %rsi, -0x118(%rbp)
callq 0x705d0
movq %rax, %rdi
callq 0x46a90
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq %rax, -0x60(%rbp)
callq 0x705d0
movq %rax, %rdi
callq 0x46ac0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
leaq -0x1c(%rbp), %rdx
callq 0x70580
movq %rax, -0x110(%rbp)
jmp 0x6bc43
movq -0x110(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x705d0
movq %rax, %rdi
callq 0x46a90
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x70630
movq %rax, -0x128(%rbp)
jmp 0x6bc86
movq -0x128(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x705d0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x4d100
movl (%rax), %eax
cmpl -0x20(%rbp), %eax
jg 0x6bdf9
leaq -0x98(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x48da0
movq -0x130(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x48dc0
jmp 0x6bcda
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x705d0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x4d100
movl (%rax), %esi
leaq -0xb8(%rbp), %rdi
callq 0x3e190
jmp 0x6bd03
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x5f980
jmp 0x6bd18
leaq -0xb8(%rbp), %rdi
callq 0xac88
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x705d0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x4d100
movl (%rax), %esi
leaq -0xd8(%rbp), %rdi
callq 0x3e190
jmp 0x6bd4e
leaq -0x98(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x5f980
jmp 0x6bd63
leaq -0xd8(%rbp), %rdi
callq 0xac88
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3dfa0
jmp 0x6bc91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6be1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6be15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6bdeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xac88
jmp 0x6bdeb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xac88
leaq -0x98(%rbp), %rdi
callq 0x3dfa0
jmp 0x6be15
movb $0x1, -0x21(%rbp)
movl $0x1, -0xdc(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x6d0b0
jmp 0x6bec2
leaq -0x40(%rbp), %rdi
callq 0x6d0b0
movl -0x4c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6bee4
movq -0x48(%rbp), %rdi
callq 0xa210
movq %rax, -0xe8(%rbp)
movq 0x12d1ab(%rip), %rdi    # 0x198ff0
leaq 0xcd9ac(%rip), %rsi     # 0x1397f8
callq 0xa5c0
movq %rax, -0x138(%rbp)
jmp 0x6be5a
movq -0x138(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xa520
movq %rax, -0x140(%rbp)
jmp 0x6be73
movq -0x140(%rbp), %rdi
movq 0x12d107(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x6be88
movb $0x1, -0x21(%rbp)
movl $0x1, -0xdc(%rbp)
callq 0xaa20
jmp 0x6beb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0xaa20
jmp 0x6bec0
jmp 0x6bec2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x6bee4
jmp 0x6bee4
testb $0x1, -0x21(%rbp)
jne 0x6bed4
movq -0x108(%rbp), %rdi
callq 0x3ec50
movq -0x100(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x108(%rbp), %rdi
callq 0x3ec50
movq -0x48(%rbp), %rdi
callq 0xab50
movq %rax, %rdi
callq 0x2d970
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)