// File: /workspace/github_cpp_makefile_star2_O1/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 0x8ed29(%rip), %r14     # 0x10afe8
leaq 0x61d9c(%rip), %rsi     # 0xde062
movl $0x23, %edx
movq %r14, %rdi
callq 0x84e0
movq 0x903d6(%rip), %rsi     # 0x10c6b0
movq 0x903d7(%rip), %rdx     # 0x10c6b8
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 0x61d6c(%rip), %rsi     # 0xde086
movl $0x21, %edx
movq %r14, %rdi
callq 0x84e0
movq 0x903a2(%rip), %rsi     # 0x10c6d0
movq 0x903a3(%rip), %rdx     # 0x10c6d8
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), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x208, %edi            # imm = 0x208
callq 0x8470
movq %rax, %r14
movq 0x90321(%rip), %rsi     # 0x10c6b0
movq %rax, %rdi
movl $0x8, %edx
callq 0x8860
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x558d0(%rip), %rdx     # 0xd1c7f
leaq 0x78(%rsp), %rdi
movq %rdx, %rsi
callq 0x28952
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x58(%rsp), %r15
movq 0x8ebd3(%rip), %r12     # 0x10afb8
movl %eax, 0x10(%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 0x7c6f5
movq 0x58(%rsp), %rsi
cmpb $0x23, (%rsi)
jne 0x7c464
movq 0x60(%rsp), %rdx
movq %r12, %rdi
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 0x7c3ed
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
movl $0x9, %edx
callq 0x50624
movq 0x98(%rsp), %r13
movq 0x8(%r13), %rdx
cmpq 0x80(%rsp), %rdx
jne 0x7c4ae
testq %rdx, %rdx
je 0x7c66a
movq 0x78(%rsp), %rsi
movq (%r13), %rdi
callq 0x8490
testl %eax, %eax
je 0x7c66a
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
callq 0x8270
movq 0x98(%rsp), %rsi
leaq 0xc0(%rsp), %rdi
movl $0x5f, %edx
callq 0x50624
movq 0x40(%rsp), %rdx
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
leaq 0x55797(%rip), %rcx     # 0xd1c7f
xorl %r8d, %r8d
callq 0x86c0
movq %rbx, 0xb0(%rsp)
movq 0x18(%rbx), %rax
cmpq 0x28(%rsp), %rax
je 0x7c699
movl $0x0, 0x10(%rsp)
movq %r14, 0x20(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x40(%rax), %rbx
movq %rax, 0x30(%rsp)
movq 0x48(%rax), %r12
movl $0x0, %r15d
subq %rbx, %r12
je 0x7c59e
sarq $0x3, %r12
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
movq 0xc0(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x28(%rax), %r13
xorl %ebp, %ebp
xorl %r15d, %r15d
movq (%rbx,%rbp), %r14
movq 0x8(%r14), %rdx
cmpq %r13, %rdx
jne 0x7c589
testq %rdx, %rdx
je 0x7c5be
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rsi
movq (%r14), %rdi
callq 0x8490
testl %eax, %eax
je 0x7c5be
movq 0x40(%r14), %rdi
callq 0x86e0
addl %eax, %r15d
addq $0x18, %rbp
decq %r12
jne 0x7c55f
movl %r15d, 0x18(%rsp)
movq 0x20(%rsp), %r14
leaq 0x58(%rsp), %r15
movq 0x8ea04(%rip), %r12     # 0x10afb8
movq 0x30(%rsp), %r13
jmp 0x7c64e
movl %r15d, 0x18(%rsp)
movq 0x30(%rsp), %r13
leaq 0x20(%r13), %rsi
leaq 0x38(%rsp), %rdi
callq 0x8270
movq 0x40(%r13), %rax
movq (%rax,%rbp), %rbx
movq 0x40(%rbx), %rdi
callq 0x86e0
movl %eax, 0x1c(%rsp)
addq $0x20, %rbx
movq %rbx, %rdi
leaq 0x542aa(%rip), %rsi     # 0xd08a3
callq 0x8160
movb $0x1, %cl
movl %ecx, 0x10(%rsp)
testl %eax, %eax
movq 0x20(%rsp), %r14
leaq 0x58(%rsp), %r15
movq 0x8e9a1(%rip), %r12     # 0x10afb8
je 0x7c648
movq 0x40(%r13), %rax
movq (%rax,%rbp), %rdi
addq $0x20, %rdi
leaq 0x54284(%rip), %rsi     # 0xd08b0
callq 0x8160
testl %eax, %eax
movl 0x14(%rsp), %ecx
movzbl %cl, %ecx
movl $0x2d, %eax
cmovel %eax, %ecx
movl %ecx, 0x14(%rsp)
jmp 0x7c64e
movb $0x2b, %al
movl %eax, 0x14(%rsp)
testb $0x1, 0x10(%rsp)
jne 0x7c6a1
movq %r13, %rdi
callq 0x84f0
cmpq 0x28(%rsp), %rax
jne 0x7c514
jmp 0x7c6a1
movq %r15, (%rsp)
movsbl 0x14(%rsp), %edx
movzbl 0x10(%rsp), %esi
andl $0x1, %esi
leaq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x7d24c
jmp 0x7c6e3
movl $0x0, 0x10(%rsp)
movq %r15, (%rsp)
movsbl 0x14(%rsp), %edx
movzbl 0x10(%rsp), %esi
andl $0x1, %esi
leaq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x1c(%rsp), %r9
callq 0x7d24c
movq 0xb0(%rsp), %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3123c
leaq 0x98(%rsp), %rdi
callq 0x3123c
jmp 0x7c3ed
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x7c711
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x7c733
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7c74f
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 0x7c765
jmp 0x7c79f
movq %rax, %rbx
jmp 0x7c790
jmp 0x7c779
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
jmp 0x7c7db
movq %rax, %rbx
jmp 0x7c7e0
jmp 0x7c780
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3123c
leaq 0x98(%rsp), %rdi
callq 0x3123c
jmp 0x7c7a2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x7c7be
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x7c7e0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x8480
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x7c7fc
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x8480
movq %rbx, %rdi
callq 0x8840