// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]DrLink/detect_recombsite.cpp
// Function: collect_marker_info(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, 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::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>*)
bool collect_marker_info(const char* file, string parent_id, map<string, string>* mkr)
{
    // type of markers: snps, 1-bp deletion and 1-bp insertion
    cout << "   Info: reading marker info from " << file << endl;
    fstream ifp;
    ifp.open(file);
    if(!ifp.good())
    {
        return false;
    }
    int num = 0;
    int raw = 0;
    int del = 0;
    int ins = 0;
    bool adjsnp = false; // SNPs directly next to each other
    int    nadj = 0;
    while(ifp.good())
    {
        string line("");
        getline(ifp, line);
        if(line.size()==0 || line[0]=='#') continue;
        
        /* e.g.,
	        ks	1	164393	C	G  -- snp
		ks	1	164413	AC	TA -- twp snps
		ks	1	460940  -	A  -- insertion
		ks	1	468923  T	-  -- deletion
        */
        vector<string> lineinfo = split_string(line, '\t');
        if(lineinfo[3].size() != lineinfo[4].size()) continue; // non-snps
        raw ++;
        
        if(lineinfo[3].size() > 1 && !adjsnp)
        {
            cout << "   Info: snp line will be separated, e.g, " << line << endl;
            cout << "       You will get a total number after reading all marker info. " << endl;
            adjsnp = true;
            nadj ++;
        }
        else
        if(lineinfo[3].size()>1)
        {
            nadj ++;
        }
        
        //  split "double/triple/..." snps
        for(int snpi = 0; snpi < lineinfo[3].size(); snpi ++)
        {
            string ref = lineinfo[3].substr(snpi, 1);
            string alt = lineinfo[4].substr(snpi, 1);
            //
            unsigned long pos = strtoul(lineinfo[2].c_str(), NULL, 0);
            pos += snpi;
            std::stringstream sspos;
            sspos.str("");
            sspos << pos;
            //
            string key = lineinfo[1] + "#" + sspos.str() + "#" + ref + "#" + alt; // "GA", "G-" or "-A"
            string val = parent_id;
            
            map<string, string>::iterator itr;
            map<string, string>::iterator itr_end;
            itr     = (*mkr).find(key);
            itr_end = (*mkr).end();
            
            if(itr == itr_end)
            {
                (*mkr).insert(std::pair<string, string>(key, val));
                num ++;
                if(alt=="-") del ++;
                if(ref=="-") ins ++;
            } 
            else
            {
                // cout << "    Warning: same marker for both parents: " << line << " (only recorded in first set)" << endl;
                if(parent_id.compare((*itr).second) != 0)
                {
                    (*mkr).erase(key); // removed
                }
            }
        }
    }
    ifp.close();
    cout << "   Info: recording " << num << " (of " << raw << ")" << " snp markers info done " << endl;  
    cout << "   Info: total number of \"neighboring\" snps: "     << nadj << endl;  
    cout << "   Info: total number of del markers: "              << del  << endl;
    cout << "   Info: total number of ins markers: "              << ins  << endl;
    if(parent_id.compare("2") == 0)
    {
        cout << "   Info: in total  " << (*mkr).size()  << " markers info recorded till now. " << endl; 
        cout << "   Info: markers appear in both marker sets have been removed from records. " << endl << endl;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x558, %rsp            # imm = 0x558
movq %rdx, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %rbx
movq 0x2b07f(%rip), %rdi     # 0x3cfc8
leaq 0x19d3d(%rip), %rsi     # 0x2bc8d
callq 0x4330
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
leaq 0x348(%rsp), %r14
movq %r14, %rdi
callq 0x43a0
pushq $0x18
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x42f0
movq 0x348(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x368(%rsp,%rax), %ecx
movl %ecx, 0x30(%rsp)
testl %ecx, %ecx
jne 0x124e8
movq 0x8(%rsp), %rcx
addq $0x8, %rcx
movq %rcx, 0x78(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x160(%rsp), %r13
leaq 0x1a0(%rsp), %rbp
leaq 0x140(%rsp), %rbx
movl $0x0, 0x14(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x1c(%rsp)
movq $0x0, 0x38(%rsp)
xorl %r14d, %r14d
cmpl $0x0, 0x368(%rsp,%rax)
jne 0x12393
leaq 0x58(%rsp), %r15
movq %r15, %rdi
leaq 0x1bb05(%rip), %rsi     # 0x2db1a
leaq 0x1c0(%rsp), %rdx
callq 0x4d3e
leaq 0x348(%rsp), %rdi
movq %r15, %rsi
callq 0x4090
cmpq $0x0, 0x60(%rsp)
je 0x12378
movq 0x58(%rsp), %rax
cmpb $0x23, (%rax)
je 0x12378
movb $0x9, 0x1c0(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
callq 0x26120
movq 0x40(%rsp), %rax
movq 0x68(%rax), %rcx
cmpq 0x88(%rax), %rcx
jne 0x1236e
cmpq $0x2, %rcx
setb %al
orb 0x38(%rsp), %al
testb $0x1, %al
je 0x1209b
xorl %eax, %eax
cmpq $0x2, %rcx
setae %al
jmp 0x120e8
movq 0x2af26(%rip), %rdi     # 0x3cfc8
leaq 0x19c07(%rip), %rsi     # 0x2bcb0
callq 0x4330
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x42e0
movq %rax, %rdi
callq 0x41c0
movq 0x2aefe(%rip), %rdi     # 0x3cfc8
leaq 0x19c0a(%rip), %rsi     # 0x2bcdb
callq 0x4330
movb $0x1, %cl
movq %rcx, 0x38(%rsp)
movq %rax, %rdi
callq 0x41c0
pushq $0x1
popq %rax
incl 0x14(%rsp)
addl %eax, %r14d
movl %r14d, 0x34(%rsp)
xorl %r14d, %r14d
movq 0x40(%rsp), %rsi
cmpq %r14, 0x68(%rsi)
pushq $0x1
popq %rcx
jbe 0x12369
addq $0x60, %rsi
leaq 0xa0(%rsp), %rdi
movq %r14, %rdx
movq %rcx, %r15
callq 0x4360
movq 0x40(%rsp), %rsi
subq $-0x80, %rsi
leaq 0x80(%rsp), %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x4360
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4130
movq %rax, %r15
leaq 0x1c0(%rsp), %rdi
callq 0x4250
movq %r13, %rdi
leaq 0x1b9b2(%rip), %rsi     # 0x2db1a
movq %rbp, %rdx
callq 0x4d3e
leaq 0x1d8(%rsp), %rdi
movq %r13, %rsi
callq 0x4490
addq %r14, %r15
movq %r13, %rdi
callq 0x4638
leaq 0x1d0(%rsp), %rdi
movq %r15, %rsi
callq 0x4230
movq 0x40(%rsp), %rsi
addq $0x20, %rsi
leaq 0xc0(%rsp), %rdi
leaq 0x1be2f(%rip), %rdx     # 0x2dfe2
callq 0x95e2
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x44e0
leaq 0x100(%rsp), %r12
movq %r12, %rdi
leaq 0xc0(%rsp), %rsi
movq %r15, %rdx
callq 0x957b
leaq 0x120(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
leaq 0x1bde2(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq %rbx, %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %rdx
callq 0x961a
movq %r13, %rdi
movq %rbx, %rsi
leaq 0x1bdbd(%rip), %rdx     # 0x2dfe2
callq 0x5c38
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
callq 0x961a
movq %r13, %rdi
callq 0x4638
movq %rbx, %rdi
callq 0x4638
leaq 0x120(%rsp), %rdi
callq 0x4638
leaq 0x100(%rsp), %rdi
callq 0x4638
leaq 0xe0(%rsp), %rdi
callq 0x4638
leaq 0xc0(%rsp), %rdi
callq 0x4638
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x4400
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0xb44c
cmpq 0x78(%rsp), %rax
je 0x122c6
addq $0x40, %rax
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x4030
testl %eax, %eax
je 0x1232a
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x18070
jmp 0x1232a
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0xb400
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0xb4c2
movq %r13, %rdi
callq 0xb436
movq 0x20(%rsp), %rax
incl %eax
movq %rax, 0x20(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x172aa(%rip), %r15     # 0x295ae
movq %r15, %rsi
callq 0x158ea
movzbl %al, %eax
addl %eax, 0x18(%rsp)
leaq 0xa0(%rsp), %rdi
movq %r15, %rsi
callq 0x158ea
movzbl %al, %eax
addl %eax, 0x1c(%rsp)
movq %rbx, %rdi
callq 0x4638
movq %rbp, %rdi
callq 0x4638
leaq 0x1c0(%rsp), %rdi
callq 0x4280
leaq 0x80(%rsp), %rdi
callq 0x4638
leaq 0xa0(%rsp), %rdi
callq 0x4638
incq %r14
jmp 0x120f7
movl 0x34(%rsp), %r14d
leaq 0x40(%rsp), %rdi
callq 0x5d02
leaq 0x58(%rsp), %rdi
callq 0x4638
movq 0x348(%rsp), %rax
movq -0x18(%rax), %rax
jmp 0x11ff8
leaq 0x348(%rsp), %rdi
callq 0x4060
movq 0x2ac21(%rip), %rdi     # 0x3cfc8
leaq 0x19970(%rip), %rsi     # 0x2bd1e
callq 0x4330
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x4580
leaq 0x1996b(%rip), %rsi     # 0x2bd32
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x4580
leaq 0x1af56(%rip), %rsi     # 0x2d338
movq %rax, %rdi
callq 0x4330
leaq 0x19947(%rip), %rsi     # 0x2bd38
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x2abc0(%rip), %rdi     # 0x3cfc8
leaq 0x19941(%rip), %rsi     # 0x2bd50
callq 0x4330
movq %rax, %rdi
movl %r14d, %esi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
movq 0x2ab9a(%rip), %rdi     # 0x3cfc8
leaq 0x19949(%rip), %rsi     # 0x2bd7e
callq 0x4330
movq %rax, %rdi
movl 0x18(%rsp), %esi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
movq 0x2ab73(%rip), %rdi     # 0x3cfc8
leaq 0x19949(%rip), %rsi     # 0x2bda5
callq 0x4330
movq %rax, %rdi
movl 0x1c(%rsp), %esi
callq 0x4580
movq %rax, %rdi
callq 0x41c0
leaq 0x1ba91(%rip), %rsi     # 0x2df0d
movq 0x28(%rsp), %rdi
callq 0x4110
testl %eax, %eax
jne 0x124e8
movq 0x2ab37(%rip), %rdi     # 0x3cfc8
leaq 0x19934(%rip), %rsi     # 0x2bdcc
callq 0x4330
movq 0x8(%rsp), %rcx
movq 0x28(%rcx), %rsi
movq %rax, %rdi
callq 0x4230
leaq 0x1992b(%rip), %rsi     # 0x2bde0
movq %rax, %rdi
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq 0x2aafc(%rip), %rdi     # 0x3cfc8
leaq 0x1992f(%rip), %rsi     # 0x2be02
callq 0x4330
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x41c0
cmpl $0x0, 0x30(%rsp)
sete %bl
leaq 0x348(%rsp), %rdi
callq 0x40b0
movl %ebx, %eax
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1251c
jmp 0x12524
jmp 0x125da
jmp 0x1251c
movq %rax, %rbx
jmp 0x12637
movq %rax, %rbx
jmp 0x1262d
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0xb436
jmp 0x125e2
jmp 0x125df
movq %rax, %rbx
jmp 0x1259c
movq %rax, %rbx
jmp 0x125a9
movq %rax, %rbx
jmp 0x1257d
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0x125f7
movq %rax, %rbx
jmp 0x12609
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x4638
leaq 0x140(%rsp), %rdi
callq 0x4638
jmp 0x1258f
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x4638
leaq 0x100(%rsp), %rdi
callq 0x4638
leaq 0xe0(%rsp), %rdi
callq 0x4638
leaq 0xc0(%rsp), %rdi
jmp 0x125f7
movq %rax, %rbx
jmp 0x125ef
jmp 0x125df
movq %rax, %rbx
jmp 0x12616
movq %rax, %rbx
jmp 0x125b6
jmp 0x125d5
jmp 0x125d5
movq %rax, %rbx
jmp 0x125fc
movq %rax, %rbx
jmp 0x12623
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x4638
leaq 0x1a0(%rsp), %rdi
callq 0x4638
leaq 0x1c0(%rsp), %rdi
callq 0x4280
leaq 0x80(%rsp), %rdi
callq 0x4638
leaq 0xa0(%rsp), %rdi
callq 0x4638
leaq 0x40(%rsp), %rdi
callq 0x5d02
leaq 0x58(%rsp), %rdi
callq 0x4638
leaq 0x348(%rsp), %rdi
callq 0x40b0
movq %rbx, %rdi
callq 0x45a0