// File: jpbalarini[P]otsus/./framework/libparser.cpp
// Function: printusage(char const*, char const*, std::vector<optstruct*, std::allocator<optstruct*>>&, std::vector<parstruct*, std::allocator<parstruct*>>&)
void  printusage(const char *pname,
		 const char *gp,
		 vector<OptStruct*>  &opt,
		 vector<ParStruct*>  &par)
{
	
	//int nopt = opt.size();
	int npar = par.size();
	
	///// USAGE
	printf("\nusage: %s ", pname);
	for(int i=0; i < (int) strlen(gp); i++)
		if (gp[i] != ':')
		{
			printf("[-%c",gp[i]);
			
			if (i+1 < (int) strlen(gp) && gp[i+1] ==  ':') printf(" %c] ", gp[i]);
			else printf("] ");
			
		}
	
	for(int i=0; i < npar; i++)
		printf(" %s ", par[i]->name);
	
	printf("\n");
	//// PARAMETERS
	
	int j=0;
	for(int i=0; i < (int) strlen(gp); i++)
		if (gp[i] != ':')
		{
			printf("\t-%c",gp[i]);
			
			if (i+1 < (int) strlen(gp) && gp[i+1] ==  ':') {
				
				printf("  %c\t %s ", gp[i], opt[j]->comment);
				if (opt[j]->defvalue != NULL) printf("(Default: %s)",opt[j]->defvalue);
				
				printf("\n");
				
			}		
			else printf("\t %s \n", opt[j]->comment);
			
			j++;
		}
	
	
	for(int i=0; i < npar; i++)
	{
		printf("\t%s",par[i]->name);
		printf("\t %s\n", par[i]->comment);
	}
	
	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x66c0
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x71e6(%rip), %rdi      # 0xd185
movb $0x0, %al
callq 0x3070
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3190
movq %rax, %rcx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jge 0x6063
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
je 0x6053
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x71a3(%rip), %rdi      # 0xd191
movb $0x0, %al
callq 0x3070
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3190
movq %rax, %rcx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
jge 0x6043
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x6043
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x715c(%rip), %rdi      # 0xd196
movb $0x0, %al
callq 0x3070
jmp 0x6051
leaq 0x714f(%rip), %rdi      # 0xd199
movb $0x0, %al
callq 0x3070
jmp 0x6053
jmp 0x6055
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5fad
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x609e
movq -0x20(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x66e0
movq (%rax), %rax
movq (%rax), %rsi
leaq 0x711a(%rip), %rdi      # 0xd1a6
movb $0x0, %al
callq 0x3070
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x606a
leaq 0x7a47(%rip), %rdi      # 0xdaec
movb $0x0, %al
callq 0x3070
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3190
movq %rax, %rcx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jge 0x61f4
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
je 0x61e4
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %esi
leaq 0x709d(%rip), %rdi      # 0xd19c
movb $0x0, %al
callq 0x3070
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3190
movq %rax, %rcx
movl -0x48(%rbp), %eax
cmpl %ecx, %eax
jge 0x61b9
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x61b9
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x6700
movl -0x4c(%rbp), %esi
movq (%rax), %rax
movq 0x20(%rax), %rdx
leaq 0x7038(%rip), %rdi      # 0xd1a1
movb $0x0, %al
callq 0x3070
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x6700
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x61a9
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x6700
movq (%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x7009(%rip), %rdi      # 0xd1ab
movb $0x0, %al
callq 0x3070
leaq 0x793c(%rip), %rdi      # 0xdaec
movb $0x0, %al
callq 0x3070
jmp 0x61db
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x6700
movq (%rax), %rax
movq 0x20(%rax), %rsi
leaq 0x6fe5(%rip), %rdi      # 0xd1b9
movb $0x0, %al
callq 0x3070
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x61e6
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x60ba
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x6251
movq -0x20(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x66e0
movq (%rax), %rax
movq (%rax), %rsi
leaq 0x6fa3(%rip), %rdi      # 0xd1c0
movb $0x0, %al
callq 0x3070
movq -0x20(%rbp), %rdi
movslq -0x38(%rbp), %rsi
callq 0x66e0
movq (%rax), %rax
movq 0x10(%rax), %rsi
leaq 0x6f85(%rip), %rdi      # 0xd1c4
movb $0x0, %al
callq 0x3070
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x61fb
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)