// File: /workspace/github_cpp_makefile_star2_O2/jliesch[P]ofxget/clap/src/cmdline.cc
// Function: CmdLine::parse(int, char**)
void CmdLine::parse(int argc, char* argv[])
{
  CmdArg*            cmd;
  CmdArgListIterator it;

  for (int i = 1; i < argc; i++)
    {
      char* arg = argv[i];
      bool found = false;
      for (it = _cmdList.begin(); (it != _cmdList.end())&& !found; it++)
	{
	  cmd = *it;
	  char cmdWord[512], cmdChar[512];
	  sprintf(cmdWord, "-%s", cmd->getKeyword());
	  sprintf(cmdChar, "-%c", cmd->getOptChar());
	  if (!strcmp(arg, cmdWord) || !strcmp(arg, cmdChar))
	    {
	      cmd->setFound();
	      if (!cmd->getValue(&i, argc, argv))
		{
		  cout << "Error: switch -" << cmd->getKeyword()
		       << " must take an argument" << endl;
		  usage();
		}
	      else
		{
		  cmd->setValFound();
		}
	      found = true;
	    }
	}
      if (!found)
	{
	  cout << "Warning: argument \"" << arg
	       << "\" looks strange, ignoring." << endl;
	}
    }
  
  for (it = _cmdList.begin(); it != _cmdList.end(); it++)
    {
      cmd = *it;
      if (!cmd->isOpt()) // i.e required
	if (!cmd->isFound())
	  {
	    cout << "Error: the switch -" << cmd->getKeyword()
		 << " must be supplied" << endl;
	    usage();
	  }
      
      if (cmd->isFound() && !cmd->isValOpt()) // i.e need value
	if (!cmd->isValFound())
	  {
	    cout << "Error: the switch -" << cmd->getKeyword()
		 << " must take a vlue" << endl;
	    usage();
	  }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, 0x18(%rsp)
movl %esi, %ebp
movq %rdi, 0x8(%rsp)
pushq $0x1
popq %rax
leaq 0x220(%rsp), %r12
leaq 0x20(%rsp), %r15
movl %eax, 0x14(%rsp)
cmpl %ebp, %eax
jge 0x17b71
cltq
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %r13
xorl %eax, %eax
movq 0x8(%rsp), %r14
movq (%r14), %r14
cmpq 0x8(%rsp), %r14
je 0x17b2d
testb $0x1, %al
jne 0x17b2d
movq 0x10(%r14), %rbx
movq %rbx, %rdi
callq 0x16580
movq %r12, %rdi
leaq 0x13c0b(%rip), %rsi     # 0x2b6bc
movq %rax, %rdx
xorl %eax, %eax
callq 0x6720
movq %rbx, %rdi
callq 0x1657c
movsbl %al, %edx
movq %r15, %rdi
leaq 0x13bf0(%rip), %rsi     # 0x2b6c0
xorl %eax, %eax
callq 0x6720
movq %r13, %rdi
movq %r12, %rsi
callq 0x65c0
testl %eax, %eax
je 0x17af9
movq %r13, %rdi
movq %r15, %rsi
callq 0x65c0
testl %eax, %eax
je 0x17af9
xorl %eax, %eax
jmp 0x17a85
movq %rbx, %rdi
callq 0x165b8
movq (%rbx), %rax
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
movl %ebp, %edx
movq 0x18(%rsp), %rcx
callq *0x10(%rax)
testb %al, %al
je 0x17c08
movq %rbx, %rdi
callq 0x165c4
movb $0x1, %al
jmp 0x17a85
testb $0x1, %al
jne 0x17b66
movq 0x2b458(%rip), %rdi     # 0x42f90
leaq 0x13bac(%rip), %rsi     # 0x2b6eb
callq 0x6410
movq %rax, %rdi
movq %r13, %rsi
callq 0x6410
movq %rax, %rdi
leaq 0x13ba6(%rip), %rsi     # 0x2b6ff
callq 0x6410
movq %rax, %rdi
callq 0x6700
movl 0x14(%rsp), %eax
incl %eax
jmp 0x17a67
movq 0x8(%rsp), %r14
movq (%r14), %r14
cmpq 0x8(%rsp), %r14
je 0x17bf6
movq 0x10(%r14), %rbx
movq %rbx, %rdi
callq 0x165a0
testb %al, %al
jne 0x17ba0
movq %rbx, %rdi
callq 0x165be
testb %al, %al
je 0x17c52
movq %rbx, %rdi
callq 0x165be
testb %al, %al
je 0x17b76
movq %rbx, %rdi
callq 0x165a6
testb %al, %al
jne 0x17b76
movq %rbx, %rdi
callq 0x165ca
testb %al, %al
jne 0x17b76
movq 0x2b3c5(%rip), %rdi     # 0x42f90
leaq 0x13b48(%rip), %rsi     # 0x2b71a
callq 0x6410
movq %rax, %r14
movq %rbx, %rdi
callq 0x16580
movq %r14, %rdi
movq %rax, %rsi
callq 0x6410
leaq 0x13b4c(%rip), %rsi     # 0x2b740
jmp 0x17c38
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2b381(%rip), %rdi     # 0x42f90
leaq 0x13aae(%rip), %rsi     # 0x2b6c4
callq 0x6410
movq %rax, %r14
movq %rbx, %rdi
callq 0x16580
movq %r14, %rdi
movq %rax, %rsi
callq 0x6410
leaq 0x13a9c(%rip), %rsi     # 0x2b6d4
movq %rax, %rdi
callq 0x6410
movq %rax, %rdi
callq 0x6700
movq 0x8(%rsp), %rdi
callq 0x1785e
movq 0x2b337(%rip), %rdi     # 0x42f90
leaq 0x13aba(%rip), %rsi     # 0x2b71a
callq 0x6410
movq %rax, %r14
movq %rbx, %rdi
callq 0x16580
movq %r14, %rdi
movq %rax, %rsi
callq 0x6410
leaq 0x13aac(%rip), %rsi     # 0x2b72e
jmp 0x17c38