// File: /workspace/github_cpp_makefile_star2_O1/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, 0x28(%rsp)
movq %rdi, %rbx
cmpl $0x1, %edx
jne 0xfa8e
movq 0x14548(%rip), %rdi     # 0x23fb8
leaq 0x7360(%rip), %rsi      # 0x16dd7
movl $0xc22, %edx            # imm = 0xC22
callq 0x4500
movq %rbx, %rdi
callq 0xdd7c
jmp 0xfc70
movq %rcx, %r15
movl %edx, %ebp
movq 0x1452e(%rip), %rax     # 0x23fc8
movl $0x0, (%rax)
leaq 0x8(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x18(%rbx), %r14
xorl %r13d, %r13d
movq %r13, (%rbx)
movq %r14, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movb $0x0, 0x18(%rbx)
movl %ebp, %edi
movq %r15, %rsi
leaq 0x70b5(%rip), %rdx      # 0x16b80
leaq 0x1410e(%rip), %rcx     # 0x23be0
xorl %r8d, %r8d
callq 0x46a0
cmpl $-0x1, %eax
je 0xfb39
movq %rsp, %rdi
movq 0x28(%rsp), %rsi
movq %r15, %rcx
movl %eax, %r8d
callq 0xf330
movq (%rsp), %rax
movq %rax, (%rbx)
movq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4540
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xfb24
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x44b0
movq %rbx, %rdi
callq 0xd9da
movl %eax, %r13d
xorb $0x1, %r13b
movzbl %r13b, %r12d
jmp 0xfb3f
movl $0x3, %r12d
testb %r13b, %r13b
jne 0xfb5c
movq 0x30(%rsp), %rax
movq (%rax), %rdi
cmpq %r14, %rdi
je 0xfb5c
movq (%r14), %rsi
incq %rsi
callq 0x44b0
testl %r12d, %r12d
je 0xfaad
cmpl $0x1, %r12d
je 0xfc70
movq 0x1444a(%rip), %r12     # 0x23fc0
movslq (%r12), %rax
cmpl %ebp, %eax
jne 0xfbaa
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x7206(%rip), %rsi      # 0x16d94
leaq 0x720a(%rip), %rdx      # 0x16d9f
movq %rsp, %rdi
callq 0x75e0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xddf8
jmp 0xfbdb
leal 0x1(%rax), %ecx
cmpl %ebp, %ecx
jne 0xfbf7
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x71df(%rip), %rsi      # 0x16da0
leaq 0x71de(%rip), %rdx      # 0x16da6
movq %rsp, %rdi
callq 0x75e0
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xddf8
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0xfc70
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x44b0
jmp 0xfc70
movq (%r15,%rax,8), %rsi
leaq 0x38(%rsp), %r14
movq %rsp, %rdx
movq %r14, %rdi
callq 0xfe6c
movq %r14, %rsi
callq 0xf850
movq 0x28(%rsp), %rcx
movl %eax, (%rcx)
movq (%r14), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xfc34
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x44b0
movslq (%r12), %rax
movq 0x8(%r15,%rax,8), %r14
movq 0x28(%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 0xfcc4
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfc86
jmp 0xfc99
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0xfcbb
movq 0x10(%rsp), %rsi
jmp 0xfcb3
movq %rax, %rbx
jmp 0xfcbb
jmp 0xfca0
movq %rax, %rbx
movq 0x30(%rsp), %rax
movq (%rax), %rdi
cmpq %r14, %rdi
je 0xfcbb
movq (%r14), %rsi
incq %rsi
callq 0x44b0
movq %rbx, %rdi
callq 0x46f0
nop