// File: hzeller[P]gcode-multi-shell-extrude/config-values.cc
// Function: SetParametersFromCommandline(int, char**)
bool SetParametersFromCommandline(int argc, char *argv[]) {
  if (sRegisteredParameters == NULL)
    return true;

  std::string optstring;
  struct option *long_options = new option [ sRegisteredParameters->size() + 1 ];
  int opt_idx = 0;
  for (size_t i = 0; i < sRegisteredParameters->size(); ++i) {
    const Parameter *const p = (*sRegisteredParameters)[i];
    if (p->option_name == NULL && p->option_char == 0) {
      continue;
    }
    if (p->option_char != 0) {
      optstring.append(1, p->option_char);
      if (p->RequiresValue()) optstring.append(1, ':');
    }
    struct option *opt = &long_options[opt_idx++];
    opt->name = p->option_name;
    opt->has_arg = p->RequiresValue() ? 1 : 2;
    opt->flag = NULL;
    opt->val = i + 256;
  }
  const char *optstr = optstring.c_str();
  bool success = true;
  int opt;
  int arg_idx = 0;
  while ((opt = getopt_long(argc, argv, optstr, long_options, &arg_idx)) >= 0) {
    if (opt == '?') {
      success = false;
      break;
    }
    for (size_t i = 0; i < sRegisteredParameters->size(); ++i) {
      Parameter *const p = (*sRegisteredParameters)[i];
      if (opt == p->option_char || opt == (int) (i + 256)) {
        p->FromString(optarg);
      }
    }
  }
  delete [] long_options;
  return success;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, 0x2b5fe(%rip)     # 0x3b278
jne 0xfc85
movb $0x1, -0x1(%rbp)
jmp 0xff58
leaq -0x30(%rbp), %rdi
callq 0x3380
movq 0x2b5e3(%rip), %rdi     # 0x3b278
callq 0x100e0
incq %rax
movl $0x20, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x90(%rbp)
jmp 0xfcc1
movq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x2b58b(%rip), %rdi     # 0x3b278
callq 0x100e0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0xfe3d
movq 0x2b56c(%rip), %rdi     # 0x3b278
movq -0x50(%rbp), %rsi
callq 0x10100
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xfd53
movq -0x58(%rbp), %rax
movsbl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0xfd53
jmp 0xfe2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3180
jmp 0xff66
movq -0x58(%rbp), %rax
movsbl 0x10(%rax), %eax
cmpl $0x0, %eax
je 0xfdb2
movq -0x58(%rbp), %rax
movsbl 0x10(%rax), %edx
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x32d0
jmp 0xfd78
movq -0x58(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movb %al, -0x99(%rbp)
jmp 0xfd8d
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0xfd99
jmp 0xfdb0
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
movl $0x3a, %edx
callq 0x32d0
jmp 0xfdae
jmp 0xfdb0
jmp 0xfdb2
movq -0x38(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl %ecx, %edx
incl %edx
movl %edx, -0x48(%rbp)
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x60(%rbp), %rax
movq %rcx, (%rax)
movq -0x58(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movb %al, -0x9a(%rbp)
jmp 0xfdf0
movb -0x9a(%rbp), %dl
movl $0x2, %ecx
movl $0x1, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x60(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x50(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movl %eax, %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xfcdb
leaq -0x30(%rbp), %rdi
callq 0x30e0
movq %rax, -0x68(%rbp)
movb $0x1, -0x69(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq -0x74(%rbp), %r8
callq 0x3410
movl %eax, -0x70(%rbp)
cmpl $0x0, %eax
jl 0xff2a
cmpl $0x3f, -0x70(%rbp)
jne 0xfe88
movb $0x0, -0x69(%rbp)
jmp 0xff2a
movq $0x0, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x2b3d6(%rip), %rdi     # 0x3b278
callq 0x100e0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0xff25
movq 0x2b3bb(%rip), %rdi     # 0x3b278
movq -0x80(%rbp), %rsi
callq 0x10100
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x70(%rbp), %eax
movq -0x88(%rbp), %rcx
movsbl 0x10(%rcx), %ecx
cmpl %ecx, %eax
je 0xfef4
movl -0x70(%rbp), %eax
movq -0x80(%rbp), %rcx
addq $0x100, %rcx            # imm = 0x100
cmpl %ecx, %eax
jne 0xff12
movq -0x88(%rbp), %rdi
movq 0x2b0b6(%rip), %rax     # 0x3afb8
movq (%rax), %rsi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0xff10
jmp 0xff12
jmp 0xff14
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0xfe90
jmp 0xfe55
movq -0x38(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0xff47
movq -0xb0(%rbp), %rdi
callq 0x3360
movb -0x69(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3180
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3440
nop