// File: /workspace/github_cpp_makefile_star2_O1/jaudoux[P]countTags/src/optionparser.h
// Function: option::Parser::workhorse(bool, option::Descriptor const*, int, char const**, option::Parser::Action&, bool, bool, int)
inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, const char** args, Action& action,
                              bool single_minus_longopt, bool print_errors, int min_abbr_len)
{
  // protect against NULL pointer
  if (args == 0)
    numargs = 0;

  int nonops = 0;

  while (numargs != 0 && *args != 0)
  {
    const char* param = *args; // param can be --long-option, -srto or non-option argument

    // in POSIX mode the first non-option argument terminates the option list
    // a lone minus character is a non-option argument
    if (param[0] != '-' || param[1] == 0)
    {
      if (gnu)
      {
        ++nonops;
        ++args;
        if (numargs > 0)
          --numargs;
        continue;
      }
      else
        break;
    }

    // -- terminates the option list. The -- itself is skipped.
    if (param[1] == '-' && param[2] == 0)
    {
      shift(args, nonops);
      ++args;
      if (numargs > 0)
        --numargs;
      break;
    }

    bool handle_short_options;
    const char* longopt_name;
    if (param[1] == '-') // if --long-option
    {
      handle_short_options = false;
      longopt_name = param + 2;
    }
    else
    {
      handle_short_options = true;
      longopt_name = param + 1; //for testing a potential -long-option
    }

    bool try_single_minus_longopt = single_minus_longopt;
    bool have_more_args = (numargs > 1 || numargs < 0); // is referencing argv[1] valid?

    do // loop over short options in group, for long options the body is executed only once
    {
      int idx;

      const char* optarg;

      /******************** long option **********************/
      if (handle_short_options == false || try_single_minus_longopt)
      {
        idx = 0;
        while (usage[idx].longopt != 0 && !streq(usage[idx].longopt, longopt_name))
          ++idx;

        if (usage[idx].longopt == 0 && min_abbr_len > 0) // if we should try to match abbreviated long options
        {
          int i1 = 0;
          while (usage[i1].longopt != 0 && !streqabbr(usage[i1].longopt, longopt_name, min_abbr_len))
            ++i1;
          if (usage[i1].longopt != 0)
          { // now test if the match is unambiguous by checking for another match
            int i2 = i1 + 1;
            while (usage[i2].longopt != 0 && !streqabbr(usage[i2].longopt, longopt_name, min_abbr_len))
              ++i2;

            if (usage[i2].longopt == 0) // if there was no second match it's unambiguous, so accept i1 as idx
              idx = i1;
          }
        }

        // if we found something, disable handle_short_options (only relevant if single_minus_longopt)
        if (usage[idx].longopt != 0)
          handle_short_options = false;

        try_single_minus_longopt = false; // prevent looking for longopt in the middle of shortopt group

        optarg = longopt_name;
        while (*optarg != 0 && *optarg != '=')
          ++optarg;
        if (*optarg == '=') // attached argument
          ++optarg;
        else
          // possibly detached argument
          optarg = (have_more_args ? args[1] : 0);
      }

      /************************ short option ***********************************/
      if (handle_short_options)
      {
        if (*++param == 0) // point at the 1st/next option character
          break; // end of short option group

        idx = 0;
        while (usage[idx].shortopt != 0 && !instr(*param, usage[idx].shortopt))
          ++idx;

        if (param[1] == 0) // if the potential argument is separate
          optarg = (have_more_args ? args[1] : 0);
        else
          // if the potential argument is attached
          optarg = param + 1;
      }

      const Descriptor* descriptor = &usage[idx];

      if (descriptor->shortopt == 0) /**************  unknown option ********************/
      {
        // look for dummy entry (shortopt == "" and longopt == "") to use as Descriptor for unknown options
        idx = 0;
        while (usage[idx].shortopt != 0 && (usage[idx].shortopt[0] != 0 || usage[idx].longopt[0] != 0))
          ++idx;
        descriptor = (usage[idx].shortopt == 0 ? 0 : &usage[idx]);
      }

      if (descriptor != 0)
      {
        Option option(descriptor, param, optarg);
        switch (descriptor->check_arg(option, print_errors))
        {
          case ARG_ILLEGAL:
            return false; // fatal
          case ARG_OK:
            // skip one element of the argument vector, if it's a separated argument
            if (optarg != 0 && have_more_args && optarg == args[1])
            {
              shift(args, nonops);
              if (numargs > 0)
                --numargs;
              ++args;
            }

            // No further short options are possible after an argument
            handle_short_options = false;

            break;
          case ARG_IGNORE:
          case ARG_NONE:
            option.arg = 0;
            break;
        }

        if (!action.perform(option))
          return false;
      }

    } while (handle_short_options);

    shift(args, nonops);
    ++args;
    if (numargs > 0)
      --numargs;

  } // while

  if (numargs > 0 && *args == 0) // It's a bug in the caller if numargs is greater than the actual number
    numargs = 0; // of arguments, but as a service to the user we fix this if we spot it.

  if (numargs < 0) // if we don't know the number of remaining non-option arguments
  { // we need to count them
    numargs = 0;
    while (args[numargs] != 0)
      ++numargs;
  }

  return action.finished(numargs + nonops, args - nonops);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %r9d, 0x3c(%rsp)
movq %r8, 0x50(%rsp)
movq %rsi, %rbp
testq %rcx, %rcx
sete %al
testl %edx, %edx
sete %sil
orb %al, %sil
je 0x389b
xorl %edx, %edx
xorl %r8d, %r8d
jmp 0x3d5b
leaq 0x10(%rbp), %rax
movq %rax, 0x58(%rsp)
leaq 0x38(%rbp), %rax
movq %rax, 0x48(%rsp)
xorl %r8d, %r8d
movl %edi, 0x24(%rsp)
movq %rbp, 0x28(%rsp)
movq (%rcx), %r15
testq %r15, %r15
je 0x3d5b
cmpb $0x2d, (%r15)
jne 0x38d9
movzbl 0x1(%r15), %eax
cmpl $0x2d, %eax
je 0x3901
testl %eax, %eax
jne 0x390c
movl $0x3, %eax
testb %dil, %dil
je 0x3d01
incl %r8d
addq $0x8, %rcx
xorl %eax, %eax
testl %edx, %edx
setg %al
subl %eax, %edx
movl $0x2, %eax
jmp 0x3d01
cmpb $0x0, 0x2(%r15)
je 0x3d14
movq %rcx, 0x18(%rsp)
leaq 0x1(%r15), %rcx
leaq 0x2(%r15), %r14
cmpb $0x2d, %al
setne %r9b
cmovneq %rcx, %r14
movl %r8d, 0x10(%rsp)
movl %r8d, %eax
negl %eax
cltq
movq %rax, 0x40(%rsp)
leaq 0x1(%r14), %rax
movq %rax, 0x60(%rsp)
movl %edx, 0x14(%rsp)
movl %edx, 0xc(%rsp)
movl 0x3c(%rsp), %eax
movq %rax, 0x30(%rsp)
testb $0x1, %r9b
je 0x395f
testb $0x1, 0x30(%rsp)
je 0x3acd
movq 0x10(%rbp), %rdx
testq %rdx, %rdx
sete %al
je 0x39b4
xorl %ecx, %ecx
xorl %ebx, %ebx
movq 0x58(%rsp), %r13
xorl %esi, %esi
movb (%rdx,%rsi), %dil
testb %dil, %dil
je 0x398e
leaq 0x1(%rsi), %r8
cmpb (%r14,%rsi), %dil
movq %r8, %rsi
je 0x3976
jmp 0x399c
movzbl (%r14,%rsi), %edx
testl %edx, %edx
je 0x39bd
cmpl $0x3d, %edx
je 0x39bd
incl %ebx
leaq (%rcx,%rcx,4), %rax
incq %rcx
movq 0x38(%rbp,%rax,8), %rdx
testq %rdx, %rdx
sete %al
jne 0x3974
jmp 0x39bf
xorl %ebx, %ebx
movq 0x58(%rsp), %r13
jmp 0x39bf
movl %ecx, %ebx
cmpl $0x0, 0xd8(%rsp)
jle 0x3a74
testb $0x1, %al
je 0x3a74
movl %r9d, 0x8(%rsp)
movq (%r13), %rdi
xorl %r12d, %r12d
testq %rdi, %rdi
je 0x3a2d
movq %r14, %rsi
movl 0xd8(%rsp), %edx
callq 0x3dd0
testb %al, %al
jne 0x3a2d
movl $0x1, %ecx
movq 0x48(%rsp), %rdx
movl %ecx, %r12d
movq %rdx, %r13
movq (%rdx), %rdi
testq %rdi, %rdi
je 0x3a2d
movq %r14, %rsi
movl 0xd8(%rsp), %edx
callq 0x3dd0
leal 0x1(%r12), %ecx
leaq 0x28(%r13), %rdx
testb %al, %al
je 0x3a03
cmpq $0x0, (%r13)
je 0x3a6f
movl %r12d, %eax
leaq (%rax,%rax,4), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rcx
movq %rcx, %r13
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x3a66
movq %r14, %rsi
movl 0xd8(%rsp), %edx
callq 0x3dd0
leaq 0x28(%r13), %rcx
testb %al, %al
je 0x3a44
cmpq $0x0, (%r13)
cmovel %r12d, %ebx
movl 0x8(%rsp), %r9d
movslq %ebx, %rax
leaq (%rax,%rax,4), %rax
cmpq $0x0, 0x10(%rbp,%rax,8)
movzbl %r9b, %r9d
movl $0x0, %eax
cmovnel %eax, %r9d
movq 0x60(%rsp), %r13
movzbl -0x1(%r13), %eax
testl %eax, %eax
je 0x3aa6
cmpl $0x3d, %eax
je 0x3ac4
incq %r13
jmp 0x3a93
cmpl $0x1, 0x14(%rsp)
jne 0x3abb
movq $0x0, 0x30(%rsp)
xorl %r13d, %r13d
jmp 0x3acd
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r13
movq $0x0, 0x30(%rsp)
testb $0x1, %r9b
je 0x3b3e
leaq 0x1(%r15), %rcx
movb 0x1(%r15), %al
testb %al, %al
je 0x3b8a
movq 0x8(%rbp), %rdx
xorl %ebx, %ebx
testq %rdx, %rdx
je 0x3b11
movb (%rdx), %sil
testb %sil, %sil
je 0x3afe
incq %rdx
cmpb %al, %sil
jne 0x3aee
cmpb %al, %sil
je 0x3b11
leaq (%rbx,%rbx,4), %rdx
incq %rbx
movq 0x30(%rbp,%rdx,8), %rdx
jmp 0x3ae9
movb 0x2(%r15), %al
addq $0x2, %r15
testb %al, %al
movq %r15, %r13
movl $0x0, %edx
cmoveq %rdx, %r13
cmpl $0x1, 0x14(%rsp)
je 0x3b3b
testb %al, %al
jne 0x3b3b
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r13
movq %rcx, %r15
movslq %ebx, %rax
leaq (%rax,%rax,4), %rax
cmpq $0x0, 0x8(%rbp,%rax,8)
je 0x3b5a
leaq (,%rax,8), %r12
addq %rbp, %r12
jmp 0x3b9c
movq 0x8(%rbp), %rax
testq %rax, %rax
je 0x3b97
movq %rbp, %r12
xorl %ebx, %ebx
cmpb $0x0, (%rax)
jne 0x3b77
movq 0x10(%r12), %rax
cmpb $0x0, (%rax)
je 0x3b9c
incq %rbx
movq 0x30(%r12), %rax
addq $0x28, %r12
testq %rax, %rax
jne 0x3b68
jmp 0x3b99
movl $0x4, %eax
movq %rcx, %r15
jmp 0x3c96
xorl %ebx, %ebx
xorl %r12d, %r12d
testq %r12, %r12
je 0x3bfb
movl %r9d, 0x8(%rsp)
movq %r15, %rdx
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rdx, %rbp
movq %r13, %rcx
callq 0x3e2c
movzbl 0xd0(%rsp), %esi
movq %r15, %rdi
callq *0x18(%r12)
cmpl $0x3, %eax
ja 0x3c75
movl %eax, %eax
leaq 0x347f(%rip), %rcx      # 0x7060
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rbp, %r15
jmpq *%rax
movq $0x0, 0x88(%rsp)
jmp 0x3c78
xorl %eax, %eax
jmp 0x3c96
cmpl $0x1, 0x14(%rsp)
movq 0x28(%rsp), %rbp
je 0x3c5f
testq %r13, %r13
je 0x3c5f
movq 0x18(%rsp), %rsi
cmpq 0x8(%rsi), %r13
jne 0x3c5f
cmpl $0x0, 0x10(%rsp)
movq 0x40(%rsp), %rdi
jle 0x3c45
movq (%rsi), %rax
xorl %ecx, %ecx
movq -0x8(%rsi,%rcx,8), %rdx
movq %rdx, (%rsi,%rcx,8)
movq %rax, -0x8(%rsi,%rcx,8)
decq %rcx
cmpq %rdi, %rcx
jg 0x3c2f
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
xorl %eax, %eax
movl 0xc(%rsp), %ecx
testl %ecx, %ecx
setg %al
subl %eax, %ecx
movl %ecx, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
jmp 0x3c7d
movl $0x1, %eax
movq 0x28(%rsp), %rbp
jmp 0x3c91
movq %rbp, %r15
movq 0x28(%rsp), %rbp
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
leaq 0x68(%rsp), %rsi
callq *(%rax)
xorb $0x1, %al
movzbl %al, %eax
movl 0x8(%rsp), %r9d
testl %eax, %eax
jne 0x3ca6
testb $0x1, %r9b
jne 0x394e
jmp 0x3cab
cmpl $0x4, %eax
jne 0x3cef
movl 0x10(%rsp), %r8d
testl %r8d, %r8d
movq 0x18(%rsp), %rcx
movq 0x40(%rsp), %rdi
jle 0x3cda
movq (%rcx), %rax
xorl %esi, %esi
movq -0x8(%rcx,%rsi,8), %rdx
movq %rdx, (%rcx,%rsi,8)
movq %rax, -0x8(%rcx,%rsi,8)
decq %rsi
cmpq %rdi, %rsi
jg 0x3cc4
addq $0x8, %rcx
xorl %eax, %eax
movl 0xc(%rsp), %edx
testl %edx, %edx
setg %al
subl %eax, %edx
xorl %eax, %eax
jmp 0x3cfd
movl 0xc(%rsp), %edx
movq 0x18(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0x24(%rsp), %edi
testl %eax, %eax
je 0x3d0a
cmpl $0x2, %eax
jne 0x3d50
testl %edx, %edx
jne 0x38b9
jmp 0x3d59
testl %r8d, %r8d
jle 0x3d3c
movl %r8d, %eax
negl %eax
cltq
movq (%rcx), %r10
xorl %r9d, %r9d
movq -0x8(%rcx,%r9,8), %rsi
movq %rsi, (%rcx,%r9,8)
movq %r10, -0x8(%rcx,%r9,8)
decq %r9
cmpq %rax, %r9
jg 0x3d26
addq $0x8, %rcx
xorl %eax, %eax
testl %edx, %edx
setg %al
subl %eax, %edx
movl $0x3, %eax
jmp 0x3d01
cmpl $0x3, %eax
je 0x3d5b
xorl %eax, %eax
jmp 0x3d9d
xorl %edx, %edx
testl %edx, %edx
jle 0x3d68
xorl %eax, %eax
cmpq $0x0, (%rcx)
cmovel %eax, %edx
testl %edx, %edx
jns 0x3d80
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %rcx, %rax
incl %edx
cmpq $0x0, (%rax)
leaq 0x8(%rax), %rax
jne 0x3d74
addl %r8d, %edx
movslq %r8d, %rax
shlq $0x3, %rax
subq %rax, %rcx
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movl %edx, %esi
movq %rcx, %rdx
callq *0x8(%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop