// File: pelrun[P]aft/optionParser.c
// Function: addOption
void addOption(struct SOptionOut **cmdOption, char **argv, struct SOption *option)
{
	int nbCmdOption=0;
	int i;
	struct SOptionOut *newCmdOption;
	

	//compte le nombre d'option possibles
	if (*cmdOption != NULL)
	{
		while ((*cmdOption)[nbCmdOption].shortName != 0)
			nbCmdOption++;
	}

	newCmdOption = (struct SOptionOut*)malloc((nbCmdOption+2)*sizeof(struct SOptionOut));
	if (!newCmdOption)
	{
		printf( "MALLOC ERROR !  %s : %d \n", __FILE__, __LINE__) ;
		printf(" nb : %d \n size : %d\ntot : %d \n", nbCmdOption+2, sizeof(struct SOptionOut), (nbCmdOption+2)*sizeof(struct SOptionOut));
		exit (-1);
	}

	if (nbCmdOption != 0)
	{
		memcpy(newCmdOption,*cmdOption,(nbCmdOption)*sizeof(struct SOptionOut));
	}
	
	newCmdOption[nbCmdOption].shortName = option->shortName;
	newCmdOption[nbCmdOption].argc = 0;
	if (option->nbArgs != 0)
	{
		for (i=0;i<option->nbArgs;i++)
		{
			addArgv(&newCmdOption[nbCmdOption].argc,&newCmdOption[nbCmdOption].argv,argv[i]);
		}
	}
	else
	{
		newCmdOption[nbCmdOption].argv = NULL;
	}
	newCmdOption[nbCmdOption+1].shortName=0;
	newCmdOption[nbCmdOption+1].argc=0;
	newCmdOption[nbCmdOption+1].argv=NULL;

	if (*cmdOption != NULL)
		free(*cmdOption);
	*cmdOption = newCmdOption;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0xd91e
jmp 0xd8f7
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xd91c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xd8f7
jmp 0xd91e
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rdi
shlq $0x4, %rdi
callq 0x44b0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xd985
leaq 0x813d(%rip), %rdi      # 0x15a7f
leaq 0x80a9(%rip), %rsi      # 0x159f2
movl $0xba, %edx
movb $0x0, %al
callq 0x4060
movl -0x1c(%rbp), %esi
addl $0x2, %esi
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rcx
shlq $0x4, %rcx
leaq 0x812a(%rip), %rdi      # 0x15a99
movl $0x10, %edx
movb $0x0, %al
callq 0x4060
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x4430
cmpl $0x0, -0x1c(%rbp)
je 0xd9a3
movq -0x28(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
callq 0x4260
movq -0x18(%rbp), %rax
movb (%rax), %cl
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movb %cl, (%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18(%rax)
je 0xda31
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0xda2f
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
addq $0x4, %rdi
movq -0x28(%rbp), %rsi
movslq -0x1c(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0xd100
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xd9e1
jmp 0xda48
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x28(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
je 0xdaac
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x4420
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)