// File: /workspace/github_cpp_makefile_star2_O3/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 $0xd8, %rsp
movq %rdi, %rbx
movq 0x86158(%rip), %r14     # 0x101fe8
leaq 0x5b25b(%rip), %rsi     # 0xd70f2
movl $0x23, %edx
movq %r14, %rdi
callq 0x84e0
movq 0x8780d(%rip), %rsi     # 0x1036b8
movq 0x8780e(%rip), %rdx     # 0x1036c0
movq %r14, %rdi
callq 0x84e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r15, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x5b22b(%rip), %rsi     # 0xd7116
movl $0x21, %edx
movq %r14, %rdi
callq 0x84e0
movq 0x877d9(%rip), %rsi     # 0x1036d8
movq 0x877da(%rip), %rdx     # 0x1036e0
movq %r14, %rdi
callq 0x84e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq 0x87754(%rip), %rsi     # 0x1036b8
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x51a4a(%rip), %rdx     # 0xcd9cb
leaq 0x38(%rsp), %rdi
movq %rdx, %rsi
callq 0x28a52
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rbx), %rbp
leaq 0x58(%rsp), %r15
movl %eax, 0x20(%rsp)
movl %eax, 0x14(%rsp)
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x8870
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x7c2c0
movq 0x58(%rsp), %rsi
cmpb $0x23, (%rsi)
jne 0x7c031
movq 0x60(%rsp), %rdx
movq 0x85fb8(%rip), %rdi     # 0x101fb8
callq 0x84e0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x8450
movsbl %al, %esi
movq %r13, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x8300
jmp 0x7bfb6
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
movl $0x9, %edx
callq 0x4d650
movq 0xa8(%rsp), %r13
movq 0x8(%r13), %rdx
cmpq 0x40(%rsp), %rdx
jne 0x7c078
testq %rdx, %rdx
je 0x7c21b
movq 0x38(%rsp), %rsi
movq (%r13), %rdi
callq 0x8490
testl %eax, %eax
je 0x7c21b
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
callq 0x8270
movq 0xa8(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
movl $0x5f, %edx
callq 0x4d650
movq 0x90(%rsp), %rdx
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
leaq 0x51913(%rip), %rcx     # 0xcd9cb
xorl %r8d, %r8d
callq 0x86c0
movq 0x18(%rbx), %rax
cmpq %rbp, %rax
je 0x7c24d
movq 0xc0(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq %rbx, 0x28(%rsp)
movq %rbp, 0x78(%rsp)
movq 0x40(%rax), %rcx
movq %rax, 0x30(%rsp)
movq 0x48(%rax), %r12
movq %rcx, 0x20(%rsp)
subq %rcx, %r12
je 0x7c168
sarq $0x3, %r12
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
movq 0x80(%rsp), %rax
movq 0x28(%rax), %r13
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movq (%rax,%rbx), %rbp
cmpq %r13, 0x8(%rbp)
jne 0x7c151
testq %r13, %r13
je 0x7c18d
movq 0x80(%rsp), %rax
movq 0x20(%rax), %rsi
movq (%rbp), %rdi
movq %r13, %rdx
callq 0x8490
testl %eax, %eax
je 0x7c18d
movq 0x40(%rbp), %rdi
callq 0x86e0
addl %eax, %r15d
addq $0x18, %rbx
decq %r12
jne 0x7c121
jmp 0x7c16b
xorl %r15d, %r15d
movq 0x30(%rsp), %rdi
callq 0x84f0
movq 0x78(%rsp), %rbp
cmpq %rbp, %rax
movq 0x28(%rsp), %rbx
jne 0x7c0e7
jmp 0x7c252
movl %r15d, 0x18(%rsp)
movq 0x30(%rsp), %r15
leaq 0x20(%r15), %rsi
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %r12
callq 0x8270
movq 0x40(%r15), %rax
movq (%rax,%rbx), %r13
movq 0x40(%r13), %rdi
callq 0x86e0
movl %eax, 0x1c(%rsp)
addq $0x20, %r13
movq %r13, %rdi
leaq 0x50edb(%rip), %rsi     # 0xcd0ab
callq 0x8160
movb $0x1, %dl
testl %eax, %eax
movq 0x78(%rsp), %rbp
leaq 0x58(%rsp), %r15
je 0x7c269
movq 0x30(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax,%rbx), %rdi
addq $0x20, %rdi
leaq 0x50eb7(%rip), %rsi     # 0xcd0b8
callq 0x8160
movb $0x1, %dl
testl %eax, %eax
movl 0x14(%rsp), %ecx
movzbl %cl, %ecx
movl $0x2d, %eax
cmovel %eax, %ecx
jmp 0x7c26b
movq %r15, (%rsp)
movsbl 0x14(%rsp), %edx
movzbl 0x20(%rsp), %esi
andl $0x1, %esi
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x7ce0d
jmp 0x7c2ae
movl 0x18(%rsp), %r15d
movl %r15d, 0x18(%rsp)
xorl %edx, %edx
leaq 0x68(%rsp), %r12
leaq 0x58(%rsp), %r15
movl 0x14(%rsp), %ecx
jmp 0x7c270
movb $0x2b, %cl
movq 0x28(%rsp), %rbx
movq %r15, (%rsp)
movl %edx, 0x20(%rsp)
movzbl %dl, %esi
movl %ecx, 0x14(%rsp)
movsbl %cl, %edx
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x7ce0d
leaq 0xc0(%rsp), %rdi
callq 0x2e784
leaq 0xa8(%rsp), %rdi
callq 0x2e784
jmp 0x7bfb6
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x7c2e5
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x7c301
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x7c318
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8480
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7c349
jmp 0x7c32e
movq %rax, %r15
jmp 0x7c359
jmp 0x7c36d
jmp 0x7c344
movq %rax, %r15
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
jmp 0x7c3ac
movq %rax, %r15
jmp 0x7c3b1
movq %rax, %r15
leaq 0xc0(%rsp), %rdi
callq 0x2e784
leaq 0xa8(%rsp), %rdi
callq 0x2e784
leaq 0x68(%rsp), %r12
jmp 0x7c370
movq %rax, %r15
leaq 0x48(%rsp), %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x7c39a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x38(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7c3b1
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x7c3c8
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8480
movq %r15, %rdi
callq 0x8840