// File: jgeumlek[P]moltengamepadctl/source/main.cpp
// Function: parse_opts(options&, int, char**)
int parse_opts(options& options, int argc, char* argv[]) {

  int c = 0;

  static struct option long_options[] = {
    {"help",          0,    0,  'h'},
    {"version",       0,    0,  'v'},
    {"socket-path",   1,    0,  'S'},
    {"exec",          1,    0,  'e'},
    {"interactive",   0,    0,  'i'},
    {0,               0,    0,    0},
  };
  int long_index;
  while (c != -1) {
    c = getopt_long(argc, argv, "hve:S:i", long_options, &long_index);
    switch (c) {
    case 0:
      break;
    case 'h':
      print_usage(argv[0]);
      return 10;
      break;
    case 'v':
      print_version();
      return 10;
      break;
    case 'S':
      options.socket_path = std::string(optarg);
      break;
    case 'e':
      options.eval_commands.push_back(std::string(optarg));
      break;
    case 'i':
      options.interactive = true;
      break;
    }

  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
je 0x4fcc
movl -0x14(%rbp), %edi
movq -0x20(%rbp), %rsi
leaq 0x94e8(%rip), %rdx      # 0xe2ed
leaq 0x10474(%rip), %rcx     # 0x15280
leaq -0x28(%rbp), %r8
callq 0x3420
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x88(%rbp)
testl %eax, %eax
je 0x4e73
jmp 0x4e27
movl -0x88(%rbp), %eax
subl $0x53, %eax
je 0x4ea1
jmp 0x4e34
movl -0x88(%rbp), %eax
subl $0x65, %eax
je 0x4f19
jmp 0x4e45
movl -0x88(%rbp), %eax
subl $0x68, %eax
je 0x4e78
jmp 0x4e52
movl -0x88(%rbp), %eax
subl $0x69, %eax
je 0x4fbf
jmp 0x4e63
movl -0x88(%rbp), %eax
subl $0x76, %eax
je 0x4e90
jmp 0x4fc7
jmp 0x4fc7
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x5240
movl $0xa, -0x4(%rbp)
jmp 0x4fd3
callq 0x5200
movl $0xa, -0x4(%rbp)
jmp 0x4fd3
movq 0x10108(%rip), %rax     # 0x14fb0
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x3480
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0x3370
jmp 0x4edb
movq -0x10(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3330
leaq -0x48(%rbp), %rdi
callq 0x31b0
leaq -0x49(%rbp), %rdi
callq 0x32e0
jmp 0x4fc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x32e0
jmp 0x4fdf
movq -0x10(%rbp), %rax
addq $0x20, %rax
movq %rax, -0xb0(%rbp)
movq 0x10081(%rip), %rax     # 0x14fb0
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x3480
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x3370
jmp 0x4f65
movq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x63f0
jmp 0x4f77
leaq -0x80(%rbp), %rdi
callq 0x31b0
leaq -0x81(%rbp), %rdi
callq 0x32e0
jmp 0x4fc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4fb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31b0
leaq -0x81(%rbp), %rdi
callq 0x32e0
jmp 0x4fdf
movq -0x10(%rbp), %rax
movb $0x1, 0x38(%rax)
jmp 0x4ded
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x3470
nopl (%rax,%rax)