// File: millanek[P]evo/./process_vcf_annotation_tools.h
// Function: SimpleCoordsBed::loadSimpleCoords(std::basic_ifstream<char, std::char_traits<char>>*&, std::map<int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<int>, std::allocator<std::pair<int const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>&)
std::map<string, std::vector<std::vector<string> > > loadSimpleCoords(std::ifstream*& bedFile, std::map<int,string>& linearToGenomeCoordMap) {
        std::map<string, std::vector<std::vector<string> > > coordsScaffoldMap;
        std::vector<std::vector<string> > coordsInScaffold;
        int linearPosition = 0; // Linear positions will be 0-indexed (will start at zero)
        string line;
        // Do the first line to find the name of the first scaffold
        getline(*bedFile, line);
        std::vector<string> bedVector = split(line, '\t');
        string currentScaffold = bedVector[0];
        int left = atoi(bedVector[1].c_str());
        int right = atoi(bedVector[2].c_str());
        int intervalLength = right - left;
        coordsInScaffold.push_back(bedVector);
        
        for (int i = 0; i < intervalLength; i++) {
            // Mapping will be 1-indexed, as in VCF files
            linearToGenomeCoordMap[linearPosition+i] = currentScaffold+"\t"+numToString(left+i+1);
        } linearPosition = linearPosition + intervalLength;
        
        //
        while (getline(*bedFile, line)) {
            std::vector<string> bedVector = split(line, '\t');
            string scaffold = bedVector[0];
            int left = atoi(bedVector[1].c_str());
            int right = atoi(bedVector[2].c_str());
            int intervalLength = right - left;
            
            for (int i = 0; i < intervalLength; i++) {
                // Mapping will be 1-indexed, as in VCF files
                int pos = linearPosition+i;
                if (pos % 1000000 == 0)
                    std::cerr << "Loaded and mapped " << pos/1000000 << "Mb" << std::endl;
                linearToGenomeCoordMap[pos] = currentScaffold+"\t"+numToString(left+i+1);
            } linearPosition = linearPosition + intervalLength;
            
            if (scaffold == currentScaffold) {
                coordsInScaffold.push_back(bedVector);
            } else {
                coordsScaffoldMap[currentScaffold] = coordsInScaffold;
                coordsInScaffold.clear();
                currentScaffold = scaffold;
            }
        }
        return coordsScaffoldMap;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rdi, -0x1f0(%rbp)
movq %rdi, %rax
movq %rax, -0x1e8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
callq 0x3f5d0
leaq -0x40(%rbp), %rdi
callq 0x3f5f0
movl $0x0, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0xa820
movq -0x1e0(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0xa0d0
jmp 0x3ef5a
leaq -0x90(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0x3ef71
xorl %eax, %eax
movl %eax, %esi
leaq -0x90(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0xa250
jmp 0x3ef92
leaq -0x90(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movq -0x1f8(%rbp), %rdi
movl %eax, -0xb4(%rbp)
movl $0x2, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movq -0x1f8(%rbp), %rsi
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl -0xb4(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xbc(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3f610
jmp 0x3f00d
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0xbc(%rbp), %eax
jge 0x3f17c
leaq 0xf6eae(%rip), %rdx     # 0x135ede
leaq -0x100(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3da80
jmp 0x3f045
movl -0xb4(%rbp), %edx
movl -0xc0(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %esi
leaq -0x120(%rbp), %rdi
callq 0x3e190
jmp 0x3f067
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0x3e070
jmp 0x3f083
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %eax
movl -0xc0(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x124(%rbp)
leaq -0x124(%rbp), %rsi
callq 0x3f680
movq %rax, -0x200(%rbp)
jmp 0x3f0ad
movq -0x200(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xa710
leaq -0xe0(%rbp), %rdi
callq 0xac88
leaq -0x120(%rbp), %rdi
callq 0xac88
leaq -0x100(%rbp), %rdi
callq 0xac88
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x3f017
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f566
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f55a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f54e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f16b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f15f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xac88
leaq -0x120(%rbp), %rdi
callq 0xac88
leaq -0x100(%rbp), %rdi
callq 0xac88
jmp 0x3f54e
movl -0x44(%rbp), %eax
addl -0xbc(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq -0x68(%rbp), %rsi
callq 0xa0d0
movq %rax, -0x208(%rbp)
jmp 0x3f1a1
movq -0x208(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xa740
movb %al, -0x209(%rbp)
jmp 0x3f1bf
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x3f1ce
jmp 0x3f518
leaq -0x140(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x9, %edx
callq 0x7bbe0
jmp 0x3f1e5
xorl %eax, %eax
movl %eax, %esi
leaq -0x140(%rbp), %rdi
callq 0x3d940
movq %rax, %rsi
leaq -0x160(%rbp), %rdi
callq 0xa250
jmp 0x3f206
leaq -0x140(%rbp), %rdi
movl $0x1, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, -0x164(%rbp)
leaq -0x140(%rbp), %rdi
movl $0x2, %esi
callq 0x3d940
movq %rax, %rdi
callq 0xa220
movq %rax, %rdi
callq 0xa970
movl %eax, -0x168(%rbp)
movl -0x168(%rbp), %eax
subl -0x164(%rbp), %eax
movl %eax, -0x16c(%rbp)
movl $0x0, -0x170(%rbp)
movl -0x170(%rbp), %eax
cmpl -0x16c(%rbp), %eax
jge 0x3f45a
movl -0x44(%rbp), %eax
addl -0x170(%rbp), %eax
movl %eax, -0x174(%rbp)
movl -0x174(%rbp), %eax
movl $0xf4240, %ecx          # imm = 0xF4240
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x3f34b
movq 0x159d41(%rip), %rdi    # 0x198ff0
leaq 0xf319b(%rip), %rsi     # 0x132451
callq 0xa5c0
movq %rax, -0x218(%rbp)
jmp 0x3f2c4
movq -0x218(%rbp), %rdi
movslq -0x174(%rbp), %rax
imulq $0x431bde83, %rax, %rcx # imm = 0x431BDE83
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x32, %rcx
movl %ecx, %esi
addl %eax, %esi
callq 0xab20
movq %rax, -0x220(%rbp)
jmp 0x3f2f6
movq -0x220(%rbp), %rdi
leaq 0xf3160(%rip), %rsi     # 0x132464
callq 0xa5c0
movq %rax, -0x228(%rbp)
jmp 0x3f312
movq -0x228(%rbp), %rdi
movq 0x159c68(%rip), %rsi    # 0x198f88
callq 0xa610
jmp 0x3f327
jmp 0x3f34b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f50a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f4fe
leaq 0xf6b8c(%rip), %rdx     # 0x135ede
leaq -0x1b8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3da80
jmp 0x3f367
movl -0x164(%rbp), %edx
movl -0x170(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %esi
leaq -0x1d8(%rbp), %rdi
callq 0x3e190
jmp 0x3f389
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
leaq -0x1d8(%rbp), %rdx
callq 0x3e070
jmp 0x3f3a5
movq -0x20(%rbp), %rdi
leaq -0x174(%rbp), %rsi
callq 0x3e450
movq %rax, -0x230(%rbp)
jmp 0x3f3be
movq -0x230(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0xa710
leaq -0x198(%rbp), %rdi
callq 0xac88
leaq -0x1d8(%rbp), %rdi
callq 0xac88
leaq -0x1b8(%rbp), %rdi
callq 0xac88
movl -0x170(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x170(%rbp)
jmp 0x3f270
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f449
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x3f43d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x198(%rbp), %rdi
callq 0xac88
leaq -0x1d8(%rbp), %rdi
callq 0xac88
leaq -0x1b8(%rbp), %rdi
callq 0xac88
jmp 0x3f4fe
movl -0x44(%rbp), %eax
addl -0x16c(%rbp), %eax
movl %eax, -0x44(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x39210
testb $0x1, %al
jne 0x3f47f
jmp 0x3f493
leaq -0x40(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x3f610
jmp 0x3f491
jmp 0x3f4e1
movq -0x1f0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3f760
movq %rax, -0x238(%rbp)
jmp 0x3f4af
movq -0x238(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3f840
jmp 0x3f4c1
leaq -0x40(%rbp), %rdi
callq 0x3fa90
leaq -0xb0(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xa060
jmp 0x3f4df
jmp 0x3f4e1
leaq -0x160(%rbp), %rdi
callq 0xac88
leaq -0x140(%rbp), %rdi
callq 0x3dfa0
jmp 0x3f188
leaq -0x160(%rbp), %rdi
callq 0xac88
leaq -0x140(%rbp), %rdi
callq 0x3dfa0
jmp 0x3f54e
movb $0x1, -0x21(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0x3dfa0
leaq -0x68(%rbp), %rdi
callq 0xac88
leaq -0x40(%rbp), %rdi
callq 0x3ec50
testb $0x1, -0x21(%rbp)
jne 0x3f592
jmp 0x3f586
leaq -0xb0(%rbp), %rdi
callq 0xac88
leaq -0x90(%rbp), %rdi
callq 0x3dfa0
leaq -0x68(%rbp), %rdi
callq 0xac88
leaq -0x40(%rbp), %rdi
callq 0x3ec50
movq -0x1f0(%rbp), %rdi
callq 0x3f5b0
jmp 0x3f5a2
movq -0x1f0(%rbp), %rdi
callq 0x3f5b0
movq -0x1e8(%rbp), %rax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0xab50
nopl (%rax,%rax)