// File: /workspace/github_c_makefile_star2_O0/marcomorain[P]garcon/deps/commander/commander.c
// Function: command_parse_args
static void
command_parse_args(command_t *self, int argc, char **argv) {
  int literal = 0;
  int i, j;

  for (i = 1; i < argc; ++i) {
    const char *arg = argv[i];
    for (j = 0; j < self->option_count; ++j) {
      command_option_t *option = &self->options[j];

      // match flag
      if (!strcmp(arg, option->small) || !strcmp(arg, option->large)) {
        self->arg = NULL;

        // required
        if (option->required_arg) {
          arg = argv[++i];
          if (!arg || '-' == arg[0]) {
            fprintf(stderr, "%s %s argument required\n", option->large, option->argname);
            command_free(self);
            exit(1);
          }
          self->arg = arg;
        }

        // optional
        if (option->optional_arg) {
          if (argv[i + 1] && '-' != argv[i + 1][0]) {
            self->arg = argv[++i];
          }
        }

        // invoke callback
        option->cb(self);
        goto match;
      }
    }

    // --
    if ('-' == arg[0] && '-' == arg[1] && 0 == arg[2]) {
      literal = 1;
      goto match;
    }

    // unrecognized
    if ('-' == arg[0] && !literal) {
      fprintf(stderr, "unrecognized flag %s\n", arg);
      command_free(self);
      exit(1);
    }

    int n = self->argc++;
    if (n == COMMANDER_MAX_ARGS) {
      command_free(self);
      error("Maximum number of arguments exceeded");
    }
    self->argv[n] = (char *) arg;
    match:;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xac59
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xab82
movq -0x8(%rbp), %rax
addq $0x30, %rax
movslq -0x24(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2308
cmpl $0x0, %eax
je 0xaa7b
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x2308
cmpl $0x0, %eax
jne 0xab72
movq -0x8(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x38(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xab07
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xaac0
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
jne 0xaafb
movq 0x4531(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x1a6a(%rip), %rsi      # 0xc54b
movb $0x0, %al
callq 0x2190
movq -0x8(%rbp), %rdi
callq 0xa300
movl $0x1, %edi
callq 0x22a0
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
je 0xab5f
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0xab5d
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
je 0xab5d
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xab5f
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rdi
callq *%rax
jmp 0xac49
jmp 0xab74
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xaa24
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
jne 0xabbd
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
jne 0xabbd
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0xabbd
movl $0x1, -0x1c(%rbp)
jmp 0xac49
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2d, %eax
cmpl %ecx, %eax
jne 0xac02
cmpl $0x0, -0x1c(%rbp)
jne 0xac02
movq 0x441e(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
leaq 0x197c(%rip), %rsi      # 0xc564
movb $0x0, %al
callq 0x2190
movq -0x8(%rbp), %rdi
callq 0xa300
movl $0x1, %edi
callq 0x22a0
movq -0x8(%rbp), %rcx
movl 0x730(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x730(%rcx)
movl %eax, -0x3c(%rbp)
cmpl $0x20, -0x3c(%rbp)
jne 0xac35
movq -0x8(%rbp), %rdi
callq 0xa300
leaq 0x194a(%rip), %rdi      # 0xc57a
callq 0xa660
movq -0x30(%rbp), %rdx
movq -0x8(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, 0x738(%rax,%rcx,8)
jmp 0xac4b
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xaa01
addq $0x40, %rsp
popq %rbp
retq