// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
movq %rsi, 0x30(%rsp)
movq %rdi, %rbx
cmpl $0x1, %edx
jne 0xf9a4
movq 0x14632(%rip), %rdi     # 0x23fb8
leaq 0x744a(%rip), %rsi      # 0x16dd7
movl $0xc22, %edx            # imm = 0xC22
callq 0x4500
movq %rbx, %rdi
callq 0xdce4
jmp 0xfb84
movq %rcx, %r15
movl %edx, %ebp
movq 0x14618(%rip), %rax     # 0x23fc8
movl $0x0, (%rax)
leaq 0x8(%rbx), %r12
leaq 0x18(%rbx), %r13
xorl %eax, %eax
movq %rax, (%rbx)
movq %r13, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movb $0x0, 0x18(%rbx)
movl %ebp, %edi
movq %r15, %rsi
leaq 0x71a5(%rip), %rdx      # 0x16b80
leaq 0x141fe(%rip), %rcx     # 0x23be0
xorl %r8d, %r8d
callq 0x46a0
cmpl $-0x1, %eax
je 0xfa4a
leaq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %r15, %rcx
movl %eax, %r8d
callq 0xf24c
movq 0x8(%rsp), %rax
movq %rax, (%rbx)
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x4540
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xfa35
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x44b0
movq %rbx, %rdi
callq 0xd942
xorb $0x1, %al
movzbl %al, %r14d
testb %r14b, %r14b
je 0xfa50
jmp 0xfa65
movl $0x3, %r14d
movq (%r12), %rdi
cmpq %r13, %rdi
je 0xfa65
movq (%r13), %rsi
incq %rsi
callq 0x44b0
testl %r14d, %r14d
je 0xf9be
cmpl $0x1, %r14d
je 0xfb84
movq 0x14541(%rip), %r12     # 0x23fc0
movslq (%r12), %rax
cmpl %ebp, %eax
jne 0xfab7
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x72fd(%rip), %rsi      # 0x16d94
leaq 0x7301(%rip), %rdx      # 0x16d9f
leaq 0x8(%rsp), %rdi
callq 0x7618
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xdd60
jmp 0xfaec
leal 0x1(%rax), %ecx
cmpl %ebp, %ecx
jne 0xfb09
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x72d2(%rip), %rsi      # 0x16da0
leaq 0x72d1(%rip), %rdx      # 0x16da6
leaq 0x8(%rsp), %rdi
callq 0x7618
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xdd60
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xfb84
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x44b0
jmp 0xfb84
movq (%r15,%rax,8), %rsi
leaq 0x38(%rsp), %r14
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0xfd7e
movq %r14, %rsi
callq 0xf766
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movq (%r14), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xfb48
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x44b0
movslq (%r12), %rax
movq 0x8(%r15,%rax,8), %r14
movq 0x30(%rsp), %r13
leaq 0x8(%r13), %r15
movq 0x10(%r13), %r12
movq %r14, %rdi
callq 0x4200
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x4640
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfbd6
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfb9a
jmp 0xfbae
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xfbcd
movq 0x18(%rsp), %rsi
jmp 0xfbc5
movq %rax, %rbx
jmp 0xfbcd
jmp 0xfbb5
movq %rax, %rbx
movq (%r12), %rdi
cmpq %r13, %rdi
je 0xfbcd
movq (%r13), %rsi
incq %rsi
callq 0x44b0
movq %rbx, %rdi
callq 0x46f0
nop