// File: /workspace/github_cpp_makefile_star2_O3/gpertea[P]gclib/GArgs.cpp
// Function: GArgs::GArgs(int, char**, char const*, bool)
GArgs::GArgs(int argc, char* argv[], const char* format, bool nodigitopts) {
   /* format can be:
      <string>{;|=} e.g. disable-test;PID=S= for --disable-test PID=50 (or --PID 50) S=3.5 etc.
      <letter>[:]  e.g. p:hT  for -p testing (or -ptesting) -h -T
   */
const char* fstr=format;
fmtcount=0;
count=0;
nonOptCount=0;
nonOptPos=0;
optPos=0;
errarg=0;
err_valmissing=false;
args=NULL;
fmt=NULL;
_argc=argc;
_argv=argv;
int fmtlen=strlen(format);
//---- first parse the format string
while (fstr-format < fmtlen ) {
  int l=strcspn(fstr, ";=:");
  if (fstr[l]==0) { //end of string reached
      //all previous chars are just switches:
       GREALLOC(fmt, (fmtcount+l)*sizeof(fmtdef));
       //store each switch
       for (int i=0; i<l;i++) { 
         fmt[fmtcount+i].longopt=NULL;
         fmt[fmtcount+i].opt=fstr[i];
         fmt[fmtcount+i].req_value = false;
         fmt[fmtcount+i].code=fmtcount+i+1;
         }
       fmtcount+=l;
       break;
     }
   else {
     if (fstr[l]==':') {
         //fstr[l-1] is an argument, but all the previous are just switches
         GREALLOC(fmt, (fmtcount+l)*sizeof(fmtdef));
         //store each switch AND the option
         for (int i=0; i<l;i++) { 
           fmt[fmtcount+i].longopt=NULL; //one char length
           fmt[fmtcount+i].opt=fstr[i];
           fmt[fmtcount+i].req_value = (i==l-1);
           fmt[fmtcount+i].code=fmtcount+i+1;
           }
         fmtcount+=l;
         }
      else { // fstr[l]=='=' or ';' 
         GREALLOC(fmt, (fmtcount+1)*sizeof(fmtdef));
         fmt[fmtcount].longopt=Gstrdup(fstr, fstr+l-1);
         fmt[fmtcount].opt=0;
         fmt[fmtcount].req_value=(fstr[l]=='=');
         fmt[fmtcount].code=fmtcount+1;
         fmtcount++;
         }
     fstr+=l+1;
     }
  }
 //-- now parse the arguments based on the given format specification
 parseArgs(nodigitopts);
 }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, 0xc(%rsp)
movq %rdi, %r14
movl $0x0, (%rdi)
movq $0x0, 0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x2d(%rdi)
movl %esi, 0x10(%rdi)
movq %rdx, 0x18(%rdi)
movq %rcx, 0x10(%rsp)
movq %rcx, %rdi
callq 0x2140
movslq %eax, %rbx
testq %rbx, %rbx
jle 0x7ff5
xorl %ebp, %ebp
movq 0x10(%rsp), %r15
movq %r15, %rdi
leaq 0x6454(%rip), %rsi      # 0xe230
callq 0x2060
movq %rax, %r12
movslq %r12d, %r13
movzbl (%r15,%r13), %eax
movq 0x8(%r14), %rdi
cmpl $0x3a, %eax
je 0x7e15
testl %eax, %eax
je 0x7f59
leal 0x1(%rbp), %eax
incl %ebp
jne 0x7e2d
testq %rdi, %rdi
je 0x7e0e
callq 0x22e0
xorl %eax, %eax
jmp 0x7ee2
addl %r12d, %ebp
je 0x7e47
movslq %ebp, %rsi
shlq $0x4, %rsi
testq %rdi, %rdi
je 0x7e55
callq 0x23d0
jmp 0x7e5d
movslq %eax, %rsi
shlq $0x4, %rsi
testq %rdi, %rdi
je 0x7ed5
callq 0x23d0
jmp 0x7edd
testq %rdi, %rdi
je 0x7e51
callq 0x22e0
xorl %eax, %eax
jmp 0x7e62
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
je 0x7e68
movq %rax, 0x8(%r14)
jmp 0x7e76
leaq 0x61b1(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x286c
movslq (%r14), %rbp
testl %r12d, %r12d
jle 0x7ed0
movq 0x8(%r14), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addl %r12d, %eax
movl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leal 0x1(%rbp), %edx
movq %rbp, %rdi
shlq $0x4, %rdi
addq %rdi, %rsi
addq $0xc, %rsi
xorl %edi, %edi
movq $0x0, -0xc(%rsi)
movb (%r15,%rdi), %r8b
movb %r8b, -0x4(%rsi)
cmpq %rdi, %rax
sete -0x3(%rsi)
leal (%rdx,%rdi), %r8d
movl %r8d, (%rsi)
incq %rdi
addq $0x10, %rsi
cmpq %rdi, %rcx
jne 0x7ea6
addl %r12d, %ebp
jmp 0x7f1a
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
je 0x7f49
movq %rax, 0x8(%r14)
addq %r15, %r13
leaq -0x1(%r13), %rsi
movq %r15, %rdi
callq 0x2978
movq 0x8(%r14), %rcx
movslq (%r14), %rdx
leal 0x1(%rdx), %ebp
shlq $0x4, %rdx
movq %rax, (%rcx,%rdx)
movb $0x0, 0x8(%rcx,%rdx)
cmpb $0x3d, (%r13)
sete 0x9(%rcx,%rdx)
movl %ebp, 0xc(%rcx,%rdx)
shlq $0x20, %r12
movl %ebp, (%r14)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq %r12, %rax
incq %rax
sarq $0x20, %rax
addq %rax, %r15
movq %r15, %rax
subq 0x10(%rsp), %rax
cmpq %rbx, %rax
jl 0x7dd2
jmp 0x7ff5
leaq 0x60d0(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x286c
jmp 0x7ee6
addl %r12d, %ebp
je 0x7f71
movslq %ebp, %rsi
shlq $0x4, %rsi
testq %rdi, %rdi
je 0x7f7f
callq 0x23d0
jmp 0x7f87
testq %rdi, %rdi
je 0x7f7b
callq 0x22e0
xorl %eax, %eax
jmp 0x7f8c
movq %rsi, %rdi
callq 0x2330
testq %rax, %rax
je 0x7f92
movq %rax, 0x8(%r14)
jmp 0x7fa0
leaq 0x6087(%rip), %rdi      # 0xe020
xorl %eax, %eax
callq 0x286c
movslq (%r14), %rax
testl %r12d, %r12d
jle 0x7fef
movq 0x8(%r14), %rsi
movl %r12d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leal 0x1(%rax), %edx
movq %rax, %rdi
shlq $0x4, %rdi
addq %rdi, %rsi
addq $0xc, %rsi
xorl %edi, %edi
movq $0x0, -0xc(%rsi)
movb (%r15,%rdi), %r8b
movb %r8b, -0x4(%rsi)
movb $0x0, -0x3(%rsi)
leal (%rdx,%rdi), %r8d
movl %r8d, (%rsi)
incq %rdi
addq $0x10, %rsi
cmpq %rdi, %rcx
jne 0x7fc8
addl %r12d, %eax
movl %eax, (%r14)
movzbl 0xc(%rsp), %esi
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8010