// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/process_vcf_use_map.cpp
// Function: processVCF(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::vector<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::allocator<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>>>>> const&)
void processVCF(const std::map<string, std::vector<std::vector<string> > >& LGmap) {
    
    std::cerr << "Processing VCF variant calls from: " << opt::inputFile << std::endl;
    std::cerr << "using linkage groups defined in: " << opt::LGfile << std::endl;
    
    string line;
    std::ifstream* vcfFile = new std::ifstream(opt::inputFile.c_str());
    
    string currentScaffoldNum = "";
    bool bInLG;
    string thisLG;
    int LGsizeUpToHere;
    int thisScaffoldSize;
    char thisScaffoldOrientation;
    
    while (getline(*vcfFile, line)) {
        if (line[0] == '#')
            std::cout << line << std::endl;
        else {
            std::vector<string> vcfFields = split(line, '\t');
            if (vcfFields[0] == currentScaffoldNum) {
                printProcessedVCFline(vcfFields, bInLG, thisScaffoldOrientation, thisLG, LGsizeUpToHere, thisScaffoldSize, line);
            } else {
                currentScaffoldNum = vcfFields[0];
                std::vector<string> scaffoldNumVec = split(vcfFields[0], '_');
                bInLG = false;
                thisLG = "";
                for(std::map<string, std::vector<std::vector<string> > >::const_iterator it = LGmap.begin(); it != LGmap.end(); ++it) {
                    // std::cerr << "Building " << it->first << std::endl;
                    LGsizeUpToHere = 0;
                    for (std::vector<std::vector<string> >::size_type i = 0; i != it->second.size(); i++) {
                        // std::cerr << "Adding " << it->second[i][0] << std::endl;
                        if (it->second[i][0] == scaffoldNumVec[1]) {
                            bInLG = true;
                            thisLG = it->first;
                            thisScaffoldSize = atoi(it->second[i][2].c_str());
                            if (it->second[i][1] == "+")
                                thisScaffoldOrientation = '+';
                            else if (it->second[i][1] == "-")
                                thisScaffoldOrientation = '-';
                            break;
                        } else {
                            LGsizeUpToHere += atoi(it->second[i][2].c_str());
                            //std::cerr << "Here: " << it->second[i][0] << std::endl;
                            //std::cerr << "LG:" << it->first << " LGsizeUpToHere: " << LGsizeUpToHere << std::endl;
                        }
                    }
                    if (bInLG) break;
                }
                // std::cerr << "LGsizeUpToHere: " << LGsizeUpToHere << std::endl;
                printProcessedVCFline(vcfFields, bInLG, thisScaffoldOrientation, thisLG, LGsizeUpToHere, thisScaffoldSize, line);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movq 0x7e07b(%rip), %r14     # 0xdcfe8
leaq 0x47376(%rip), %rsi     # 0xa62ea
movq %r14, %rdi
callq 0x8480
leaq 0x7f765(%rip), %rsi     # 0xde6e8
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x47374(%rip), %rsi     # 0xa630e
movq %r14, %rdi
callq 0x8480
leaq 0x7f75f(%rip), %rsi     # 0xde708
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r14
movq 0x7f707(%rip), %rsi     # 0xde6e8
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
leaq 0x3ae2c(%rip), %rsi     # 0x99e1f
leaq 0xa8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x21904
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rbx), %r12
leaq 0x88(%rsp), %r15
movq 0x7df8f(%rip), %rbp     # 0xdcfb8
movl %eax, 0x18(%rsp)
movl %eax, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x80a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x5f253
movq 0x88(%rsp), %rax
cmpb $0x23, (%rax)
jne 0x5f070
movq %rbp, %rdi
movq %r15, %rsi
callq 0x8430
movq %rax, %rdi
callq 0x8230
jmp 0x5f031
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
pushq $0x9
popq %rdx
callq 0x40349
movq 0x28(%rsp), %rdi
leaq 0xa8(%rsp), %r13
movq %r13, %rsi
callq 0x26b06
testb %al, %al
je 0x5f0c8
movq %r15, (%rsp)
movsbl 0x10(%rsp), %edx
movzbl 0x18(%rsp), %esi
andl $0x1, %esi
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x5f95c
jmp 0x5f237
movq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x82a0
movq 0x28(%rsp), %rsi
leaq 0x70(%rsp), %rdi
pushq $0x5f
popq %rdx
callq 0x40349
leaq 0x50(%rsp), %rdi
leaq 0x3ad2c(%rip), %rsi     # 0x99e1f
callq 0x88f0
movq %r14, 0x40(%rsp)
movq %rbx, 0x48(%rsp)
movq 0x18(%rbx), %rbp
movl 0x14(%rsp), %r13d
movq %r12, 0x20(%rsp)
cmpq %r12, %rbp
je 0x5f246
movq 0x40(%rbp), %r14
xorl %ebx, %ebx
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x48(%rbp), %rax
subq %r14, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rax, %r12
je 0x5f16c
movq (%r14,%rbx), %rdi
movq 0x70(%rsp), %rsi
addq $0x20, %rsi
callq 0x26b06
testb %al, %al
jne 0x5f17e
movq 0x40(%rbp), %r14
movq (%r14,%rbx), %rax
movq 0x40(%rax), %rdi
callq 0x86f0
addl %eax, %r13d
incq %r12
addq $0x18, %rbx
jmp 0x5f125
movq %rbp, %rdi
callq 0x84f0
movq %rax, %rbp
movq 0x20(%rsp), %r12
jmp 0x5f110
movl %r13d, 0x14(%rsp)
leaq 0x20(%rbp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x82a0
movq 0x40(%rbp), %rax
movq (%rax,%rbx), %r13
movq 0x40(%r13), %rdi
callq 0x86f0
movl %eax, 0x1c(%rsp)
addq $0x20, %r13
movq %r13, %rdi
leaq 0x3988f(%rip), %rsi     # 0x98a43
callq 0x2193f
movb $0x1, %dl
testb %al, %al
movq 0x20(%rsp), %r12
je 0x5f1c8
movb $0x2b, %cl
jmp 0x5f1f1
movq 0x40(%rbp), %rax
movq (%rax,%rbx), %rdi
addq $0x20, %rdi
leaq 0x39875(%rip), %rsi     # 0x98a50
callq 0x2193f
movb $0x1, %dl
movl 0x10(%rsp), %ecx
movzbl %cl, %ecx
testb %al, %al
pushq $0x2d
popq %rax
cmovnel %eax, %ecx
movq %r15, (%rsp)
movl %edx, 0x18(%rsp)
movzbl %dl, %esi
movl %ecx, 0x10(%rsp)
movsbl %cl, %edx
leaq 0x28(%rsp), %rdi
leaq 0x50(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x5f95c
movq 0x48(%rsp), %rbx
movq 0x40(%rsp), %r14
movq 0x7dd8b(%rip), %rbp     # 0xdcfb8
leaq 0x70(%rsp), %rdi
callq 0x28a08
leaq 0x28(%rsp), %rdi
callq 0x28a08
jmp 0x5f031
movl %r13d, 0x14(%rsp)
xorl %edx, %edx
movl 0x10(%rsp), %ecx
jmp 0x5f1f1
leaq 0x50(%rsp), %rdi
callq 0x8978
leaq 0xa8(%rsp), %rdi
callq 0x8978
leaq 0x88(%rsp), %rdi
callq 0x8978
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f294
jmp 0x5f28d
movq %rax, %rbx
jmp 0x5f2a1
jmp 0x5f2c6
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x28a08
leaq 0x28(%rsp), %rdi
callq 0x28a08
jmp 0x5f2c9
jmp 0x5f2c1
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
callq 0x84a0
jmp 0x5f2e0
movq %rax, %rbx
jmp 0x5f2e0
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x8978
leaq 0xa8(%rsp), %rdi
callq 0x8978
leaq 0x88(%rsp), %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8870