// File: trapexit[P]bbf/src/options.cpp
// Function: Options::process_arg(int, char const* const*, int)
AppError
Options::process_arg(const int          argc,
                     const char * const argv[],
                     const int          opt)
{
  switch(opt)
    {
    case 'f':
      force = true;
      break;
    case 'q':
      quiet++;
      break;
    case 'r':
      errno = 0;
      retries = ::strtol(optarg,NULL,BASE10);
      if(((errno == ERANGE) && (retries == LONG_MAX)) || (retries < 1))
        return AppError::argument_invalid("retries invalid");
      break;
    case 's':
      errno = 0;
      start_block = ::strtoull(optarg,NULL,BASE10);
      if((start_block == ULLONG_MAX) && (errno == ERANGE))
        return AppError::argument_invalid("start block value is invalid");
      break;
    case 'e':
      errno = 0;
      end_block = ::strtoull(optarg,NULL,BASE10);
      if((end_block == ULLONG_MAX) && (errno == ERANGE))
        return AppError::argument_invalid("end block value is invalid");
      break;
    case 'S':
      errno = 0;
      stepping = ::strtoull(optarg,NULL,BASE10);
      if((stepping == ULLONG_MAX) && (errno == ERANGE))
        return AppError::argument_invalid("invalid stepping");
      if((stepping > 65536) || (stepping < 1))
        return AppError::argument_invalid("stepping must be >= 1 && <= 65536");
      break;
    case 'M':
      errno = 0;
      max_errors = ::strtoull(optarg,NULL,BASE10);
      if((max_errors == ULLONG_MAX) && (errno == ERANGE))
        return AppError::argument_invalid("max errors value is invalid");
      break;
    case 'o':
      output_file = optarg;
      break;
    case 'i':
      input_file = optarg;
      break;
    case 'c':
      captcha = optarg;
      break;
    case 't':
      if(!strcmp(optarg,"os"))
        rwtype = OS;
      else if(!strcmp(optarg,"ata"))
        rwtype = ATA;
      else
        return AppError::argument_invalid("valid rwtype values are 'os' or 'ata'");
      break;
    case 'h':
      usage(std::cout);
      return AppError::success();
    case '?':
      return AppError::argument_invalid(std::string(argv[optind-1]) + " is unknown");
    }

  return AppError::success();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x1b8(%rbp)
movq %rdi, %rax
movq %rax, -0x1b0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl -0x24(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x1a0(%rbp)
subl $0x35, %eax
ja 0x19cd1
movq -0x1a0(%rbp), %rax
leaq 0xa610(%rip), %rcx      # 0x23b10
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x1a8(%rbp), %rax
movb $0x1, 0xb8(%rax)
jmp 0x19cd1
movq -0x1a8(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x28(%rax)
jmp 0x19cd1
callq 0x4070
movl $0x0, (%rax)
movq 0x1da5d(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x4700
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq %rcx, 0x30(%rax)
callq 0x4070
cmpl $0x22, (%rax)
jne 0x19583
movq -0x1a8(%rbp), %rax
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
cmpq %rcx, 0x30(%rax)
je 0x19595
movq -0x1a8(%rbp), %rax
cmpq $0x1, 0x30(%rax)
jge 0x19618
leaq -0x49(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x48a0
movq -0x1c0(%rbp), %rdx
leaq 0xa691(%rip), %rsi      # 0x23c44
leaq -0x48(%rbp), %rdi
callq 0x7620
jmp 0x195be
movq -0x1b8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x17510
jmp 0x195d0
leaq -0x48(%rbp), %rdi
callq 0x4300
leaq -0x49(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1960a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4300
leaq -0x49(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19cd1
callq 0x4070
movl $0x0, (%rax)
movq 0x1d971(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x46b0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq %rcx, 0x38(%rax)
cmpq $-0x1, 0x38(%rax)
jne 0x196f3
callq 0x4070
cmpl $0x22, (%rax)
jne 0x196f3
leaq -0x81(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x48a0
movq -0x1c8(%rbp), %rdx
leaq 0xa5cc(%rip), %rsi      # 0x23c54
leaq -0x80(%rbp), %rdi
callq 0x7620
jmp 0x19693
movq -0x1b8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x17510
jmp 0x196a5
leaq -0x80(%rbp), %rdi
callq 0x4300
leaq -0x81(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x196e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4300
leaq -0x81(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19cd1
callq 0x4070
movl $0x0, (%rax)
movq 0x1d896(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x46b0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq %rcx, 0x40(%rax)
cmpq $-0x1, 0x40(%rax)
jne 0x197da
callq 0x4070
cmpl $0x22, (%rax)
jne 0x197da
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x48a0
movq -0x1d0(%rbp), %rdx
leaq 0xa50e(%rip), %rsi      # 0x23c71
leaq -0xa8(%rbp), %rdi
callq 0x7620
jmp 0x19771
movq -0x1b8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x17510
jmp 0x19786
leaq -0xa8(%rbp), %rdi
callq 0x4300
leaq -0xa9(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x197c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x4300
leaq -0xa9(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19cd1
callq 0x4070
movl $0x0, (%rax)
movq 0x1d7af(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x46b0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq %rcx, 0x48(%rax)
cmpq $-0x1, 0x48(%rax)
jne 0x198c1
callq 0x4070
cmpl $0x22, (%rax)
jne 0x198c1
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x48a0
movq -0x1d8(%rbp), %rdx
leaq 0xa442(%rip), %rsi      # 0x23c8c
leaq -0xd0(%rbp), %rdi
callq 0x7620
jmp 0x19858
movq -0x1b8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x17510
jmp 0x1986d
leaq -0xd0(%rbp), %rdi
callq 0x4300
leaq -0xd1(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x198b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4300
leaq -0xd1(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
movq -0x1a8(%rbp), %rax
cmpq $0x10000, 0x48(%rax)    # imm = 0x10000
ja 0x198e4
movq -0x1a8(%rbp), %rax
cmpq $0x1, 0x48(%rax)
jae 0x1997c
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x48a0
movq -0x1e0(%rbp), %rdx
leaq 0xa398(%rip), %rsi      # 0x23c9d
leaq -0xf8(%rbp), %rdi
callq 0x7620
jmp 0x19913
movq -0x1b8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x17510
jmp 0x19928
leaq -0xf8(%rbp), %rdi
callq 0x4300
leaq -0xf9(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x1996b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4300
leaq -0xf9(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19cd1
callq 0x4070
movl $0x0, (%rax)
movq 0x1d60d(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x46b0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq %rcx, 0x50(%rax)
cmpq $-0x1, 0x50(%rax)
jne 0x19a63
callq 0x4070
cmpl $0x22, (%rax)
jne 0x19a63
leaq -0x121(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x48a0
movq -0x1e8(%rbp), %rdx
leaq 0xa2d3(%rip), %rsi      # 0x23cbf
leaq -0x120(%rbp), %rdi
callq 0x7620
jmp 0x199fa
movq -0x1b8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x17510
jmp 0x19a0f
leaq -0x120(%rbp), %rdi
callq 0x4300
leaq -0x121(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x19a52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x4300
leaq -0x121(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19cd1
movq -0x1a8(%rbp), %rdi
movq 0x1d52a(%rip), %rax     # 0x36fa0
movq (%rax), %rsi
addq $0x58, %rdi
callq 0x46d0
jmp 0x19cd1
movq -0x1a8(%rbp), %rdi
movq 0x1d50b(%rip), %rax     # 0x36fa0
movq (%rax), %rsi
addq $0x78, %rdi
callq 0x46d0
jmp 0x19cd1
movq -0x1a8(%rbp), %rdi
movq 0x1d4ec(%rip), %rax     # 0x36fa0
movq (%rax), %rsi
addq $0x98, %rdi
callq 0x46d0
jmp 0x19cd1
movq 0x1d4d1(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
leaq 0x97b2(%rip), %rsi      # 0x2328b
callq 0x46f0
cmpl $0x0, %eax
jne 0x19af6
movq -0x1a8(%rbp), %rax
movl $0x1, 0x4(%rax)
jmp 0x19bbe
movq 0x1d4a3(%rip), %rax     # 0x36fa0
movq (%rax), %rdi
leaq 0xc5e5(%rip), %rsi      # 0x260ec
callq 0x46f0
cmpl $0x0, %eax
jne 0x19b24
movq -0x1a8(%rbp), %rax
movl $0x0, 0x4(%rax)
jmp 0x19bbc
leaq -0x149(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x48a0
movq -0x1f0(%rbp), %rdx
leaq 0xa196(%rip), %rsi      # 0x23cdb
leaq -0x148(%rbp), %rdi
callq 0x7620
jmp 0x19b53
movq -0x1b8(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x17510
jmp 0x19b68
leaq -0x148(%rbp), %rdi
callq 0x4300
leaq -0x149(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x19bab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x4300
leaq -0x149(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
jmp 0x19bbe
jmp 0x19cd1
movq 0x1d3e6(%rip), %rdi     # 0x36fb0
callq 0x19d00
movq -0x1b8(%rbp), %rdi
callq 0x17420
jmp 0x19cdd
movq -0x20(%rbp), %rax
movq 0x1d3d5(%rip), %rcx     # 0x36fc0
movl (%rcx), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x200(%rbp)
leaq -0x191(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x48a0
movq -0x200(%rbp), %rsi
movq -0x1f8(%rbp), %rdx
leaq -0x190(%rbp), %rdi
callq 0x7620
jmp 0x19c2c
leaq 0xa0ce(%rip), %rdx      # 0x23d01
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x15f80
jmp 0x19c48
movq -0x1b8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x17510
jmp 0x19c5d
leaq -0x170(%rbp), %rdi
callq 0x4300
leaq -0x190(%rbp), %rdi
callq 0x4300
leaq -0x191(%rbp), %rdi
callq 0x45b0
jmp 0x19cdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x19cc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x19cb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x4300
leaq -0x190(%rbp), %rdi
callq 0x4300
leaq -0x191(%rbp), %rdi
callq 0x45b0
jmp 0x19ced
movq -0x1b8(%rbp), %rdi
callq 0x17420
movq -0x1b0(%rbp), %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x4890
nopw %cs:(%rax,%rax)