// File: /workspace/github_cpp_makefile_star2_O1/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, 0x1c(%rsp)
movq %rdi, %rbx
cmpl $0x2, 0x10(%rdi)
jl 0x8852
movl $0x1, %r13d
movq 0x18(%rbx), %rax
movslq %r13d, %r14
movq (%rax,%r14,8), %r12
movb (%r12), %al
cmpb $0x2d, %al
jne 0x8285
movsbl 0x1(%r12), %ebp
cmpl $0x2d, %ebp
jne 0x835f
cmpb $0x2d, %al
jne 0x8285
xorl %ebp, %ebp
cmpb $0x2d, 0x1(%r12)
sete %bpl
leaq (%r12,%rbp,2), %r12
jmp 0x8287
xorl %ebp, %ebp
leaq 0x1(%r12), %rdi
movl $0x3d, %esi
callq 0x2100
testq %rax, %rax
je 0x82ba
movq %rax, %r15
cmpb $0x5c, -0x1(%r15)
jne 0x82d2
movq %r15, %rdi
movl $0x3d, %esi
callq 0x2100
movq %rax, %r15
testq %rax, %rax
jne 0x829e
testb %bpl, %bpl
je 0x82cf
movq %r12, %r15
movzbl (%r15), %eax
testb $-0x21, %al
je 0x82d2
incq %r15
jmp 0x82c2
xorl %r15d, %r15d
cmpq %r12, %r15
jbe 0x8326
leaq -0x1(%r15), %r14
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x88d8
testl %eax, %eax
js 0x857a
movl %eax, %ebp
movslq 0x28(%rbx), %rax
leaq 0x1(%rax), %rcx
movq 0x20(%rbx), %rdi
testl %ecx, %ecx
je 0x83ad
leaq 0x8(,%rax,8), %rax
leaq (%rax,%rax,2), %rsi
testq %rdi, %rdi
je 0x85a1
callq 0x23d0
jmp 0x85a9
je 0x857a
movslq 0x28(%rbx), %rax
leaq 0x1(%rax), %rcx
movq 0x20(%rbx), %rdi
testl %ecx, %ecx
je 0x83c4
leaq 0x8(,%rax,8), %rax
leaq (%rax,%rax,2), %rsi
testq %rdi, %rdi
je 0x85b7
callq 0x23d0
jmp 0x85bf
testb %bpl, %bpl
movq %r14, 0x10(%rsp)
je 0x837a
cmpb $0x0, 0x1c(%rsp)
je 0x83db
movl %ebp, %eax
addl $-0x30, %eax
cmpl $0xa, %eax
jae 0x83db
movslq 0x28(%rbx), %rax
leaq 0x1(%rax), %rcx
movq 0x20(%rbx), %rdi
testl %ecx, %ecx
je 0x858a
leaq 0x8(,%rax,8), %rax
leaq (%rax,%rax,2), %rsi
testq %rdi, %rdi
je 0x86f3
callq 0x23d0
jmp 0x86fb
testq %rdi, %rdi
je 0x83b7
callq 0x22e0
movq $0x0, 0x20(%rbx)
jmp 0x85e6
testq %rdi, %rdi
je 0x83ce
callq 0x22e0
movq $0x0, 0x20(%rbx)
jmp 0x86ac
cmpb $0x2e, %bpl
jne 0x83ef
movsbl 0x2(%r12), %eax
addl $-0x30, %eax
cmpl $0x9, %eax
jbe 0x837a
movl $0x1, %r15d
movq %r13, 0x20(%rsp)
movslq (%rbx), %rax
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testq %rax, %rax
jle 0x8428
movq 0x8(%rbx), %rcx
addq $0x8, %rcx
xorl %edx, %edx
cmpb %bpl, (%rcx)
je 0x8425
incq %rdx
addq $0x10, %rcx
cmpq %rdx, %rax
jne 0x8412
jmp 0x8428
movl %edx, %r12d
testl %r12d, %r12d
js 0x857a
movslq 0x28(%rbx), %rax
leaq 0x1(%rax), %rcx
movq 0x20(%rbx), %rdi
testl %ecx, %ecx
je 0x8459
leaq 0x8(,%rax,8), %rax
leaq (%rax,%rax,2), %rsi
testq %rdi, %rdi
je 0x846d
callq 0x23d0
jmp 0x8475
testq %rdi, %rdi
je 0x8463
callq 0x22e0
movq $0x0, 0x20(%rbx)
jmp 0x8495
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
setne %cl
je 0x8483
movq %rax, 0x20(%rbx)
jmp 0x8495
testb %cl, %cl
jne 0x8495
leaq 0x5b92(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq 0x20(%rbx), %r14
movslq 0x28(%rbx), %r13
testq %r14, %r14
jne 0x84ba
leaq 0x5dc3(%rip), %rdi      # 0xe26c
leaq 0x5dc0(%rip), %rsi      # 0xe270
movl $0x105, %edx            # imm = 0x105
callq 0x285c
leaq (,%r13,2), %rax
addq %r13, %rax
leaq (%r14,%rax,8), %r14
movl $0x2, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, (%r14)
testq %rax, %rax
jne 0x84ee
leaq 0x5b39(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movb %bpl, (%rax)
movq 0x20(%rbx), %rbp
movslq 0x28(%rbx), %rax
leaq (%rax,%rax,2), %r14
movl %r12d, 0x10(%rbp,%r14,8)
movq 0x8(%rbx), %rax
movl %r12d, %ecx
shlq $0x4, %rcx
cmpb $0x0, 0x9(%rax,%rcx)
movq 0x20(%rsp), %r13
jne 0x87ef
movl $0x1, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, 0x8(%rbp,%r14,8)
testq %rax, %rax
jne 0x8554
leaq 0x5ad3(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
incl 0x28(%rbx)
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movb 0x1(%rax,%r15), %bpl
incq %r15
testb %bpl, %bpl
jne 0x83fa
jmp 0x87a5
movl %r13d, 0x38(%rbx)
xorl %eax, %eax
movl %r13d, 0xc(%rsp)
jmp 0x87dc
testq %rdi, %rdi
je 0x8594
callq 0x22e0
movq $0x0, 0x20(%rbx)
jmp 0x871b
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
setne %cl
je 0x85d4
movq %rax, 0x20(%rbx)
jmp 0x85e6
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
setne %cl
je 0x869a
movq %rax, 0x20(%rbx)
jmp 0x86ac
testb %cl, %cl
jne 0x85e6
leaq 0x5a41(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq %r12, %rdi
movq %r14, %rsi
callq 0x29ac
movq 0x20(%rbx), %r14
movslq 0x28(%rbx), %rcx
leaq (%rcx,%rcx,2), %r12
movq %rax, (%r14,%r12,8)
movl %ebp, 0x10(%r14,%r12,8)
movq 0x8(%rbx), %rax
movl %ebp, %ecx
shlq $0x4, %rcx
cmpb $0x1, 0x9(%rax,%rcx)
jne 0x866a
movzbl (%r15), %eax
cmpl $0x3d, %eax
je 0x87a9
testl %eax, %eax
jne 0x87ac
leal 0x1(%r13), %ebp
cmpl 0x10(%rbx), %ebp
jge 0x8845
movq 0x18(%rbx), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rdi
cmpb $0x0, (%rdi)
je 0x8845
xorl %esi, %esi
callq 0x2936
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
movq %rax, 0x8(%rcx,%rdx,8)
jmp 0x87d4
movl $0x1, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, 0x8(%r14,%r12,8)
testq %rax, %rax
jne 0x87d1
leaq 0x5992(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
jmp 0x87d1
testb %cl, %cl
jne 0x86ac
leaq 0x597b(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq $0x0, (%rax,%rcx,8)
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
xorl %esi, %esi
callq 0x2936
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
leaq (%rdx,%rdx,2), %rsi
movq %rax, 0x8(%rcx,%rsi,8)
movl $0xffffffff, 0x10(%rcx,%rsi,8) # imm = 0xFFFFFFFF
leal 0x1(%rdx), %eax
movl %eax, 0x28(%rbx)
jmp 0x87a2
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
setne %cl
je 0x8709
movq %rax, 0x20(%rbx)
jmp 0x871b
testb %cl, %cl
jne 0x871b
leaq 0x590c(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq 0x20(%rbx), %r14
movslq 0x28(%rbx), %rax
leaq (%rax,%rax,2), %r15
movq $0x0, (%r14,%r15,8)
movl $0xffffffff, 0x10(%r14,%r15,8) # imm = 0xFFFFFFFF
testb %bpl, %bpl
je 0x8764
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x2936
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
movq %rax, 0x8(%rcx,%rdx,8)
jmp 0x879f
movl $0x2, %edi
movl $0x1, %esi
callq 0x21c0
movq %rax, 0x8(%r14,%r15,8)
testq %rax, %rax
jne 0x878b
leaq 0x589c(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x289c
movq 0x20(%rbx), %rax
movslq 0x28(%rbx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x8(%rax,%rcx,8), %rax
movb $0x2d, (%rax)
incl 0x28(%rbx)
incl 0x2c(%rbx)
movb $0x1, %al
jmp 0x87dc
incq %r15
cmpb $0x0, (%r15)
je 0x8845
movq %r15, %rdi
xorl %esi, %esi
callq 0x2936
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
leaq (%rdx,%rdx,2), %rdx
movq %rax, 0x8(%rcx,%rdx,8)
movl %r13d, %ebp
incl 0x28(%rbx)
movb $0x1, %al
movl %ebp, %r13d
testb %al, %al
je 0x8859
incl %r13d
cmpl 0x10(%rbx), %r13d
jl 0x824d
jmp 0x8852
movq 0x18(%rbx), %rax
movq 0x10(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movl %r15d, %edx
cmpb $0x0, 0x1(%rcx,%rdx)
je 0x8830
leaq (%rcx,%rdx), %rdi
incq %rdi
movl %r13d, %ebp
xorl %esi, %esi
callq 0x2936
movq 0x20(%rbx), %rcx
movslq 0x28(%rbx), %rdx
leaq (%rdx,%rdx,2), %rsi
movq %rax, 0x8(%rcx,%rsi,8)
leal 0x1(%rdx), %eax
movl %eax, 0x28(%rbx)
jmp 0x87d7
leal 0x1(%r13), %ebp
cmpl 0x10(%rbx), %ebp
jge 0x8845
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rdi
cmpb $0x0, (%rdi)
jne 0x8810
movl %r13d, 0x38(%rbx)
movb $0x1, 0x3c(%rbx)
jmp 0x857e
movl 0x38(%rbx), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq