// File: /workspace/github_cpp_makefile_star2_O2/schneebergerlab[P]GameteBinning/asPollinator_1.0.cpp
// Function: get_options(int, char**, 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::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>>>>*, bool*, double*, double*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
bool get_options(int                  argc, 
                 char*                argv[],
                 string*              filemark,
                 string*              filesize,
                 vector<string>*      filepoll,
                 bool*                correction,
                 double*              lodcutoff,
                 double*              minCOscore,
                 string*              outprefix)
{
    int  ic;
    bool markf   = false;
    bool pollf   = false;
    int  pollnum = 0; // number of pollen files given
    // log cmdline
    cout << "   CMDline: ";
    ic = 0;
    while(ic < argc)
    {
        cout << argv[ic] << " ";
        ic ++;
    }
    cout << endl;
    // get values
    ic = 1;    
    while (ic < argc) 
    {
        string optstr = (string)argv[ic];
        if(optstr.compare("--marker") == 0)
        {
            ic ++;
            *filemark = (string)argv[ic];
            ifstream fp;
            fp.open((*filemark).c_str(), ios::in);
            if(fp.good())
            {
                fp.close();
                cout << "   Info: marker file provided: "    << *filemark << endl;
            }
            else
            {
                cout << "   Error: cannot open marker file " << *filemark << endl;
                return false;
            }
        }
        else
        if(optstr.compare("--corr") == 0)
        {
            *correction = true;
            cout << "   Info: correcting markers asked. " << endl;
        }
        else
        if(optstr.compare("--lod") == 0)
        {
            ic ++;
            *lodcutoff = atof(argv[ic]);
            cout << "   Info: lod cutoff provided to build conections: " << *lodcutoff << endl;
        } 
        else
        if(optstr.compare("--ims") == 0)
        {
            ic ++;
            *minCOscore = (double)atof(argv[ic]);
            if(*minCOscore>=0.5)
            {
                cout << "   Info: minimum score of candidate co events provided: "   << *minCOscore << endl;
            }
            else
            {
                cout << "   Error: minimum score of candidate co events too small: " << *minCOscore << endl;
                return false;
            }
        }                
        else       
        if(optstr.compare("--pollen") == 0)
        {
            ic ++;
            cout << "   Info: list of pollen variant files provided: "    << argv[ic] << endl;            
            ifstream fp;
            fp.open(argv[ic], ios::in);
            if(fp.good())
            {
                while(fp.good())
                {
                    string line("");
                    getline(fp, line);
                    if(line.size()==0 || line[0]=='#') continue;
                    pollnum ++;
                    ifstream ithfp;
                    ithfp.open(line.c_str(), ios::in);                    
                    if(ithfp.good())
                    {
                        (*filepoll).push_back(line);
                        ithfp.close();
                    }else
                    {
                        cout << "   Error: cannot open " << pollnum  << "th "  << "pollen file "  << line    << endl;
                    }                  
                }
                fp.close();
                cout << "   Info: No. pollen file collected/provided: " << (*filepoll).size() << "/" << pollnum << endl;
            }
            else
            {
                cout << "   Error: cannot open pollen-sample list file " << argv[ic] << endl;
                return false;
            }
        }
        else       
        if(optstr.compare("--size") == 0)
        {
            ic ++;
            ifstream fp;
            *filesize = (string)argv[ic];
            fp.open(argv[ic], ios::in);
            if(fp.good())
            {
                cout << "   Info: contig size file provided: "    << argv[ic] << endl;            
            }
            else
            {
                cout << "   Error: contig size file not found: "  << argv[ic] << endl;            
                return false;
            }
            fp.close();
        }        
        else
        if(optstr.compare("-o") == 0)
        {
            ic ++;
            *outprefix = (string)argv[ic];
            cout << "   Info: output files will be labeled with \""    << *outprefix << "\"" << endl;
        }        
        else
        {
            cout << "   Warning: option " << argv[ic] << " was not recognized and ignored."  << endl;
        }
        // next option
        ic ++;
    }
    // check necessary files
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %r9, 0x50(%rsp)
movq %r8, 0x18(%rsp)
movq %rcx, 0x48(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, %r13
movl %edi, %ebx
movq 0x146f9(%rip), %r12     # 0x1bfd8
leaq 0xca5c(%rip), %rsi      # 0x14342
movq %r12, %rdi
callq 0x3260
xorl %r14d, %r14d
testl %ebx, %ebx
movl $0x0, %r15d
movl %ebx, 0x10(%rsp)
cmovgl %ebx, %r15d
leaq 0xc328(%rip), %rbx      # 0x13c30
cmpq %r14, %r15
je 0x792a
movq (%r13,%r14,8), %rsi
movq %r12, %rdi
callq 0x3260
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3260
incq %r14
jmp 0x7908
movq %r12, %rdi
callq 0x3140
movl $0x0, 0xc(%rsp)
pushq $0x1
popq %rbp
leaq 0x58(%rsp), %rbx
movl %ebp, %r12d
cmpl 0x10(%rsp), %ebp
jge 0x7f77
movslq %r12d, %r15
movq (%r13,%r15,8), %rsi
movq %rbx, %rdi
leaq 0x78(%rsp), %r14
movq %r14, %rdx
callq 0xe174
movq %rbx, %rdi
leaq 0xc9de(%rip), %rsi      # 0x1434f
callq 0x30c0
testl %eax, %eax
je 0x7a37
movq %rbx, %rdi
leaq 0xc9f0(%rip), %rsi      # 0x14378
callq 0x30c0
testl %eax, %eax
je 0x7ae5
movq %rbx, %rdi
leaq 0xca04(%rip), %rsi      # 0x143a3
callq 0x30c0
testl %eax, %eax
je 0x7b10
movq %rbx, %rdi
leaq 0xca26(%rip), %rsi      # 0x143dc
callq 0x30c0
testl %eax, %eax
je 0x7b5f
movq %rbx, %rdi
leaq 0xca89(%rip), %rsi      # 0x14456
callq 0x30c0
testl %eax, %eax
je 0x7bbc
movq %rbx, %rdi
leaq 0xcb2d(%rip), %rsi      # 0x14511
callq 0x30c0
testl %eax, %eax
je 0x7c86
movq %rbx, %rdi
leaq 0xcb69(%rip), %rsi      # 0x14564
callq 0x30c0
testl %eax, %eax
je 0x7d1e
movq 0x145c9(%rip), %rdi     # 0x1bfd8
leaq 0xcb7e(%rip), %rsi      # 0x14594
callq 0x3260
movq (%r13,%r15,8), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
leaq 0xcb76(%rip), %rsi      # 0x145a8
jmp 0x7afb
movq 0x8(%r13,%r15,8), %rsi
movq %r14, %rdi
leaq 0x280(%rsp), %rdx
callq 0xe174
movq 0x20(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x3120
movq %r14, %rdi
callq 0x32b0
movq (%r15), %rsi
movq %r14, %rdi
pushq $0x8
popq %rdx
callq 0x3180
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x98(%rsp,%rax), %r15d
leaq 0xb93c(%rip), %rsi      # 0x133ce
testl %r15d, %r15d
jne 0x7aa6
movq %r14, %rdi
callq 0x3080
leaq 0xc8b2(%rip), %rsi      # 0x14358
movq 0x1452b(%rip), %rdi     # 0x1bfd8
callq 0x3260
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x3240
movq %rax, %rdi
callq 0x3140
leal 0x1(%r12), %ebp
movq %r14, %rdi
callq 0x30a0
testl %r15d, %r15d
je 0x7f61
xorl %r15d, %r15d
jmp 0x7f66
movq 0x50(%rsp), %rax
movb $0x1, (%rax)
movq 0x144e4(%rip), %rdi     # 0x1bfd8
leaq 0xc884(%rip), %rsi      # 0x1437f
callq 0x3260
movq %rax, %rdi
callq 0x3140
movl %r12d, %ebp
jmp 0x7f61
movq 0x8(%r13,%r15,8), %rdi
callq 0x32e0
movq 0x4c0(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x144ab(%rip), %rdi     # 0x1bfd8
leaq 0xc875(%rip), %rsi      # 0x143a9
callq 0x3260
movq 0x4c0(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x33b0
movq %rax, %rdi
callq 0x3140
leal 0x1(%r12), %ebp
jmp 0x7f61
leal 0x1(%r12), %ebp
movq 0x8(%r13,%r15,8), %rdi
callq 0x32e0
movq 0x4c8(%rsp), %rax
movsd %xmm0, (%rax)
ucomisd 0xb526(%rip), %xmm0     # 0x130a8
jae 0x7c52
movq 0x14449(%rip), %rdi     # 0x1bfd8
leaq 0xc885(%rip), %rsi      # 0x1441b
callq 0x3260
movq 0x4c8(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x33b0
movq %rax, %rdi
callq 0x3140
jmp 0x7add
movq 0x14415(%rip), %rdi     # 0x1bfd8
leaq 0xc895(%rip), %rsi      # 0x1445f
callq 0x3260
leal 0x1(%r12), %ebp
movslq %ebp, %r15
movq (%r13,%r15,8), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x32b0
movq (%r13,%r15,8), %rsi
movq %r14, %rdi
pushq $0x8
popq %rdx
callq 0x3180
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x98(%rsp,%rax), %eax
movl %eax, 0x14(%rsp)
testl %eax, %eax
je 0x7d8a
movq 0x143ac(%rip), %rdi     # 0x1bfd8
leaq 0xc8af(%rip), %rsi      # 0x144e2
callq 0x3260
movq (%r13,%r15,8), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
jmp 0x7f05
movq 0x1437f(%rip), %rdi     # 0x1bfd8
leaq 0xc782(%rip), %rsi      # 0x143e2
callq 0x3260
movq 0x4c8(%rsp), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x33b0
movq %rax, %rdi
callq 0x3140
jmp 0x7f61
movq %r14, %rdi
callq 0x32b0
leal 0x1(%r12), %ebp
movslq %ebp, %r15
movq (%r13,%r15,8), %rsi
leaq 0x280(%rsp), %r14
movq %r14, %rdi
leaq 0x28(%rsp), %rdx
callq 0xe174
movq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x3120
movq (%r13,%r15,8), %rsi
leaq 0x78(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x3180
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x98(%rsp,%rax), %r14d
testl %r14d, %r14d
je 0x7f1c
movq 0x142e0(%rip), %rdi     # 0x1bfd8
leaq 0xc83e(%rip), %rsi      # 0x1453d
callq 0x3260
movq (%r13,%r15,8), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
jmp 0x7f4e
movq 0x8(%r13,%r15,8), %rsi
movq %r14, %rdi
leaq 0x280(%rsp), %rdx
callq 0xe174
movq 0x4d0(%rsp), %rdi
movq %r14, %rsi
callq 0x32d0
movq %r14, %rdi
callq 0x3120
movq 0x14286(%rip), %rdi     # 0x1bfd8
leaq 0xc80e(%rip), %rsi      # 0x14567
callq 0x3260
movq %rax, %rdi
movq 0x4d0(%rsp), %rsi
callq 0x3240
movq %rax, %rdi
leaq 0xc81a(%rip), %rsi      # 0x14592
callq 0x3260
movq %rax, %rdi
callq 0x3140
jmp 0x7b55
xorl %eax, %eax
testl %eax, %eax
jne 0x7ead
leaq 0x28(%rsp), %r14
movq %r14, %rdi
leaq 0xc124(%rip), %rsi      # 0x13ec7
leaq 0x280(%rsp), %rdx
callq 0xe174
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x3070
cmpq $0x0, 0x30(%rsp)
je 0x7e8e
movq 0x28(%rsp), %rax
cmpb $0x23, (%rax)
je 0x7e8e
leaq 0x280(%rsp), %r14
movq %r14, %rdi
callq 0x32b0
movq 0x28(%rsp), %rsi
movq %r14, %rdi
pushq $0x8
popq %rdx
callq 0x3180
incl 0xc(%rsp)
movq 0x280(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x2a0(%rsp,%rax)
je 0x7e65
movq 0x141c0(%rip), %rdi     # 0x1bfd8
leaq 0xc671(%rip), %rsi      # 0x14490
callq 0x3260
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x33f0
movq %rax, %rdi
leaq 0xb7e0(%rip), %rsi      # 0x1361a
callq 0x3260
movq %rax, %rdi
leaq 0xc65e(%rip), %rsi      # 0x144a7
callq 0x3260
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
callq 0x3240
movq %rax, %rdi
callq 0x3140
jmp 0x7e81
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0xe6a2
leaq 0x280(%rsp), %rdi
callq 0x3080
leaq 0x280(%rsp), %rdi
callq 0x30a0
leaq 0x28(%rsp), %rdi
callq 0x3120
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x98(%rsp,%rax), %eax
jmp 0x7d8c
leaq 0x78(%rsp), %rdi
callq 0x3080
movq 0x1411a(%rip), %rdi     # 0x1bfd8
leaq 0xc5ef(%rip), %rsi      # 0x144b4
callq 0x3260
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rsi
subq (%rcx), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x31b0
movq %rax, %rdi
leaq 0xc0b7(%rip), %rsi      # 0x13fa3
callq 0x3260
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x33f0
movq %rax, %rdi
callq 0x3140
leaq 0x78(%rsp), %rdi
callq 0x30a0
cmpl $0x0, 0x14(%rsp)
jne 0x7add
jmp 0x7f61
movq 0x140b5(%rip), %rdi     # 0x1bfd8
leaq 0xc5ee(%rip), %rsi      # 0x14518
callq 0x3260
movq (%r13,%r15,8), %rsi
movq %rax, %rdi
callq 0x3260
movq %rax, %rdi
callq 0x3140
leaq 0x78(%rsp), %rdi
callq 0x3080
leaq 0x78(%rsp), %rdi
callq 0x30a0
testl %r14d, %r14d
jne 0x7add
incl %ebp
movb $0x1, %r15b
movq %rbx, %rdi
callq 0x3120
testb %r15b, %r15b
jne 0x7942
cmpl 0x10(%rsp), %r12d
setge %al
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7fc6
jmp 0x7fcb
jmp 0x7fc6
jmp 0x7fc6
jmp 0x7fcb
jmp 0x7fa3
jmp 0x7fcb
jmp 0x7fc6
jmp 0x7fc6
movq %rax, %rbx
jmp 0x7fba
jmp 0x7fcb
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
callq 0x30a0
leaq 0x28(%rsp), %rdi
callq 0x3120
jmp 0x7fce
movq %rax, %rbx
jmp 0x7fd8
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x30a0
leaq 0x58(%rsp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3410