// File: /workspace/github_cpp_makefile_star2_O1/jpbalarini[P]otsus/./framework/libparser.cpp
// Function: parsecmdline(char const*, char const*, int, char**, std::vector<optstruct*, std::allocator<optstruct*>>&, std::vector<parstruct*, std::allocator<parstruct*>>&)
int parsecmdline(const char *pname,
		 const char *function,
		 const int argc, char **argv,
		 vector <OptStruct*> & opt,
		 vector <ParStruct*> & par) {
	int nopt = opt.size();
	int npar = par.size();
	
	
	char gp[2*nopt+1];
	gp[0]='\0';
	
	
	for(int i=0; i < nopt; i++) { opt[i]->flag = 0; opt[i]->value=NULL; strcat(gp, opt[i]->gp);}
	for(int i=0; i < npar; i++) { par[i]->value = NULL;}
	
	opterr = 0;	// No messages by getopt
	
	int c;
	while ((c = getopt (argc, argv, gp)) != -1)
	{
		
		int j=0;
		for(unsigned int i=0; i < strlen(gp); i++)
			if (c == gp[i])
			{
				
				opt[j]->flag = 1;
				/*				if (optarg != NULL && optarg[0] == '-')
				 {	 
				 printf("\n%s: %s\n", pname, function);
				 fprintf (stderr, "\nerror: option -%c requires an argument.\n", c);
				 printusage(pname,function, gp, argc, argv, opt, nopt, par, npar);
				 return 0;
				 
				 }*/
				
				opt[j]->value = optarg;
				break;
				
			} else if (gp[i] != ':') j++;
		
		
		
		if (c == '?')
		{	
			
			unsigned int i = 0;
			for(i=0; i < strlen(gp); i++)
				if (optopt == gp[i])
				{
					printf("\n%s: %s\n", pname, function);
					fprintf (stderr, "\nerror: option -%c requires an argument.\n", optopt);
					break;	
				}
			
			if (i == strlen(gp)) { 	printf("\n%s: %s\n", pname, function);
				fprintf (stderr, "\nerror: unknown option `-%c'.\n", optopt);
			}
			
			printusage(pname, gp,  opt,  par);
			return 0;
			
		}
		
	}
	
	
	//// Setting default values for non selected options
	for(int j=0; j < nopt; j++)
		if (opt[j]->flag == 0 && opt[j]->defvalue != NULL) opt[j]->value =  opt[j]->defvalue;
	
	
	if (argc - optind != npar) {
		printf("\n%s: %s\n", pname, function);
		fprintf (stderr, "\nerror: incorrect number of parameters\n");
		printusage(pname, gp,  opt,par);
		return 0;
	}
	
	int i=0;
	for (int index = optind; index < argc ; index++, i++){
		par[i]->value = argv[index];
	}
	
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, -0x58(%rbp)
movl %edx, -0x2c(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movq (%r8), %r12
movq %r8, -0x60(%rbp)
movq 0x8(%r8), %rax
subq %r12, %rax
movq %rax, %rdx
shrq $0x3, %rdx
movq (%r9), %rbx
movq %r9, -0x68(%rbp)
movq 0x8(%r9), %rcx
subq %rbx, %rcx
shrq $0x3, %rcx
movq %rcx, -0x48(%rbp)
shrq $0x2, %rax
orl $0x1, %eax
movq %rsp, %rcx
addq $0xf, %rax
andq $-0x10, %rax
movq %rcx, %r15
subq %rax, %r15
movq %r15, %rsp
negq %rax
movb $0x0, (%rcx,%rax)
movq %rdx, -0x50(%rbp)
testl %edx, %edx
jle 0x4bd0
movq -0x50(%rbp), %r14
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %r13d, %r13d
movq (%r12,%r13,8), %rax
movl $0x0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movq (%r12,%r13,8), %rax
movq (%rax), %rsi
movq %r15, %rdi
callq 0x34c0
incq %r13
cmpq %r13, %r14
jne 0x4ba6
cmpl $0x0, -0x48(%rbp)
jle 0x4bf5
movq -0x48(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movq (%rbx,%rcx,8), %rdx
movq $0x0, 0x8(%rdx)
incq %rcx
cmpq %rcx, %rax
jne 0x4be1
movq 0x73d4(%rip), %rax      # 0xbfd0
movl $0x0, (%rax)
movl -0x2c(%rbp), %edi
movq -0x58(%rbp), %r12
movq %r12, %rsi
movq %r15, %rdx
callq 0x30c0
cmpl $-0x1, %eax
movq -0x68(%rbp), %r14
movq -0x60(%rbp), %r13
je 0x4d1c
movl %eax, %ebx
movq %r15, %rdi
callq 0x3160
testq %rax, %rax
je 0x4c7c
xorl %esi, %esi
movl $0x1, %ecx
xorl %edx, %edx
movsbl (%r15,%rsi), %esi
cmpl %esi, %ebx
je 0x4c5d
xorl %edi, %edi
cmpb $0x3a, %sil
setne %dil
addl %edi, %edx
movl %ecx, %esi
incl %ecx
cmpq %rsi, %rax
ja 0x4c3d
jmp 0x4c7c
movl %edx, %eax
movq (%r13), %rcx
movq (%rcx,%rax,8), %rax
movl $0x1, 0x8(%rax)
movq 0x7323(%rip), %rcx      # 0xbf98
movq (%rcx), %rcx
movq %rcx, 0x18(%rax)
cmpl $0x3f, %ebx
jne 0x4ce3
movq %r15, %rdi
callq 0x3160
testq %rax, %rax
je 0x4cb4
movq 0x731b(%rip), %rcx      # 0xbfb0
movl (%rcx), %ecx
movl $0x1, %edx
xorl %r12d, %r12d
movsbl (%r15,%r12), %esi
cmpl %esi, %ecx
je 0x4d0d
movl %edx, %r12d
incl %edx
cmpq %r12, %rax
ja 0x4c9f
jmp 0x4cb7
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x3160
cmpq %r12, %rax
je 0x4cfe
movq -0x38(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x48f4
cmpl $0x3f, %ebx
movq -0x58(%rbp), %r12
je 0x4d8f
movl -0x2c(%rbp), %edi
movq %r12, %rsi
movq %r15, %rdx
callq 0x30c0
movl %eax, %ebx
cmpl $-0x1, %eax
jne 0x4c27
jmp 0x4d1c
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3600
jmp 0x4cc4
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x35c5
jmp 0x4cb7
movq -0x50(%rbp), %rdi
testl %edi, %edi
jle 0x4d4f
movq (%r13), %rax
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rdx
cmpl $0x0, 0x8(%rdx)
jne 0x4d47
movq 0x10(%rdx), %rsi
testq %rsi, %rsi
je 0x4d47
movq %rsi, 0x18(%rdx)
incq %rcx
cmpq %rcx, %rdi
jne 0x4d30
movq 0x7272(%rip), %rax      # 0xbfc8
movslq (%rax), %rdx
movl -0x2c(%rbp), %eax
movl %eax, %ecx
subl %edx, %ecx
cmpl -0x48(%rbp), %ecx
jne 0x4da2
movl $0x1, %ebx
cmpl %edx, %eax
jle 0x4d91
movq (%r14), %rax
movl %ecx, %ecx
leaq (%r12,%rdx,8), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
movq (%rax,%rsi,8), %r8
movq %rdi, 0x8(%r8)
incq %rsi
cmpq %rsi, %rcx
jne 0x4d79
jmp 0x4d91
xorl %ebx, %ebx
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x341f(%rip), %rdi      # 0x81c8
xorl %ebx, %ebx
movq -0x38(%rbp), %r12
movq %r12, %rsi
movq -0x40(%rbp), %rdx
xorl %eax, %eax
callq 0x3070
movq 0x71fc(%rip), %rax      # 0xbfc0
movq (%rax), %rcx
leaq 0x344c(%rip), %rdi      # 0x821a
movl $0x27, %esi
movl $0x1, %edx
callq 0x3510
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x48f4
jmp 0x4d91