// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]evo/process_vcf_use_map.cpp
// Function: processGenome(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 processGenome(const std::map<string, std::vector<std::vector<string> > >& LGmap) {
    
    std::cerr << "Joining genomic scaffolds from: " << opt::inputFile << std::endl;
    std::cerr << "using linkage groups defined in: " << opt::LGfile << std::endl;
    
    string line;
    std::vector<string> currentScaffoldNum;
    string nextScaffoldNum;
    string currentScaffoldString;
    std::map<std::string, std::string> scaffoldStrings;
    std::ifstream* genomeFile = new std::ifstream(opt::inputFile.c_str());
    
    getline(*genomeFile, line);
    currentScaffoldNum = split(line, '_');
    int i = 0;
    while (currentScaffoldString != "") {
        i++;
        currentScaffoldString = readScaffold(genomeFile, nextScaffoldNum);
        if (i % 10 == 0)
            std::cerr << "scaffold " << i << " read" << std::endl;
        /*if (i == 118) {
            std::cerr << "scaffold " << i << " read; length: " << currentScaffoldString.length() << std::endl;
            std::cerr << "currentScaffoldNum[1]: " << currentScaffoldNum[1] << std::endl;
        } */
        scaffoldStrings[currentScaffoldNum[1]] = currentScaffoldString;
        currentScaffoldNum = split(nextScaffoldNum,'_');
    }
    scaffoldStrings[currentScaffoldNum[1]] = currentScaffoldString;
    std::cerr << "scaffold " << currentScaffoldNum[1] << " read" << std::endl;
    
    // std::cerr << "Hello?? " << std::endl;
    std::vector<string> scaffoldsInLinkageGroups;
    string LGString; LGString.reserve(100000000);
    for(std::map<string, std::vector<std::vector<string> > >::const_iterator it = LGmap.begin(); it != LGmap.end(); ++it) {
        LGString = "";
        std::cerr << "Building " << it->first << std::endl;
        for (std::vector<std::vector<string> >::size_type i = 0; i != it->second.size(); i++) {
            std::cerr << "Adding " << it->second[i][0] << " length: " << scaffoldStrings[it->second[i][0]].length() << "(" << it->second[i][2] << ")" << std::endl;
            if (it->second[i][1] == "+") {
                LGString.append(scaffoldStrings[it->second[i][0]]);
            } else if (it->second[i][1] == "-") {
                LGString.append(reverseComplementIUPAC(scaffoldStrings[it->second[i][0]]));
            }
            scaffoldsInLinkageGroups.push_back(it->second[i][0]);
        }
        std::cout << ">" << it->first << std::endl;
        print80bpPerLineStdOut(std::cout, LGString);
    }
    // Print remaining scaffolds (the ones that are not in linkage groups
    for(std::map<std::string, std::string>::iterator it = scaffoldStrings.begin(); it != scaffoldStrings.end(); ++it) {
        if (std::find(scaffoldsInLinkageGroups.begin(), scaffoldsInLinkageGroups.end(), it->first) ==  scaffoldsInLinkageGroups.end()) {
            std::cout << ">scaffold_" << it->first << std::endl;
            print80bpPerLineStdOut(std::cout, it->second);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x8(%rsp)
movq 0x7dcd6(%rip), %rbx     # 0xdcfe8
leaq 0x47017(%rip), %rsi     # 0xa6330
movq %rbx, %rdi
callq 0x8480
leaq 0x7f3c0(%rip), %rsi     # 0xde6e8
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x46fcf(%rip), %rsi     # 0xa630e
movq %rbx, %rdi
callq 0x8480
leaq 0x7f3ba(%rip), %rsi     # 0xde708
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x20(%rsp)
leaq 0xf8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, 0x10(%rsp)
movb %cl, (%rax)
leaq 0xb8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x80(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movl $0x208, %edi            # imm = 0x208
callq 0x8490
movq %rax, %r14
movq 0x7f310(%rip), %rsi     # 0xde6e8
pushq $0x8
popq %rdx
movq %rax, %rdi
callq 0x8890
movq %r14, 0x70(%rsp)
leaq 0xc8(%rsp), %rsi
movq %r14, %rdi
callq 0x80a0
leaq 0x48(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
pushq $0x5f
popq %rdx
callq 0x40349
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %r14
movq %r14, %rsi
callq 0x2f6c0
movq %r14, %rdi
callq 0x28a08
pushq $-0x1
popq %r15
pushq $0x1
popq %rbp
leaq 0xa8(%rsp), %r12
leaq 0xe8(%rsp), %rbx
movl %ebp, %eax
xorl %edx, %edx
pushq $0xa
popq %rcx
divl %ecx
movl %eax, %r13d
movq %r12, %rdi
leaq 0x3a9cb(%rip), %rsi     # 0x99e1f
callq 0x2ea9b
testb %al, %al
je 0x5f50f
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
movq %rbx, %rdx
callq 0x3a53b
imull $0xa, %r13d, %r13d
addl %r15d, %r13d
movq %r12, %rdi
movq %r14, %rsi
callq 0x8550
movq %r14, %rdi
callq 0x8978
testl %r13d, %r13d
jne 0x5f4c4
movq 0x7db51(%rip), %rdi     # 0xdcfe8
leaq 0x519cd(%rip), %rsi     # 0xb0e6b
callq 0x8480
movq %rax, %rdi
movl %ebp, %esi
callq 0x8840
movq %rax, %rdi
leaq 0x46e9a(%rip), %rsi     # 0xa6351
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
leaq 0x78(%rsp), %rdi
callq 0x3210e
movq %rax, %rdi
movq %r12, %rsi
callq 0x82a0
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x5f
popq %rdx
callq 0x40349
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x2f6c0
movq %r14, %rdi
callq 0x28a08
decl %r15d
incl %ebp
jmp 0x5f43e
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
leaq 0x78(%rsp), %rdi
callq 0x3210e
leaq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x82a0
movq 0x7daaf(%rip), %rdi     # 0xdcfe8
leaq 0x5192b(%rip), %rsi     # 0xb0e6b
callq 0x8480
movq 0x10(%rsp), %rsi
addq $0x20, %rsi
movq %rax, %rdi
callq 0x8430
leaq 0x46df4(%rip), %rsi     # 0xa6351
movq %rax, %rdi
callq 0x8480
movq %rax, %rdi
callq 0x8230
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x48(%rsp), %rdi
movl $0x5f5e100, %esi        # imm = 0x5F5E100
callq 0x8700
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r14
addq $0x8, %rax
movq %rax, 0x8(%rsp)
leaq 0x78(%rsp), %rbp
leaq 0x30(%rsp), %r12
cmpq 0x8(%rsp), %r14
je 0x5f7b8
leaq 0x48(%rsp), %rdi
leaq 0x3a851(%rip), %rsi     # 0x99e1f
callq 0x88f0
movq 0x7da0e(%rip), %rdi     # 0xdcfe8
leaq 0x46d76(%rip), %rsi     # 0xa6357
callq 0x8480
leaq 0x20(%r14), %rsi
movq %rax, %rdi
movq %rsi, 0x68(%rsp)
callq 0x8430
movq %rax, %rdi
callq 0x8230
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x48(%r14), %rax
subq 0x40(%r14), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %rax, %r15
je 0x5f74f
movq 0x7d9c3(%rip), %rdi     # 0xdcfe8
leaq 0x46d35(%rip), %rsi     # 0xa6361
callq 0x8480
movq 0x40(%r14), %rcx
movq (%rcx,%r13), %rsi
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
leaq 0x43e7f(%rip), %rsi     # 0xa34ca
callq 0x8480
movq %rax, %rbx
movq 0x40(%r14), %rax
movq (%rax,%r13), %rsi
movq %rbp, %rdi
callq 0x3210e
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x8320
movq %rax, %rdi
leaq 0x421cb(%rip), %rsi     # 0xa1844
callq 0x8480
movq 0x40(%r14), %rcx
movq (%rcx,%r13), %rsi
addq $0x40, %rsi
movq %rax, %rdi
callq 0x8430
movq %rax, %rdi
leaq 0x453a4(%rip), %rsi     # 0xa4a40
callq 0x8480
movq %rax, %rdi
callq 0x8230
movq 0x40(%r14), %rax
movq (%rax,%r13), %rdi
addq $0x20, %rdi
leaq 0x39387(%rip), %rsi     # 0x98a43
callq 0x2193f
movq 0x40(%r14), %rcx
movq (%rcx,%r13), %rsi
testb %al, %al
je 0x5f6e4
movq %rbp, %rdi
callq 0x3210e
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x8920
jmp 0x5f733
addq $0x20, %rsi
movq %rsi, %rdi
leaq 0x3935e(%rip), %rsi     # 0x98a50
callq 0x2193f
testb %al, %al
je 0x5f733
movq 0x40(%r14), %rax
movq (%rax,%r13), %rsi
movq %rbp, %rdi
callq 0x3210e
leaq 0x148(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x465bc
leaq 0x48(%rsp), %rdi
movq %rbx, %rsi
callq 0x8920
movq %rbx, %rdi
callq 0x8978
movq 0x40(%r14), %rax
movq (%rax,%r13), %rsi
movq %r12, %rdi
callq 0x2b0a4
incq %r15
addq $0x18, %r13
jmp 0x5f605
movq 0x7d862(%rip), %rdi     # 0xdcfb8
leaq 0x3f3b5(%rip), %rsi     # 0x9eb12
callq 0x8480
movq %rax, %rdi
movq 0x68(%rsp), %rsi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x108(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x8600
movq 0x7d828(%rip), %rdi     # 0xdcfb8
leaq 0x108(%rsp), %rbx
movq %rbx, %rsi
callq 0x426a5
movq %rbx, %rdi
callq 0x8978
movq %r14, %rdi
callq 0x84f0
movq %rax, %r14
jmp 0x5f5b7
movq 0x90(%rsp), %r15
movq 0x7d7f1(%rip), %rbx     # 0xdcfb8
leaq 0x46b9b(%rip), %r14     # 0xa6369
leaq 0x128(%rsp), %r12
leaq 0x80(%rsp), %rax
cmpq %rax, %r15
je 0x5f84a
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
leaq 0x20(%r15), %r13
movq %r13, %rdx
callq 0x46356
cmpq 0x38(%rsp), %rax
jne 0x5f83d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8480
movq %rax, %rdi
movq %r13, %rsi
callq 0x8430
movq %rax, %rdi
callq 0x8230
leaq 0x40(%r15), %rsi
movq %r12, %rdi
callq 0x8600
movq %rbx, %rdi
movq %r12, %rsi
callq 0x426a5
movq %r12, %rdi
callq 0x8978
movq %r15, %rdi
callq 0x8340
movq %rax, %r15
jmp 0x5f7d6
leaq 0x48(%rsp), %rdi
callq 0x8978
leaq 0x30(%rsp), %rdi
callq 0x28a08
leaq 0x78(%rsp), %rdi
callq 0x33008
leaq 0xa8(%rsp), %rdi
callq 0x8978
leaq 0xe8(%rsp), %rdi
callq 0x8978
leaq 0x10(%rsp), %rdi
callq 0x28a08
leaq 0xc8(%rsp), %rdi
callq 0x8978
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5f902
jmp 0x5f8e7
movq %rax, %rbx
movl $0x208, %esi            # imm = 0x208
movq %r14, %rdi
callq 0x84a0
jmp 0x5f919
jmp 0x5f8e7
jmp 0x5f8e7
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
jmp 0x5f8f7
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x5f8f7
jmp 0x5f902
jmp 0x5f8e7
jmp 0x5f8e7
jmp 0x5f902
movq %rax, %rbx
jmp 0x5f919
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x8978
jmp 0x5f905
jmp 0x5f902
jmp 0x5f902
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x8978
leaq 0x30(%rsp), %rdi
callq 0x28a08
leaq 0x78(%rsp), %rdi
callq 0x33008
leaq 0xa8(%rsp), %rdi
callq 0x8978
leaq 0xe8(%rsp), %rdi
callq 0x8978
leaq 0x10(%rsp), %rdi
callq 0x28a08
leaq 0xc8(%rsp), %rdi
callq 0x8978
movq %rbx, %rdi
callq 0x8870