// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0xc241
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xbe80
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0xbaac
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
je 0xbe80
movq -0x48(%rbp), %rax
movl $0x1, -0x20(%rbp)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x0, %eax
je 0xbb22
testb $0x1, -0x11(%rbp)
je 0xbaea
movsbl -0x21(%rbp), %edi
callq 0x2210
cmpl $0x0, %eax
jne 0xbb22
movsbl -0x21(%rbp), %eax
cmpl $0x2e, %eax
jne 0xbc24
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edi
callq 0x2210
cmpl $0x0, %eax
je 0xbc24
movq -0x48(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movl 0x28(%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
callq 0x5f10
testb $0x1, %al
jne 0xbb50
leaq 0x84da(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rax
movslq 0x28(%rcx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq $0x0, (%rax)
movq 0x20(%rcx), %rax
movslq 0x28(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0xffffffff, 0x10(%rax) # imm = 0xFFFFFFFF
movsbl -0x21(%rbp), %eax
cmpl $0x0, %eax
jne 0xbbd8
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movslq 0x28(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
movl $0x2, %esi
callq 0xcd90
testb $0x1, %al
jne 0xbbbc
leaq 0x846e(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rax
movslq 0x28(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movb $0x2d, (%rax)
jmp 0xbc09
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x27b0
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movq 0x20(%rdx), %rax
movslq 0x28(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
jmp 0xbe7b
jmp 0xbc26
movq -0x48(%rbp), %rdi
movsbl -0x21(%rbp), %esi
callq 0xc2e0
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jl 0xbe64
movq -0x48(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movl 0x28(%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
callq 0x5f10
testb $0x1, %al
jne 0xbc6d
leaq 0x83bd(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movslq 0x28(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movl $0x2, %esi
callq 0xcd90
testb $0x1, %al
jne 0xbc9c
leaq 0x838e(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rax
movb -0x21(%rbp), %dl
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rcx
movq (%rcx), %rcx
movb %dl, (%rcx)
movl -0x1c(%rbp), %edx
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x10(%rcx)
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, 0x9(%rax)
jne 0xbd70
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movslq 0x28(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0xcd90
testb $0x1, %al
jne 0xbd18
leaq 0x8312(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0xbd6b
movq -0x48(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x20(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x21(%rbp)
jmp 0xbc26
jmp 0xbe62
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0xbe19
movq -0x48(%rbp), %rcx
movl -0x18(%rbp), %eax
addl $0x1, %eax
cmpl 0x10(%rcx), %eax
jge 0xbdfe
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xbdfe
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x18(%rbp)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x27b0
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movq 0x20(%rdx), %rax
movslq 0x28(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0xbe17
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movb $0x1, 0x3c(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
jmp 0xbe55
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x20(%rbp), %rax
addq %rax, %rdi
addq $0x1, %rdi
xorl %esi, %esi
callq 0x27b0
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movq 0x20(%rdx), %rax
movslq 0x28(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0xbe79
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
jmp 0xbe7b
jmp 0xc233
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movb $0x0, -0x31(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xbec1
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0xbec1
movb $0x1, -0x31(%rbp)
movq -0x30(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
movl $0x3d, %esi
callq 0x2100
movq %rax, -0x40(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x40(%rbp)
movb %al, -0x49(%rbp)
je 0xbef4
movq -0x40(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x5c, %eax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0xbefd
jmp 0xbf11
movq -0x40(%rbp), %rdi
movl $0x3d, %esi
callq 0x2100
movq %rax, -0x40(%rbp)
jmp 0xbed7
cmpq $0x0, -0x40(%rbp)
jne 0xbf60
testb $0x1, -0x31(%rbp)
je 0xbf60
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0xbf47
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0xbf50
jmp 0xbf5e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xbf26
jmp 0xbf60
cmpq $0x0, -0x40(%rbp)
je 0xc175
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0xc175
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq $-0x1, %rdx
callq 0xc350
movl %eax, -0x1c(%rbp)
cmpl $0x0, %eax
jl 0xc15b
movq -0x48(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movl 0x28(%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
callq 0x5f10
testb $0x1, %al
jne 0xbfc8
leaq 0x8062(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $-0x1, %rsi
callq 0x2880
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rcx
movq %rdx, (%rcx)
movl -0x1c(%rbp), %edx
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rcx
movl %edx, 0x10(%rcx)
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
testb $0x1, 0x9(%rax)
je 0xc117
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc0b3
movq -0x48(%rbp), %rcx
movl -0x18(%rbp), %eax
addl $0x1, %eax
cmpl 0x10(%rcx), %eax
jge 0xc098
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc098
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x18(%rbp)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x27b0
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movq 0x20(%rdx), %rax
movslq 0x28(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0xc0b1
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movb $0x1, 0x3c(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
jmp 0xc115
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0xc0cb
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc0f0
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movb $0x1, 0x3c(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x27b0
movq -0x48(%rbp), %rdx
movq %rax, %rcx
movq 0x20(%rdx), %rax
movslq 0x28(%rdx), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0xc14c
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movslq 0x28(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0xcd90
testb $0x1, %al
jne 0xc14a
leaq 0x7ee0(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
jmp 0xc14c
movq -0x48(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0xc170
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
jmp 0xc231
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jne 0xc194
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, 0x38(%rax)
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0xc24b
movq -0x48(%rbp), %rax
movq %rax, %rdi
addq $0x20, %rdi
movl 0x28(%rax), %eax
addl $0x1, %eax
cltq
imulq $0x18, %rax, %rsi
callq 0x5f10
testb $0x1, %al
jne 0xc1c2
leaq 0x7e68(%rip), %rdi      # 0x14023
movb $0x0, %al
callq 0x2640
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq $0x0, (%rcx)
movq 0x18(%rax), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x27b0
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rsi
imulq $0x18, %rsi, %rsi
addq %rsi, %rcx
movq %rdx, 0x8(%rcx)
movq 0x20(%rax), %rcx
movslq 0x28(%rax), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movl $0xffffffff, 0x10(%rcx) # imm = 0xFFFFFFFF
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
movl 0x2c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x2c(%rax)
jmp 0xc233
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xba4a
movq -0x48(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)