// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/utils/bamtools_options.cpp
// Function: BamTools::Options::Parse(int, char**, int)
void Options::Parse(int argc, char* argv[], int offset) {

    // initialize
    map<string, OptionValue>::const_iterator ovMapIter;
    map<string, OptionValue>::const_iterator checkMapIter;
    const int LAST_INDEX = argc - 1;
    ostringstream errorBuilder;
    bool foundError = false;
    char* end_ptr = NULL;
    const string ERROR_SPACER(7, ' ');

    // check if we should show the help menu
    bool showHelpMenu = false;
    if (argc > 1) {
        for (int i = 1; i < argc; i++) {
            const std::string argument = argv[i];
            if ( (argument == "-h") || (argument == "--help") || (argument == "help") ) 
                showHelpMenu = true;
        }
    } else showHelpMenu = true;

    if (showHelpMenu) 
        DisplayHelp();

    // check each argument
    for (int i = offset+1; i < argc; i++) {
      
        const string argument = argv[i];
        ovMapIter = m_optionsMap.find(argument);

        if (ovMapIter == m_optionsMap.end()) {
            errorBuilder << ERROR_SPACER << "An unrecognized argument was found: " << argument << std::endl;
            foundError = true;
        } else {

            *ovMapIter->second.pFoundArgument = true;

            // grab the value
            if (ovMapIter->second.StoreValue) {

                if (i < LAST_INDEX) {

                    // check if the next argument is really a command line option
                    const string val = argv[i + 1]; 
                    checkMapIter = m_optionsMap.find(val);

                    if (checkMapIter == m_optionsMap.end()) {
                        
                        ++i;
                        
                        if (ovMapIter->second.VariantValue.is_type<unsigned int>()) {
                            const unsigned int uint32 = (unsigned int)strtoul(val.c_str(), &end_ptr, 10);
                            unsigned int* varValue = (unsigned int*)ovMapIter->second.pValue;
                            *varValue = uint32;
                        } else if (ovMapIter->second.VariantValue.is_type<unsigned char>()) {
                            const unsigned char uint8 = (unsigned char)strtoul(val.c_str(), &end_ptr, 10);
                            unsigned char* varValue = (unsigned char*)ovMapIter->second.pValue;
                            *varValue = uint8;
                        } else if (ovMapIter->second.VariantValue.is_type<uint64_t>()) {
                            const uint64_t uint64 = strtoui64(val.c_str(), &end_ptr, 10);
                            uint64_t* varValue = (uint64_t*)ovMapIter->second.pValue;
                            *varValue = uint64;
                        } else if (ovMapIter->second.VariantValue.is_type<double>()) {
                            const double d = strtod(val.c_str(), &end_ptr);
                            double* varValue = (double*)ovMapIter->second.pValue;
                            *varValue = d;
                        } else if (ovMapIter->second.VariantValue.is_type<float>()) {
                            const float f = (float)strtod(val.c_str(), &end_ptr);
                            float* varValue = (float*)ovMapIter->second.pValue;
                            *varValue = f;
                        } else if (ovMapIter->second.VariantValue.is_type<string>()) {
                            string* pStringValue = (string*)ovMapIter->second.pValue;
                            *pStringValue = val;
                        } else if (ovMapIter->second.VariantValue.is_type<vector<string> >()) {
                            vector<string>* pVectorValue = (vector<string>*)ovMapIter->second.pValue;
                            pVectorValue->push_back(val);
                        } else {
                            printf("ERROR: Found an unsupported data type for argument %s when parsing the arguments.\n",
                                   argument.c_str());
                            exit(1);
                        }
                    } else {
                        errorBuilder << ERROR_SPACER << "The argument (" << argument
                                     << ") expects a value, but none was found." << endl;
                        foundError = true;
                    }
                } else {
                    errorBuilder << ERROR_SPACER << "The argument (" << argument
                                 << ") expects a value, but none was found." << endl;
                    foundError = true;
                }
            }
        }
    }

    // check if we missed any required parameters
    for (ovMapIter = m_optionsMap.begin(); ovMapIter != m_optionsMap.end(); ++ovMapIter) {
        if (ovMapIter->second.IsRequired && !*ovMapIter->second.pFoundArgument) {
            errorBuilder << ERROR_SPACER << ovMapIter->second.ValueTypeDescription
                         << " was not specified. Please use the " << ovMapIter->first << " parameter." << endl;
            foundError = true;
        }
    }

    // print the errors if any were found
    if (foundError) {
        printf("ERROR: Some problems were encountered when parsing the command line options:\n");
        printf("%s\n", errorBuilder.str().c_str());
        printf("For a complete list of command line options, type \"%s help %s\"\n", argv[0], argv[1]);
        exit(1);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movl %edx, %ebp
movq %rsi, 0x10(%rsp)
movl %edi, %ebx
leaq 0x90(%rsp), %rdi
callq 0x357f0
andq $0x0, 0x8(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x50(%rsp), %rdi
pushq $0x7
popq %rsi
pushq $0x20
popq %rdx
callq 0x356c0
cmpl $0x2, %ebx
jl 0x65d9a
leal -0x1(%rbx), %eax
movl %eax, 0x24(%rsp)
movq %rbx, 0x48(%rsp)
movl %ebx, %ebx
pushq $0x1
popq %r14
xorl %r12d, %r12d
leaq 0x70(%rsp), %r15
leaq 0xfcb4(%rip), %r13      # 0x7567e
cmpq %r14, %rbx
je 0x65a2a
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rsi
movq %r15, %rdi
leaq 0x28(%rsp), %rdx
callq 0x35280
movq %r15, %rdi
movq %r13, %rsi
callq 0x43e87
testb %al, %al
jne 0x65a1a
movq %r15, %rdi
leaq 0xfc79(%rip), %rsi      # 0x75677
callq 0x43e87
testb %al, %al
jne 0x65a1a
movq %r15, %rdi
leaq 0xfc68(%rip), %rsi      # 0x75679
callq 0x43e87
testb %al, %al
je 0x65a1d
movb $0x1, %r12b
movq %r15, %rdi
callq 0x35730
incq %r14
jmp 0x659ca
testb $0x1, %r12b
jne 0x65d9a
xorl %ebx, %ebx
leaq 0x70(%rsp), %r15
leaq 0x30c56(%rip), %rax     # 0x96698
addq $0x8, %rax
movq %rax, 0x18(%rsp)
leal 0x1(%rbp), %r13d
cmpl 0x48(%rsp), %r13d
jge 0x65cdf
movslq %r13d, %rax
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r15, %rdi
leaq 0x28(%rsp), %rdx
callq 0x35280
leaq 0x30c1e(%rip), %rdi     # 0x96698
movq %r15, %rsi
callq 0x6664c
movq %rax, %r12
cmpq 0x18(%rsp), %rax
je 0x65b35
movq 0x40(%r12), %rax
movb $0x1, (%rax)
cmpb $0x1, 0x71(%r12)
jne 0x65ccf
cmpl 0x24(%rsp), %r13d
jge 0x65b63
movslq %ebp, %rax
movq 0x10(%rsp), %rcx
movq 0x10(%rcx,%rax,8), %rsi
leaq 0x28(%rsp), %r14
movq %r14, %rdi
leaq 0x7(%rsp), %rdx
callq 0x35280
leaq 0x30bc3(%rip), %rdi     # 0x96698
movq %r14, %rsi
callq 0x6664c
cmpq 0x18(%rsp), %rax
je 0x65bad
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x35510
movq %rax, %rdi
leaq 0x1046d(%rip), %rsi     # 0x75f71
callq 0x355b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x35510
movq %rax, %rdi
leaq 0x10462(%rip), %rsi     # 0x75f80
callq 0x355b0
movb $0x1, %bl
movq %rax, %rdi
callq 0x35300
movl %r13d, %ebp
jmp 0x65cc2
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x35510
movq %rax, %rdi
leaq 0x103a8(%rip), %rsi     # 0x75ef9
callq 0x355b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x35510
jmp 0x65b9e
leaq 0x90(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x35510
movq %rax, %rdi
leaq 0x103f2(%rip), %rsi     # 0x75f71
callq 0x355b0
movq %rax, %rdi
movq %r15, %rsi
callq 0x35510
movq %rax, %rdi
leaq 0x103e7(%rip), %rsi     # 0x75f80
callq 0x355b0
movb $0x1, %bl
movq %rax, %rdi
callq 0x35300
jmp 0x65ccf
movq %r12, %r13
addq $0x78, %r13
movq %r13, %rdi
callq 0x49790
addl $0x2, %ebp
testb %al, %al
je 0x65be1
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x35210
movq 0x48(%r12), %rcx
movl %eax, (%rcx)
jmp 0x65cc2
movq %r13, %rdi
callq 0x65f86
testb %al, %al
je 0x65c0b
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x35210
movq 0x48(%r12), %rcx
movb %al, (%rcx)
jmp 0x65cc2
movq %r13, %rdi
callq 0x66016
testb %al, %al
je 0x65c36
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0xa
popq %rdx
callq 0x357d0
movq 0x48(%r12), %rcx
movq %rax, (%rcx)
jmp 0x65cc2
movq %r13, %rdi
callq 0x65fc6
testb %al, %al
je 0x65c5c
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x354a0
movq 0x48(%r12), %rax
movsd %xmm0, (%rax)
jmp 0x65cc2
movq %r13, %rdi
callq 0x4ae32
testb %al, %al
je 0x65c86
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x354a0
cvtsd2ss %xmm0, %xmm0
movq 0x48(%r12), %rax
movss %xmm0, (%rax)
jmp 0x65cc2
movq %r13, %rdi
callq 0x43ec6
testb %al, %al
je 0x65ca3
movq 0x48(%r12), %rdi
leaq 0x28(%rsp), %rsi
callq 0x35340
jmp 0x65cc2
movq %r13, %rdi
callq 0x66038
testb %al, %al
je 0x65df4
movq 0x48(%r12), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3a16c
leaq 0x28(%rsp), %rdi
callq 0x35730
movl %ebp, %r13d
movq %r15, %rdi
callq 0x35730
movl %r13d, %ebp
jmp 0x65a4b
leaq 0x309b2(%rip), %rax     # 0x96698
movq 0x18(%rax), %r13
leaq 0x90(%rsp), %r14
leaq 0x50(%rsp), %r15
leaq 0x102a9(%rip), %r12     # 0x75fa7
leaq 0x102c6(%rip), %rbp     # 0x75fcb
cmpq 0x18(%rsp), %r13
je 0x65d6c
cmpb $0x1, 0x72(%r13)
jne 0x65d5f
movq 0x40(%r13), %rax
cmpb $0x0, (%rax)
jne 0x65d5f
movq %r14, %rdi
movq %r15, %rsi
callq 0x35510
leaq 0x50(%r13), %rsi
movq %rax, %rdi
callq 0x35510
movq %rax, %rdi
movq %r12, %rsi
callq 0x355b0
leaq 0x20(%r13), %rsi
movq %rax, %rdi
callq 0x35510
movq %rax, %rdi
movq %rbp, %rsi
callq 0x355b0
movb $0x1, %bl
movq %rax, %rdi
callq 0x35300
movq %r13, %rdi
callq 0x356b0
movq %rax, %r13
jmp 0x65d05
testb $0x1, %bl
jne 0x65d9f
leaq 0x50(%rsp), %rdi
callq 0x35730
leaq 0x90(%rsp), %rdi
callq 0x35160
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6547e
leaq 0x102b0(%rip), %rdi     # 0x76056
callq 0x35910
leaq 0x98(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x359c0
leaq 0x70(%rsp), %r14
movq (%r14), %rdi
callq 0x35910
movq %r14, %rdi
callq 0x35cc8
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0x101f2(%rip), %rdi     # 0x75fd7
xorl %eax, %eax
callq 0x35060
pushq $0x1
popq %rdi
callq 0x35720
movq 0x70(%rsp), %rsi
leaq 0x1011e(%rip), %rdi     # 0x75f1e
xorl %eax, %eax
callq 0x35060
jmp 0x65dec
jmp 0x65e1e
jmp 0x65e1e
jmp 0x65e37
jmp 0x65e11
movq %rax, %rbx
jmp 0x65e62
jmp 0x65e37
jmp 0x65e1e
jmp 0x65e4b
jmp 0x65e4b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x35730
jmp 0x65e4e
jmp 0x65e4b
jmp 0x65e37
jmp 0x65e37
jmp 0x65e37
jmp 0x65e37
movq %rax, %rbx
jmp 0x65e58
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x35730
jmp 0x65e58
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x35730
leaq 0x50(%rsp), %rdi
callq 0x35730
leaq 0x90(%rsp), %rdi
callq 0x35160
movq %rbx, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198
nop