// File: /workspace/github_cpp_makefile_star2_O3/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 $0x418, %rsp            # imm = 0x418
movq %rdx, 0x8(%rsp)
movq %rdi, %rbx
movl $0x1, (%rsp)
movl %esi, 0x4(%rsp)
cmpl $0x2, %esi
jl 0x1c950
movl $0x1, %eax
leaq 0x210(%rsp), %r13
leaq 0x10(%rsp), %rbp
cltq
movq 0x8(%rsp), %rcx
movq (%rcx,%rax,8), %r15
movq (%rbx), %r14
cmpq %rbx, %r14
je 0x1c883
movq 0x10(%r14), %r12
movq %r12, %rdi
callq 0x1acda
movq %r13, %rdi
leaq 0x14e72(%rip), %rsi     # 0x316ac
movq %rax, %rdx
xorl %eax, %eax
callq 0x6700
movq %r12, %rdi
callq 0x1acd6
movsbl %al, %edx
movq %rbp, %rdi
leaq 0x14e57(%rip), %rsi     # 0x316b0
xorl %eax, %eax
callq 0x6700
movq %r15, %rdi
movq %r13, %rsi
callq 0x6590
testl %eax, %eax
je 0x1c8bb
movq %r15, %rdi
movq %rbp, %rsi
callq 0x6590
testl %eax, %eax
je 0x1c8bb
movq (%r14), %r14
jmp 0x1c81f
movl $0x13, %edx
movq 0x296f1(%rip), %r14     # 0x45f80
movq %r14, %rdi
leaq 0x14e42(%rip), %rsi     # 0x316db
callq 0x6690
testq %r15, %r15
je 0x1c8eb
movq %r15, %rdi
callq 0x6270
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6690
jmp 0x1c903
movq %r12, %rdi
callq 0x1ad12
movq (%r12), %rax
movq %r12, %rdi
movq %rsp, %rsi
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rcx
callq *0x10(%rax)
testb %al, %al
je 0x1c9f5
movq %r12, %rdi
callq 0x1ad1e
jmp 0x1c93e
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x67b0
movl $0x1a, %edx
movq %r14, %rdi
leaq 0x14ddd(%rip), %rsi     # 0x316ef
callq 0x6690
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6730
movsbl %al, %esi
movq %r14, %rdi
callq 0x63c0
movq %rax, %rdi
callq 0x6340
movl (%rsp), %eax
incl %eax
movl %eax, (%rsp)
cmpl 0x4(%rsp), %eax
jl 0x1c811
movq (%rbx), %r15
cmpq %rbx, %r15
je 0x1c9a1
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x1acfa
testb %al, %al
jne 0x1c974
movq %r14, %rdi
callq 0x1ad18
testb %al, %al
je 0x1c9b3
movq %r14, %rdi
callq 0x1ad18
testb %al, %al
je 0x1c99c
movq %r14, %rdi
callq 0x1ad00
testb %al, %al
jne 0x1c99c
movq %r14, %rdi
callq 0x1ad24
testb %al, %al
je 0x1ca67
movq (%r15), %r15
jmp 0x1c953
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x295c6(%rip), %r15     # 0x45f80
leaq 0x14d49(%rip), %rsi     # 0x3170a
movl $0x13, %edx
movq %r15, %rdi
callq 0x6690
movq %r14, %rdi
callq 0x1acda
testq %rax, %rax
jne 0x1ca3e
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x67b0
jmp 0x1ca5b
movq 0x29584(%rip), %r14     # 0x45f80
leaq 0x14cb1(%rip), %rsi     # 0x316b4
movl $0xf, %edx
movq %r14, %rdi
callq 0x6690
movq %r12, %rdi
callq 0x1acda
testq %rax, %rax
jne 0x1caa9
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x67b0
jmp 0x1cac6
movq %rax, %r14
movq %rax, %rdi
callq 0x6270
movq 0x29530(%rip), %rdi     # 0x45f80
movq %r14, %rsi
movq %rax, %rdx
callq 0x6690
leaq 0x14cbc(%rip), %rsi     # 0x3171e
jmp 0x1cb1a
movq 0x29512(%rip), %r15     # 0x45f80
leaq 0x14c95(%rip), %rsi     # 0x3170a
movl $0x13, %edx
movq %r15, %rdi
callq 0x6690
movq %r14, %rdi
callq 0x1acda
testq %rax, %rax
jne 0x1caf6
movq (%r15), %rax
movq -0x18(%rax), %rax
leaq (%r15,%rax), %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x67b0
jmp 0x1cb13
movq %rax, %r15
movq %rax, %rdi
callq 0x6270
movq 0x294c5(%rip), %rdi     # 0x45f80
movq %r15, %rsi
movq %rax, %rdx
callq 0x6690
leaq 0x14bf7(%rip), %rsi     # 0x316c4
movl $0x16, %edx
movq %r14, %rdi
callq 0x6690
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6730
movsbl %al, %esi
movq %r14, %rdi
jmp 0x1cb41
movq %rax, %r14
movq %rax, %rdi
callq 0x6270
movq 0x29478(%rip), %rdi     # 0x45f80
movq %r14, %rsi
movq %rax, %rdx
callq 0x6690
leaq 0x14c16(%rip), %rsi     # 0x31730
movl $0x11, %edx
movq %r15, %rdi
callq 0x6690
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x6730
movsbl %al, %esi
movq %r15, %rdi
callq 0x63c0
movq %rax, %rdi
callq 0x6340
movq %rbx, %rdi
callq 0x1c462
nop