// File: /workspace/github_cpp_makefile_star2_O2/trapexit[P]bbf/src/options.cpp
// Function: Options::parse(int, char* const*)
AppError
Options::parse(const int argc,
               char * const argv[])
{
  static const char short_options[] = "hqft:r:s:S:e:o:i:c:";
  static const struct option long_options[] =
    {
      {"help",              no_argument, NULL, 'h'},
      {"quiet",             no_argument, NULL, 'q'},
      {"force",             no_argument, NULL, 'f'},
      {"rwtype",      required_argument, NULL, 't'},
      {"retries",     required_argument, NULL, 'r'},
      {"start-block", required_argument, NULL, 's'},
      {"end-block",   required_argument, NULL, 'e'},
      {"stepping",    required_argument, NULL, 'S'},
      {"output",      required_argument, NULL, 'o'},
      {"input",       required_argument, NULL, 'i'},
      {"captcha",     required_argument, NULL, 'c'},
      {"max-errors",  required_argument, NULL, 'M'},
      {NULL,                          0, NULL,   0}
    };

  if(argc == 1)
    {
      usage(std::cout);
      return AppError::success();
    }

  opterr = 0;
  while(true)
    {
      int rv;
      AppError error;

      rv = getopt_long(argc,argv,short_options,long_options,NULL);
      if(rv == -1)
        break;

      error = process_arg(argc,argv,rv);
      if(!error.succeeded())
        return error;
    }

  if(argc == optind)
    return AppError::argument_required("instruction");
  if(argc == (optind + 1))
    return AppError::argument_required("target");

  instruction = instr_from_string(argv[optind]);
  device      = argv[optind+1];

  return validate();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, 0x18(%rsp)
movq %rdi, %rbx
cmpl $0x1, %edx
jne 0xcc3d
callq 0xca58
movq %rbx, %rdi
callq 0xb6d0
jmp 0xcd9d
movq %rcx, %r15
movl %edx, %ebp
movq 0x1437f(%rip), %rax     # 0x20fc8
andl $0x0, (%rax)
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rbx), %r14
leaq 0x20(%rsp), %r13
andq $0x0, (%rbx)
movq %r14, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movb $0x0, 0x18(%rbx)
movl %ebp, %edi
movq %r15, %rsi
leaq 0x5f25(%rip), %rdx      # 0x12ba0
leaq 0x13f6e(%rip), %rcx     # 0x20bf0
xorl %r8d, %r8d
callq 0x46e0
pushq $0x3
popq %r12
cmpl $-0x1, %eax
je 0xccce
movq %r13, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rcx
movl %eax, %r8d
callq 0xc660
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5284
leaq 0x28(%rsp), %rdi
callq 0x4200
movq %rbx, %rdi
callq 0xb4c2
xorb $0x1, %al
movzbl %al, %r12d
testb %r12b, %r12b
jne 0xccd8
movq 0x10(%rsp), %rdi
callq 0x4200
testl %r12d, %r12d
je 0xcc5e
cmpl $0x1, %r12d
je 0xcd9d
movq 0x142d2(%rip), %r12     # 0x20fc0
movslq (%r12), %rax
cmpl %ebp, %eax
jne 0xcd1b
leaq 0x60b7(%rip), %rsi      # 0x12db4
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5cd4
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xb71e
jmp 0xcd45
leal 0x1(%rax), %ecx
cmpl %ebp, %ecx
jne 0xcd51
leaq 0x6097(%rip), %rsi      # 0x12dc0
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x5cd4
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xb71e
leaq 0x20(%rsp), %rdi
callq 0x4200
jmp 0xcd9d
movq (%r15,%rax,8), %rsi
leaq 0x48(%rsp), %r14
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x5cd4
movq %r14, %rsi
callq 0xca6c
movq 0x18(%rsp), %r13
movl %eax, (%r13)
movq %r14, %rdi
callq 0x4200
movslq (%r12), %rax
movq 0x8(%r15,%rax,8), %rsi
leaq 0x8(%r13), %rdi
callq 0x4790
movq %rbx, %rdi
movq %r13, %rsi
callq 0xcdda
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcdb3
jmp 0xcdbd
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0xcdcc
movq %rax, %rbx
jmp 0xcdd1
jmp 0xcdc4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x4200
movq %rbx, %rdi
callq 0x4730
nop