// File: /workspace/github_cpp_makefile_star2_O3/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, 0xc8(%rsp)
movl %esi, 0x44(%rsp)
leaq 0xf8(%rdi), %rax
movq %rax, 0xd0(%rsp)
leaq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x10(%rdi), %rax
movq %rax, 0x80(%rsp)
leaq 0x40(%rdi), %rax
movq %rax, 0x78(%rsp)
leaq 0x138(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x48(%rsp)
leaq 0x98(%rdi), %rax
movq %rax, 0x50(%rsp)
movl $0x1, %r15d
xorl %r13d, %r13d
leaq 0xa8(%rsp), %r12
xorl %ebp, %ebp
cmpl 0x44(%rsp), %r15d
jge 0x1fc3e
movslq %r15d, %rax
movq 0xc8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %r12, %rdi
leaq 0x20(%rsp), %rdx
callq 0x2182c
movl $0x0, 0x8(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r13, 0x28(%rsp)
movb %r13b, 0x30(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %r13, 0x90(%rsp)
movb %r13b, 0x98(%rsp)
movq %r12, %rdi
callq 0x1fe7c
movl %eax, %r14d
testb %al, %al
je 0x1f60d
testb $0x1, %bpl
je 0x1f62e
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4230
movl $0x4, 0x4(%rsp)
movb $0x1, %bpl
xorl %ebx, %ebx
jmp 0x1f943
movq 0xd0(%rsp), %rdi
movq %r12, %rsi
callq 0x2186a
xorb $0x1, %r14b
incl %r15d
movb $0x1, %bl
movl %r14d, %ebp
jmp 0x1f943
cmpq $0x4, 0xb0(%rsp)
jb 0x1f657
movl $0x2, %edx
movq %r12, %rdi
xorl %esi, %esi
leaq 0x11415(%rip), %rcx     # 0x30a5f
callq 0x44c0
testl %eax, %eax
je 0x1f88b
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 0x1f69a
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x1ff04
testb %al, %al
je 0x1f6db
cmpq $0x2, 0x28(%rsp)
jb 0x1f7cc
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
movl $0x8, 0x4(%rsp)
jmp 0x1f93f
movq %r13, 0x28(%rsp)
movq 0x20(%rsp), %rax
movb %r13b, (%rax)
movq %r13, 0x90(%rsp)
movq 0x88(%rsp), %rax
movb %r13b, (%rax)
movq 0xb0(%rsp), %rax
testq %rax, %rax
je 0x1f61d
cmpq $0x1, %rax
jne 0x1f9b6
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x220fc
movq %r12, %rsi
cmpq 0x80(%rsp), %rax
je 0x1f92d
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x22392
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x48(%rsp), %rcx
cmpl 0x130(%rcx), %eax
je 0x1f923
movq 0x48(%rcx), %rdx
movq 0x78(%rsp), %rdi
movq %rdi, %rsi
testq %rdx, %rdx
je 0x1f796
movq %rdi, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1f76d
movq %rdi, %rsi
cmpq %rdi, %rcx
je 0x1f796
cmpl 0x20(%rcx), %eax
cmovbq %rdi, %rcx
movq %rcx, %rsi
testb $0x1, 0x24(%rsi)
jne 0x1fb26
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x218a8
movq 0x8(%rax), %rdx
movq %rax, %rdi
xorl %esi, %esi
leaq 0x10d18(%rip), %rcx     # 0x304d7
xorl %r8d, %r8d
callq 0x45e0
jmp 0x1f61d
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x220fc
leaq 0x20(%rsp), %rsi
cmpq 0x80(%rsp), %rax
je 0x1f92d
movq 0x18(%rsp), %rdi
callq 0x22392
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x48(%rsp), %rcx
cmpl 0x130(%rcx), %eax
je 0x1f923
movq 0x48(%rcx), %rdx
movq 0x78(%rsp), %rdi
movq %rdi, %rsi
testq %rdx, %rdx
je 0x1f84d
movq %rdi, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1f824
movq %rdi, %rsi
cmpq %rdi, %rcx
je 0x1f84d
cmpl 0x20(%rcx), %eax
cmovbq %rdi, %rcx
movq %rcx, %rsi
testb $0x1, 0x24(%rsi)
je 0x1f867
cmpq $0x0, 0x90(%rsp)
leaq 0x20(%rsp), %rsi
je 0x1fb80
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x218a8
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0x4230
jmp 0x1f61d
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 0x1f8ce
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x1ff04
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x220fc
leaq 0x20(%rsp), %rsi
cmpq 0x80(%rsp), %rax
je 0x1f92d
movq 0x18(%rsp), %rdi
callq 0x22392
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x48(%rsp), %rcx
cmpl 0x130(%rcx), %eax
jne 0x1fa5a
movl $0x32, 0x4(%rsp)
jmp 0x1f93f
movq 0x10(%rsp), %rdi
callq 0x4230
movl $0x1, 0x4(%rsp)
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x1f968
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1f984
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1f9a9
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bl, %bl
jne 0x1f576
jmp 0x1fd7e
movl $0x1, %ebx
xorl %eax, %eax
movq 0x48(%rsp), %rbp
movq 0xa8(%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 0x220fc
cmpq 0x80(%rsp), %rax
je 0x1fb12
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x22392
movl 0x40(%rax), %eax
movl %eax, 0x8(%rsp)
cmpl 0x130(%rbp), %eax
je 0x1f923
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x218a8
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0x4230
movl %ebx, %eax
incl %ebx
cmpq %rax, 0xb0(%rsp)
ja 0x1f9c2
jmp 0x1f61d
movq 0x48(%rcx), %rdx
movq 0x78(%rsp), %rdi
movq %rdi, %rsi
testq %rdx, %rdx
je 0x1fa97
movq %rdi, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x1fa6e
movq %rdi, %rsi
cmpq %rdi, %rcx
je 0x1fa97
cmpl 0x20(%rcx), %eax
cmovbq %rdi, %rcx
movq %rcx, %rsi
testb $0x1, 0x24(%rsi)
je 0x1fbcc
cmpq $0x0, 0x90(%rsp)
jne 0x1fbcc
leal 0x1(%r15), %ebp
leaq 0x20(%rsp), %rsi
cmpl 0x44(%rsp), %ebp
jge 0x1fb80
movslq %ebp, %rax
movq 0xc8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf(%rsp), %rdx
callq 0x2182c
movq %rbx, %rdi
callq 0x1fe7c
movl %eax, %ebx
testb %al, %al
je 0x1fb97
movl $0x2, 0x4(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
jmp 0x1fba9
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x4230
jmp 0x1f937
leal 0x1(%r15), %ebp
movq %r12, %rsi
cmpl 0x44(%rsp), %ebp
jge 0x1fb80
movslq %ebp, %rax
movq 0xc8(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
leaq 0xf(%rsp), %rdx
callq 0x2182c
movq %rbx, %rdi
callq 0x1fe7c
movl %eax, %ebx
testb %al, %al
je 0x1fbf0
movl $0x2, 0x4(%rsp)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4230
jmp 0x1fc0c
movq 0x10(%rsp), %rdi
callq 0x4230
movl $0x2, 0x4(%rsp)
jmp 0x1f93f
leaq 0x88(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x4230
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fbc5
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bl, %bl
jne 0x1fc2c
movl %ebp, %r15d
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x218a8
movq %rax, %rdi
leaq 0x88(%rsp), %rsi
callq 0x4230
jmp 0x1f61d
movq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x218a8
movq %rax, %rdi
leaq 0x58(%rsp), %rsi
callq 0x4230
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fc28
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bl, %bl
je 0x1fc36
xorl %ebx, %ebx
movl %ebp, %r15d
jmp 0x1f941
movl %ebp, %r15d
jmp 0x1f61d
movq 0x48(%rsp), %r15
movq 0x50(%r15), %rax
movq 0x78(%rsp), %r12
cmpq %r12, %rax
je 0x1fca1
movq 0xa8(%r15), %rbx
leaq 0xa0(%r15), %r14
testb $0x2, 0x24(%rax)
je 0x1fc94
movl 0x20(%rax), %edx
testq %rbx, %rbx
je 0x1fcae
movq %rbx, %rsi
movq %r14, %rcx
xorl %edi, %edi
cmpl %edx, 0x20(%rsi)
setb %dil
cmovaeq %rsi, %rcx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x1fc73
cmpq %r14, %rcx
je 0x1fcae
cmpl 0x20(%rcx), %edx
jb 0x1fcae
movq %rax, %rdi
callq 0x42b0
cmpq %r12, %rax
jne 0x1fc5f
movl $0x0, 0x4(%rsp)
jmp 0x1fd7e
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1ffde
movq (%rbx), %r13
cmpq %rbx, %r13
je 0x1fd6c
movl $0x1, %ebp
leaq 0x10d8a(%rip), %r14     # 0x30a60
leaq 0xa8(%rsp), %r15
leaq 0x10803(%rip), %r12     # 0x304e8
cmpq $0x2, 0x18(%r13)
jb 0x1fcf9
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x4760
leaq 0x10(%r13), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2190d
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq 0x10(%rsp), %rdi
callq 0x4150
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1fd47
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movl %ebp, %eax
cmpq %rax, 0x30(%rsp)
jbe 0x1fd5d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x4760
movq (%r13), %r13
incl %ebp
cmpq %rbx, %r13
jne 0x1fce5
leaq 0x20(%rsp), %rdi
callq 0x21fac
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 0x1fe0b
jmp 0x1fe0b
jmp 0x1fd9a
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fe0e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x1fe0e
jmp 0x1fe0b
jmp 0x1fe0b
jmp 0x1fe0b
jmp 0x1fe0b
jmp 0x1fe0b
jmp 0x1fe0b
jmp 0x1fdf3
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1fdf6
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x1fdf6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x21fac
jmp 0x1fe74
jmp 0x1fe0b
movq %rax, %rbx
jmp 0x1fe74
jmp 0x1fe0b
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x1fe33
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x1fe4f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x1fe74
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %rbx, %rdi
callq 0x4700