// File: /workspace/github_cpp_makefile_star2_O1/adamiaonr[P]rid-analytics/src/argvparser.cpp
// Function: CommandLineProcessing::ArgvParser::parse(int, char**)
ArgvParser::ParserResults
ArgvParser::parse(int _argc, char ** _argv)
{
    bool finished_options = false; // flag whether an argument was found (options are passed)

    // loop over all command line arguments
    int i = 1; // argument counter
    while( i< _argc )
    {
        string argument = _argv[i];
        unsigned int key = 0;
        string option; // option name
        string value;  // option value

        // if argument is an option
        if (!isValidOptionString(argument))
        {
            // string is a real argument since values are processed elsewhere
            finished_options=true;
            argument_container.push_back(argument);
        }
        else // can be a long or multiple short options at this point
        {
            // check whether we already found an argument
            if (finished_options)
            {
                error_option = argument;
                return(ParserOptionAfterArgument); // return error code
            }
            // check for long options
            if (isValidLongOptionString(argument))
            {
                // handle long options

                // remove trailing '--'
                argument = argument.substr(2);
                // check for option value assignment 'option=value'
                splitOptionAndValue(argument, option, value);

                if (!isDefinedOption(option)) // is this a known option
                {
                    error_option = option; // store the option that caused the error
                    return(ParserUnknownOption); // return error code if not
                }

                // get the key of this option - now that we know that it is defined
                key = option2key.find(option)->second;
                if (key == help_option) // if help is requested return error code
                    return(ParserHelpRequested);

                // do we need to extract a value
                // AND a value is not already assigned from the previous step
                if ((option2attribute.find(key)->second & OptionRequiresValue) && value.empty())
                {
                    if (i+1 >= _argc) // are there arguments left?
                    {
                        error_option = option; // store the option that caused the error
                        return(ParserMissingValue); // the was no argument left although we need a value
                    }

                    string temp = _argv[i+1]; // get the next element
                    ++i; // increase counter now that we moved forward

                    if (isValidOptionString(temp))
                    {
                        error_option = option; // store the option that caused the error
                        return(ParserMissingValue);  // missing option value
                    }
                    value = temp; // assign value
                }
                // add option-value map entry
                option2value[key] = value;
            }
            else // handle short options
            {
                argument = argument.substr(1);   // remove trailing '-'

                // check for option value assignment 'option=value'
                if (splitOptionAndValue(argument, option, value))
                {
                    // there was an option <- value assignment
                    if (option.length() > 1)
                    {
                        error_option = option; // store the option that caused the error
                        return(ParserMalformedMultipleShortOption); // return error code if option has more than one character
                    }

                    if (!isDefinedOption(option)) // is this a known option
                    {
                        error_option = option; // store the option that caused the error
                        return(ParserUnknownOption); // return error code if not
                    }
                    key = option2key.find(option)->second; // get the key for the extracted option name

                    if (key == help_option) // if help is requested return error code
                        return(ParserHelpRequested);

                    // if value is still empty for some reason: we have an error
                    if ((option2attribute.find(key)->second & OptionRequiresValue) && value.empty())
                    {
                        error_option = option; // store the option that caused the error
                        return(ParserMissingValue);   // missing option value
                    }
                    else
                        // add option-value map entry
                        option2value[key] = value;
                }
                else // no '=' assignment: can be either multiple short options or
                    // something like '-s 4'
                {
                    // handle short options with value like '-s 4'
                    option.clear();
                    value.clear();

                    if (argument.length() == 1) // if a single short option
                    {
                        if (!isDefinedOption(argument)) // is this a known option
                        {
                            error_option = argument; // store the option that caused the error
                            return(ParserUnknownOption); // return error code if not
                        }
                        key = option2key.find(argument)->second; // get the key for the extracted option name

                        if (key == help_option) // if help is requested return error code
                            return(ParserHelpRequested);

                        // check if option needs a value and next arg is not an option
                        if ((option2attribute.find(key)->second & OptionRequiresValue))
                        {
                            if (i+1 >= _argc) // are there arguments left?
                            {
                                error_option = argument; // store the option that caused the error
                                return(ParserMissingValue); // the was no argument left although we need a value
                            }
                            string temp = _argv[i+1]; // get the next element
                            ++i; // increase counter now that we moved forward

                            if (isValidOptionString(temp))
                            {
                                error_option = argument; // store the option that caused the error
                                return(ParserMissingValue);  // missing option value
                            }
                            // add option-value map entry
                            option2value[key] = temp;

                        }
                        else // no value needed
                        {
                            option2value[key] = ""; // assign value
                        }
                    }
                    else // handle multiple short option like '-svxgh'
                    {
                        unsigned int short_option_counter = 0; // position in the multiple short option string
                        while( short_option_counter < argument.length() ) // parse the whole string
                        {
                            option = argument[short_option_counter]; // get the option character

                            if (!isDefinedOption(option)) // is this a known option
                            {
                                error_option = option; // store the option that caused the error
                                return(ParserUnknownOption); // return error code if not
                            }
                            key = option2key.find(option)->second; // get the key for the extracted option name

                            if (key == help_option) // if help is requested return error code
                                return(ParserHelpRequested);

                            option2value[key] = value;

                            ++short_option_counter; // advance one character forward
                        }
                    }
                }
            }
        }
        ++i;
    }

    map<unsigned int, OptionAttributes>::iterator it;
    for( it = option2attribute.begin(); it != option2attribute.end(); it++ )
    {
        // if the current option is required look if we got it
        if (it->second & OptionRequired)
        {
            // is the object missing
            if (option2value.find(it->first) == option2value.end())
            {
                // get the list of alternative names for this option
                list<string> alternatives = getAllOptionAlternatives(it->first);

                unsigned int count = 0;
                for( list<string>::const_iterator alt = alternatives.begin();
                        alt != alternatives.end();
                        ++alt )
                {
                    ++count;
                    // additional '-' for long options
                    if (alt->length() > 1)
                        error_option += "-";

                    error_option += "-" + *alt;

                    // alternatives to come?
                    if (count < alternatives.size())
                        error_option += ", "; // add separator
                }
                return(ParserRequiredOptionMissing);
            }
        }
    }

    return(NoParserError); // everthing went fine -> sucess
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, 0xc0(%rsp)
movl %esi, 0x44(%rsp)
leaq 0xf8(%rdi), %rax
movq %rax, 0xc8(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x10(%rdi), %rax
movq %rax, 0x98(%rsp)
leaq 0x40(%rdi), %rbp
leaq 0x138(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x50(%rsp)
leaq 0x98(%rdi), %rax
movq %rax, 0x48(%rsp)
movl $0x1, %r15d
xorl %r14d, %r14d
leaq 0x78(%rsp), %r12
xorl %r13d, %r13d
movq %rbp, 0xd0(%rsp)
cmpl 0x44(%rsp), %r15d
jge 0x200ea
movslq %r15d, %rax
movq 0xc0(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r12, %rdi
leaq 0x20(%rsp), %rdx
callq 0x21d02
movl $0x0, 0x8(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movb %r14b, 0x30(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %r14, 0xa8(%rsp)
movb %r14b, 0xb0(%rsp)
movq %r12, %rdi
callq 0x2032e
testb %al, %al
je 0x1faab
testb $0x1, %r13b
je 0x1fb3d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4230
movl $0x4, 0x4(%rsp)
xorl %ebp, %ebp
jmp 0x1fac4
movb $0x1, %r13b
movq 0xc8(%rsp), %rdi
movq %r12, %rsi
callq 0x21d40
incl %r15d
movb $0x1, %bpl
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x1fae9
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1fb05
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1fb27
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
movq 0xd0(%rsp), %rbp
jne 0x1fa19
jmp 0x20236
cmpq $0x4, 0x80(%rsp)
jb 0x1fb66
movl $0x2, %edx
movq %r12, %rdi
xorl %esi, %esi
leaq 0x12126(%rip), %rcx     # 0x31c7f
callq 0x44c0
testl %eax, %eax
je 0x1fe3c
movl $0x1, %edx
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x43c0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4460
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fba9
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x203b6
testb %al, %al
je 0x1fbea
cmpq $0x2, 0x28(%rsp)
jb 0x1fcca
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
movl $0x8, 0x4(%rsp)
jmp 0x1faa7
movq %r14, 0x28(%rsp)
movq 0x20(%rsp), %rax
movb %r14b, (%rax)
movq %r14, 0xa8(%rsp)
movq 0xa0(%rsp), %rax
movb %r14b, (%rax)
cmpq $0x1, 0x80(%rsp)
jne 0x1fd84
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x225bc
movq %r12, %rsi
cmpq 0x98(%rsp), %rax
je 0x1fedd
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x2288a
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x50(%rsp), %rcx
cmpl 0x130(%rcx), %eax
je 0x1fed0
movq 0x48(%rcx), %rdx
movq %rbp, %rcx
testq %rdx, %rdx
je 0x1fc82
movq %rbp, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1fc6b
movq %rbp, %rdx
cmpq %rbp, %rcx
je 0x1fc94
cmpl 0x20(%rcx), %eax
cmovbq %rbp, %rcx
movq %rcx, %rdx
testb $0x1, 0x24(%rdx)
jne 0x1ffd7
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21d7e
movq 0x8(%rax), %rdx
movq %rax, %rdi
xorl %esi, %esi
leaq 0x11a3a(%rip), %rcx     # 0x316f7
xorl %r8d, %r8d
callq 0x45e0
jmp 0x1fabe
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x225bc
leaq 0x20(%rsp), %rsi
cmpq 0x98(%rsp), %rax
je 0x1fedd
movq 0x18(%rsp), %rdi
callq 0x2288a
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x50(%rsp), %rcx
cmpl 0x130(%rcx), %eax
je 0x1fed0
movq 0x48(%rcx), %rdx
movq %rbp, %rcx
testq %rdx, %rdx
je 0x1fd34
movq %rbp, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1fd1d
movq %rbp, %rdx
cmpq %rbp, %rcx
je 0x1fd46
cmpl 0x20(%rcx), %eax
cmovbq %rbp, %rcx
movq %rcx, %rdx
testb $0x1, 0x24(%rdx)
je 0x1fd60
cmpq $0x0, 0xa8(%rsp)
leaq 0x20(%rsp), %rsi
je 0x2002a
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21d7e
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4230
jmp 0x1fabe
cmpq $0x0, 0x80(%rsp)
setne %bpl
je 0x1ffc8
movl $0x1, %ebx
xorl %eax, %eax
movq 0x78(%rsp), %rcx
movsbl (%rcx,%rax), %r8d
movq 0x28(%rsp), %rdx
movl $0x1, %ecx
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x4730
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x225bc
cmpq 0x98(%rsp), %rax
je 0x1ffa7
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2288a
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x50(%rsp), %rcx
cmpl 0x130(%rcx), %eax
je 0x1ffc0
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21d7e
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4230
movl %ebx, %eax
incl %ebx
cmpq %rax, 0x80(%rsp)
seta %bpl
ja 0x1fd9e
jmp 0x1ffc8
movl $0x2, %edx
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x43c0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4460
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fe7f
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x203b6
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x225bc
leaq 0x20(%rsp), %rsi
cmpq 0x98(%rsp), %rax
je 0x1fedd
movq 0x18(%rsp), %rdi
callq 0x2288a
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x50(%rsp), %rcx
cmpl 0x130(%rcx), %eax
jne 0x1fef4
movl $0x32, 0x4(%rsp)
jmp 0x1faa7
movq 0x10(%rsp), %rdi
callq 0x4230
movl $0x1, 0x4(%rsp)
jmp 0x1faa7
movq 0x48(%rcx), %rdx
movq %rbp, %rcx
testq %rdx, %rdx
je 0x1ff1a
movq %rbp, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1ff03
movq %rbp, %rdx
cmpq %rbp, %rcx
je 0x1ff2c
cmpl 0x20(%rcx), %eax
cmovbq %rbp, %rcx
movq %rcx, %rdx
testb $0x1, 0x24(%rdx)
je 0x200c6
cmpq $0x0, 0xa8(%rsp)
jne 0x200c6
leal 0x1(%r15), %ebx
leaq 0x20(%rsp), %rsi
cmpl 0x44(%rsp), %ebx
jge 0x2002a
movslq %ebx, %rax
movq 0xc0(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x58(%rsp), %r15
movq %r15, %rdi
leaq 0xf(%rsp), %rdx
callq 0x21d02
movq %r15, %rdi
callq 0x2032e
movl %eax, %ebp
testb %al, %al
je 0x20086
movl $0x2, 0x4(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
jmp 0x20098
movl $0x1, 0x4(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
jmp 0x1ffc8
movl $0x32, 0x4(%rsp)
testb $0x1, %bpl
jne 0x1faa7
jmp 0x1fabe
leal 0x1(%r15), %ebx
movq %r12, %rsi
cmpl 0x44(%rsp), %ebx
jge 0x2002a
movslq %ebx, %rax
movq 0xc0(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x58(%rsp), %r15
movq %r15, %rdi
leaq 0xf(%rsp), %rdx
callq 0x21d02
movq %r15, %rdi
callq 0x2032e
movl %eax, %ebp
testb %al, %al
je 0x20041
movl $0x2, 0x4(%rsp)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4230
jmp 0x2005d
movq 0x10(%rsp), %rdi
callq 0x4230
movl $0x2, 0x4(%rsp)
jmp 0x1faa7
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21d7e
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x4230
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x20079
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
jne 0x200b9
movl %ebx, %r15d
jmp 0x1fabe
leaq 0xa0(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x4230
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x200b4
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bpl, %bpl
je 0x200c3
xorl %ebp, %ebp
movl %ebx, %r15d
jmp 0x1fac4
movl %ebx, %r15d
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21d7e
movq %rax, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x4230
jmp 0x1fabe
movq 0x50(%rsp), %r12
movq 0x50(%r12), %rax
leaq 0x40(%r12), %rbx
cmpq %rbx, %rax
je 0x20163
movq 0xa8(%r12), %r14
leaq 0xa0(%r12), %r15
testb $0x2, 0x24(%rax)
je 0x20156
movq %r15, %rcx
testq %r14, %r14
je 0x2013c
movl 0x20(%rax), %edx
movq %r14, %rsi
movq %r15, %rcx
xorl %edi, %edi
cmpl %edx, 0x20(%rsi)
setb %dil
cmovaeq %rsi, %rcx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x20125
movq %r15, %rdx
cmpq %r15, %rcx
je 0x20151
movl 0x20(%rax), %edx
cmpl 0x20(%rcx), %edx
cmovbq %r15, %rcx
movq %rcx, %rdx
cmpq %r15, %rdx
je 0x20170
movq %rax, %rdi
callq 0x42b0
cmpq %rbx, %rax
jne 0x2010e
movl $0x0, 0x4(%rsp)
jmp 0x20236
movl 0x20(%rax), %edx
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x20490
movq (%rbx), %r13
cmpq %rbx, %r13
je 0x20224
movl $0x1, %ebp
leaq 0x11ae5(%rip), %r14     # 0x31c80
leaq 0x78(%rsp), %r15
leaq 0x11561(%rip), %r12     # 0x31708
cmpq $0x2, 0x18(%r13)
jb 0x201bb
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4760
leaq 0x10(%r13), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x21de2
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x10(%rsp), %rdi
callq 0x4150
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x20203
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43a0
movl %ebp, %eax
cmpq %rax, 0x30(%rsp)
jbe 0x20219
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4760
movq (%r13), %r13
incl %ebp
cmpq %rbx, %r13
jne 0x201a7
leaq 0x20(%rsp), %rdi
callq 0x2246c
movl $0x16, 0x4(%rsp)
movl 0x4(%rsp), %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x202c0
jmp 0x202c0
jmp 0x20252
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x202c3
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x202c3
jmp 0x202c0
jmp 0x202c0
jmp 0x202c0
jmp 0x202c0
jmp 0x202c0
jmp 0x202a6
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x202a9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x202a9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2246c
jmp 0x20326
jmp 0x202c0
jmp 0x202c0
movq %rax, %rbx
jmp 0x20326
jmp 0x202c0
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x202e8
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x20304
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x20326
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %rbx, %rdi
callq 0x4700