// File: /workspace/github_cpp_makefile_star2_O2/gpertea[P]gclib/GArgs.cpp
// Function: GArgs::parseArgs(bool)
int GArgs::parseArgs(bool nodigitopts) {
  int p=1; //skip program name
  int f=0;
  while (p<_argc) {
   // silly patch for annnoying MacOS gdb/eclipse issues:
   #if defined(__APPLE__) && defined(DEBUG)
	   dbg_dequote(_argv[p]);
   #endif
   //--
   if (_argv[p][0]=='-' && (_argv[p][1]==0 || _argv[p][1]!='-')) { 
     //single-dash argument
     int cpos=1;
     char c=_argv[p][cpos];
     if (c==0 || (nodigitopts && isdigit(c)) || 
            (c=='.' && isdigit(_argv[p][cpos+1]))) { 
        //special case: plain argument '-' or just a negative number
        GREALLOC(args, (count+1)*sizeof(argdata));
        args[count].opt=NULL;
        args[count].fmti=-1;
        if (c==0) {
          GCALLOC(args[count].value, 2);
          args[count].value[0]='-';
          }
         else { //negative number given
          args[count].value=Gstrdup(_argv[p]);
          }
        count++;
        nonOptCount++;
        }
      else { //single-dash argument or switch
       COLLAPSED:
        if ((f=validShortOpt(c))>=0) {
          GREALLOC(args, (count+1)*sizeof(argdata));
          GCALLOC(args[count].opt, 2);
          args[count].opt[0]=c;
          args[count].fmti=f;
          if (!fmt[f].req_value) {//switch type
            GCALLOC(args[count].value,1);//so getOpt() functions would not return NULL
            count++;
            // only switches can be grouped with some other switches or options
            if (_argv[p][cpos+1]!='\0') {
               cpos++;
               c=_argv[p][cpos];
               goto COLLAPSED;
               }
            }
           else {
              //single-dash argument followed by a value
            if (_argv[p][cpos+1]=='\0') {
                if (p+1<_argc && _argv[p+1][0]!=0) { //value is the whole next argument
                   p++;
				#if defined(__APPLE__) && defined(DEBUG)
				   dbg_dequote(_argv[p]);
				#endif
                   args[count].value=Gstrdup(_argv[p]);
                }
                  else {
                   errarg=p;
                   err_valmissing=true;
                   return errarg;
                   }
                }
               else { //value immediately follows the dash-option
                args[count].value=Gstrdup(_argv[p]+cpos+1);
                }
            count++;
            }
          } //was validShortOpt
         else { //option not found in format definition!
           errarg=p;
           return errarg;
           }
        }
     } //-single-dash
   else {//not a single-dash argument
     char* ap=_argv[p];
     bool is_longopt=false;
     if (*ap=='-' && ap[1]=='-') { //double-dash option
        is_longopt=true;
        ap+=2;
        }
     char* e=strchr(ap+1,'=');
     while (e!=NULL && *(e-1)=='\\') e=strchr(e,'=');
     if (e==NULL && is_longopt) {
        e=ap;
        while (*e!=0 && *e!=' ') e++;
        //e will be on eos or next space
        }
     if (e!=NULL && e>ap) {
       //this must be a long option
       //e is on eos, space or '='
       if ((f=validLongOpt(ap,e-1))>=0) {
            GREALLOC(args, (count+1)*sizeof(argdata));
            args[count].opt=Gstrdup(ap,e-1);
            args[count].fmti=f;
            if (fmt[f].req_value) {
               if (*e==0) {
                   //value is the next argument
                   if (p+1<_argc && _argv[p+1][0]!=0) {
                      p++;
					#if defined(__APPLE__) && defined(DEBUG)
                      dbg_dequote(_argv[p]);
   	   	   	   	   	#endif
                      args[count].value=Gstrdup(_argv[p]);
                      }
                    else {
                      errarg=p;
                      err_valmissing=true;
                      return errarg;
                      }
                   }
                else { //value is in the same argument
                   //while (*e!=0 && (*e==' ' || *e=='=')) e++;
                   if (*e=='=') e++;
                   if (*e==0) {
                      errarg=p;
                      err_valmissing=true;
                      return errarg;
                      }
                   args[count].value=Gstrdup(e);
                   }
               } //value required
              else { //no value expected
               GCALLOC(args[count].value,1); //do not return NULL
               }
            count++;
            }
          else { //error - this long argument not recognized
           errarg=p;
           return errarg;
           }
        }
      else { //just a plain non-option argument
       if (e==ap) { //i.e. just "--"
          errarg=p;
          return errarg;
          }
       GREALLOC(args, (count+1)*sizeof(argdata));
       args[count].opt=NULL; //it's not an option
       args[count].value=Gstrdup(_argv[p]);
       args[count].fmti=-1;
       count++;
       nonOptCount++;
       }
     }
   p++;//check next arg string
   } //while arguments
 return errarg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, 0x24(%rsp)
movq %rdi, %rbx
leaq 0x20(%rdi), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %r15
pushq $0x3d
popq %rbp
cmpl 0x10(%rbx), %r15d
jge 0x7d30
movq 0x18(%rbx), %rax
movslq %r15d, %rcx
movq %rcx, 0x18(%rsp)
movq (%rax,%rcx,8), %r12
movb (%r12), %r14b
cmpb $0x2d, %r14b
jne 0x78df
movq %r15, 0x8(%rsp)
movsbl 0x1(%r12), %r15d
cmpl $0x2d, %r15d
jne 0x7a01
addq $0x2, %r12
movq 0x8(%rsp), %r15
leaq 0x1(%r12), %r13
movq %r13, %rdi
movl %ebp, %esi
callq 0x2100
testq %rax, %rax
je 0x79e2
movq %rax, %r13
cmpb $0x5c, -0x1(%rax)
je 0x78e4
cmpq %r12, %r13
jbe 0x7a99
movq %r15, %rbp
leaq -0x1(%r13), %r15
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x7dca
testl %eax, %eax
js 0x7d3d
movl %eax, %r14d
movslq 0x28(%rbx), %rax
imulq $0x18, %rax, %rsi
addq $0x18, %rsi
movq 0x10(%rsp), %rdi
callq 0x43e9
testb %al, %al
jne 0x7951
leaq 0x46d6(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movq %r12, %rdi
movq %r15, %rsi
callq 0x2788
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
imulq $0x18, %rdx, %rdx
movq %rax, (%rcx,%rdx)
movl %r14d, 0x10(%rcx,%rdx)
movq 0x8(%rbx), %rax
movl %r14d, %esi
shlq $0x4, %rsi
cmpb $0x1, 0x9(%rax,%rsi)
jne 0x7b1f
movzbl (%r13), %eax
cmpl $0x3d, %eax
movq %rbp, %r15
je 0x7c99
testl %eax, %eax
pushq $0x3d
popq %rbp
jne 0x7ca3
leal 0x1(%r15), %r14d
cmpl 0x10(%rbx), %r14d
jge 0x7d56
movq 0x18(%rbx), %rax
movslq %r14d, %rcx
movq (%rax,%rcx,8), %rdi
cmpb $0x0, (%rdi)
je 0x7d56
xorl %esi, %esi
callq 0x2704
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
imulq $0x18, %rdx, %rdx
movq %rax, 0x8(%rcx,%rdx)
jmp 0x7cc9
cmpb $0x2d, %r14b
jne 0x7a96
movq %r12, %r13
movzbl (%r13), %eax
testb $-0x21, %al
je 0x7900
incq %r13
jmp 0x79ef
testb %r15b, %r15b
je 0x7a20
cmpb $0x0, 0x24(%rsp)
je 0x7b4c
movl %r15d, %eax
addl $-0x30, %eax
cmpl $0xa, %eax
jae 0x7b4c
movslq 0x28(%rbx), %rax
imulq $0x18, %rax, %rsi
addq $0x18, %rsi
movq 0x10(%rsp), %rdi
callq 0x43e9
testb %al, %al
movq 0x18(%rsp), %r14
jne 0x7a4d
leaq 0x45da(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rcx
andq $0x0, (%rax,%rcx)
orl $-0x1, 0x10(%rax,%rcx)
testb %r15b, %r15b
je 0x7c51
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
xorl %esi, %esi
callq 0x2704
movq 0x20(%rbx), %rdx
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rsi
movq %rax, 0x8(%rdx,%rsi)
movq 0x8(%rsp), %r15
jmp 0x7c8f
xorl %r13d, %r13d
movq 0x18(%rsp), %r14
cmpq %r12, %r13
je 0x7d40
movslq 0x28(%rbx), %rax
imulq $0x18, %rax, %rsi
addq $0x18, %rsi
movq 0x10(%rsp), %rdi
callq 0x43e9
testb %al, %al
jne 0x7acf
leaq 0x4558(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rcx
andq $0x0, (%rax,%rcx)
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
xorl %esi, %esi
callq 0x2704
movq 0x20(%rbx), %rcx
movq 0x28(%rbx), %rdx
movq %rdx, %xmm0
psubd 0x472c(%rip), %xmm0     # 0xc230
movslq %edx, %rdx
imulq $0x18, %rdx, %rdx
movq %rax, 0x8(%rcx,%rdx)
orl $-0x1, 0x10(%rcx,%rdx)
movq %xmm0, 0x28(%rbx)
jmp 0x7ccf
leaq (%rcx,%rdx), %rdi
addq $0x8, %rdi
pushq $0x1
popq %rsi
callq 0x82bd
testb %al, %al
jne 0x7b41
leaq 0x44e6(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movl %ebp, %r14d
pushq $0x3d
popq %rbp
jmp 0x7cc9
cmpb $0x2e, %r15b
jne 0x7b64
movsbl 0x2(%r12), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
jbe 0x7a20
pushq $0x1
popq %r13
movq 0x18(%rsp), %r14
movsbl %r15b, %esi
movq %rbx, %rdi
callq 0x7da0
testl %eax, %eax
js 0x7d36
movl %eax, %r12d
movslq 0x28(%rbx), %rax
imulq $0x18, %rax, %rsi
addq $0x18, %rsi
movq 0x10(%rsp), %rdi
callq 0x43e9
testb %al, %al
jne 0x7bac
leaq 0x447b(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movslq 0x28(%rbx), %rax
imulq $0x18, %rax, %rdi
addq 0x20(%rbx), %rdi
pushq $0x2
popq %rsi
callq 0x82bd
testb %al, %al
jne 0x7bd2
leaq 0x4455(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rcx
movq (%rax,%rcx), %rax
movb %r15b, (%rax)
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rcx
movl %r12d, 0x10(%rax,%rcx)
movq 0x8(%rbx), %rdx
movl %r12d, %esi
shlq $0x4, %rsi
cmpb $0x0, 0x9(%rdx,%rsi)
jne 0x7cd7
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
pushq $0x1
popq %rsi
callq 0x82bd
testb %al, %al
jne 0x7c2e
leaq 0x43f9(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
incl 0x28(%rbx)
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rax
movb 0x1(%rax,%r13), %r15b
incq %r13
testb %r15b, %r15b
jne 0x7b6d
movq 0x8(%rsp), %r15
jmp 0x7ccf
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
pushq $0x2
popq %rsi
callq 0x82bd
testb %al, %al
movq 0x8(%rsp), %r15
jne 0x7c78
leaq 0x43af(%rip), %rdi      # 0xc020
xorl %eax, %eax
callq 0x25ca
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
imulq $0x18, %rcx, %rcx
movq 0x8(%rax,%rcx), %rax
movb $0x2d, (%rax)
movl 0x28(%rbx), %ecx
incl %ecx
movl %ecx, 0x28(%rbx)
incl 0x2c(%rbx)
jmp 0x7ccf
movb 0x1(%r13), %al
incq %r13
pushq $0x3d
popq %rbp
testb %al, %al
je 0x7d56
movq %r13, %rdi
xorl %esi, %esi
callq 0x2704
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
imulq $0x18, %rdx, %rdx
movq %rax, 0x8(%rcx,%rdx)
movl %r15d, %r14d
incl 0x28(%rbx)
movl %r14d, %r15d
incl %r15d
jmp 0x789d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rcx
movl %r13d, %edx
cmpb $0x0, 0x1(%rcx,%rdx)
movq 0x8(%rsp), %r15
je 0x7cfa
leaq (%rcx,%rdx), %rdi
incq %rdi
movl %r15d, %r14d
jmp 0x7d10
leal 0x1(%r15), %r14d
cmpl 0x10(%rbx), %r14d
jge 0x7d56
movslq %r14d, %rcx
movq (%rax,%rcx,8), %rdi
cmpb $0x0, (%rdi)
je 0x7d56
xorl %esi, %esi
callq 0x2704
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
imulq $0x18, %rdx, %rsi
movq %rax, 0x8(%rcx,%rsi)
leal 0x1(%rdx), %eax
movl %eax, 0x28(%rbx)
jmp 0x7ccc
movl 0x38(%rbx), %r15d
jmp 0x7d44
movq 0x8(%rsp), %r15
jmp 0x7d40
movq %rbp, %r15
movl %r15d, 0x38(%rbx)
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r15d, 0x38(%rbx)
movb $0x1, 0x3c(%rbx)
jmp 0x7d44