// File: /workspace/github_cpp_makefile_star2_O1/pelrun[P]aft/optionParser.c
// Function: parseCommandLineOption
int parseCommandLineOption(int *argc, char*** argv, struct SOption *option, struct SOptionOut **cmdOptionLine)
{


	int o,i;
	int nbOption=0;
	int *nbValOption;

	int nbArg = (*argc)-1;
	int iArgv = 1;

	//compte nb d'options
	while(option[nbOption].shortName != 0)
		nbOption++;

	//reserve memoire pour compter le nombre de valeur des options
	nbValOption = (int*)malloc(nbOption*sizeof(int));
	for (o=0;o<nbOption;o++)
	{
		nbValOption[o]=0;
	}

	//Securisation
	if ((*cmdOptionLine) == NULL)
	{
		*cmdOptionLine = (struct SOptionOut*)malloc(sizeof(struct SOptionOut));
		(*cmdOptionLine)[0].shortName=0;
		(*cmdOptionLine)[0].argc=0;
		(*cmdOptionLine)[0].argv=NULL;
	}


	//Lecture de la liste des arguments
	while (nbArg>0)
	{
		if (isOptionString((*argv)[iArgv]) != 0)
		{
			//verification si aide
			if (compareOptionString((*argv)[iArgv],'h',"help") == OPT_NO_ERROR)
			{
				free(nbValOption);
				RET_ERROR(DISPLAY_HELP, "Display help");
			}

			//recuperation option
			o = findOption((*argv)[iArgv],option);
			if (o == ERROR_UNKNOWN)
			{
				free(nbValOption);
				RET_ERROR( ERROR_UNKOPT, "Unknown option");
			}
			if (o == ERROR_UNKOPT)
			{
				// Begin like an option, but doesn't seems to be one
				nbArg--;
				iArgv++;
			}
			else
			{
				//option connue
				
				//verification nombre d'arguments minimum necessaires pour l'option
				if (nbArg <= option[o].nbArgs)
				{
					free(nbValOption);
					RET_ERROR( ERROR_OPTARG, "Wrong number of argument");
				}

				//ajout de l'option
				addOption(cmdOptionLine,&((*argv)[iArgv+1]),&option[o]);
	
				//consideration de la presence de cette option
				nbValOption[o]++;

				//suppression des arguments lus
				for (i=0;i<option[o].nbArgs + 1;i++)
				{
					removeArgv(argc,argv,iArgv);
					nbArg--;
				}
			}
		}
		else
		{
			//lecture d'une non option
			nbArg--;
			iArgv++;
		}
	}
	for (o=0;o<nbOption;o++)
	{
		if (!(option[o].nbMin == 0 && option[o].nbMax == 0))
		{
			if (option[o].nbMax != 0)
			{
				if (!((nbValOption[o] >= option[o].nbMin) && (nbValOption[o] <= option[o].nbMax)))
				{
					free(nbValOption);
					RET_ERROR( ERROR_OPTARG, "Wrong number of option");
				}
			}
			else
			{
				if (!(nbValOption[o] >= option[o].nbMin))
				{
					free(nbValOption);
					RET_ERROR( ERROR_OPTARG, "Wrong number of option");
				}
			}
		}
	}
	free(nbValOption);
	RET_ERROR(OPT_NO_ERROR, "No error");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r13
movl (%rdi), %eax
movl %eax, 0x4(%rsp)
movq $-0x1, %r14
movq $-0x4, %rbp
movq %rdx, %rax
incq %r14
addq $0x4, %rbp
cmpb $0x0, (%rax)
leaq 0x28(%rax), %rax
jne 0x93fa
movq %rbp, %rdi
callq 0x33d0
movq %rax, %r15
testq %r14, %r14
je 0x9427
movq %r15, %rdi
xorl %esi, %esi
movq %rbp, %rdx
callq 0x3180
movq %r13, 0x20(%rsp)
movq %r15, 0x8(%rsp)
movq 0x10(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x9460
movl $0x10, %edi
callq 0x33d0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movb $0x0, (%rax)
movl $0x0, 0x4(%rax)
movq $0x0, 0x8(%rax)
movl 0x4(%rsp), %r15d
cmpl $0x2, %r15d
jl 0x955f
decl %r15d
movl $0x1, %ebp
movq %rbx, 0x18(%rsp)
movq (%r12), %rax
movslq %ebp, %r13
movq (%rax,%r13,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x9548
movl $0x68, %esi
leaq 0x752f(%rip), %rdx      # 0x109cb
callq 0x8f66
testl %eax, %eax
je 0x95ff
movq (%r12), %rax
movq (%rax,%r13,8), %rdi
movq %rbx, %rsi
callq 0x9111
cmpl $-0x2, %eax
je 0x9548
cmpl $-0x1, %eax
je 0x963c
movslq %eax, %rcx
leaq (%rcx,%rcx,4), %rax
cmpl 0x18(%rbx,%rax,8), %r15d
jle 0x9679
movl %r15d, 0x4(%rsp)
leaq (%rbx,%rax,8), %r15
movq (%r12), %rax
leaq (%rax,%r13,8), %rsi
addq $0x8, %rsi
movq 0x10(%rsp), %rdi
movq %r15, %rdx
movq %rcx, %r13
callq 0x923d
movq 0x8(%rsp), %rax
incl (%rax,%r13,4)
cmpl $0x0, 0x18(%r15)
js 0x9558
xorl %eax, %eax
movq %r12, %rbx
movq 0x20(%rsp), %r12
movl %eax, %r13d
movq %r12, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x8e37
leal 0x1(%r13), %eax
cmpl 0x18(%r15), %r13d
jl 0x951c
movl 0x4(%rsp), %r15d
subl %eax, %r15d
movq %rbx, %r12
movq 0x18(%rsp), %rbx
jmp 0x954d
decl %r15d
incl %ebp
testl %r15d, %r15d
jg 0x947c
jmp 0x955f
movl 0x4(%rsp), %r15d
jmp 0x954d
testq %r14, %r14
movq 0x8(%rsp), %rdi
je 0x959e
addq $0x14, %rbx
xorl %eax, %eax
movl -0x4(%rbx), %ecx
testl %ecx, %ecx
jne 0x957b
cmpl $0x0, (%rbx)
je 0x9592
movl (%rbx), %edx
movl (%rdi,%rax,4), %esi
testl %edx, %edx
je 0x958e
cmpl %ecx, %esi
jl 0x95cc
cmpl %edx, %esi
jle 0x9592
jmp 0x95cc
cmpl %ecx, %esi
jl 0x95cc
incq %rax
addq $0x28, %rbx
cmpq %rax, %r14
jne 0x956f
callq 0x3350
movl $0x0, 0xcff3(%rip)      # 0x165a0
movabsq $0x726f727265206f4e, %rax # imm = 0x726F727265206F4E
movq %rax, 0xcff2(%rip)      # 0x165b0
movb $0x0, 0xcff3(%rip)      # 0x165b8
xorl %eax, %eax
jmp 0x96ae
callq 0x3350
movl $0xfffffffd, 0xcfc5(%rip) # imm = 0xFFFFFFFD
movabsq $0x6e6f6974706f20, %rax # imm = 0x6E6F6974706F20
movq %rax, 0xcfd3(%rip)      # 0x165bf
movups 0x74e3(%rip), %xmm0     # 0x10ad6
movaps %xmm0, 0xcfb6(%rip)     # 0x165b0
jmp 0x96a9
movq 0x8(%rsp), %rdi
callq 0x3350
movl $0x1, 0xcf8d(%rip)      # 0x165a0
movabsq $0x2079616c70736944, %rax # imm = 0x2079616C70736944
movq %rax, 0xcf8c(%rip)      # 0x165b0
movabsq $0x706c6568207961, %rax # imm = 0x706C6568207961
movq %rax, 0xcf80(%rip)      # 0x165b5
movl $0x1, %eax
jmp 0x96ae
movq 0x8(%rsp), %rdi
callq 0x3350
movl $0xfffffffe, 0xcf50(%rip) # imm = 0xFFFFFFFE
movabsq $0x206e776f6e6b6e55, %rax # imm = 0x206E776F6E6B6E55
movq %rax, 0xcf4f(%rip)      # 0x165b0
movabsq $0x6e6f6974706f20, %rax # imm = 0x6E6F6974706F20
movq %rax, 0xcf45(%rip)      # 0x165b7
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x96ae
movq 0x8(%rsp), %rdi
callq 0x3350
movl $0xfffffffd, 0xcf13(%rip) # imm = 0xFFFFFFFD
movups 0x7429(%rip), %xmm0     # 0x10abd
movaps %xmm0, 0xcf15(%rip)     # 0x165b0
movups 0x7424(%rip), %xmm0     # 0x10ac6
movups %xmm0, 0xcf10(%rip)     # 0x165b9
movl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq