// File: ridiculousfish[P]docopt_fish/docopt_fish.cpp
// Function: docopt_fish::argv_classifier_t::parse_next_arg(std::vector<docopt_fish::error_t, std::allocator<docopt_fish::error_t>>*)
void argv_classifier_t::parse_next_arg(error_list_t *out_errors) {
    assert(this->idx < argv.size());
    
    if (this->classification.double_dash_idx != npos) {
        // we saw a double-dash
        // everything remaining is positional
        this->classification.positionals.emplace_back(this->idx);
        this->idx += 1;
    } else if (is_double_dash(this->arg())) {
        // Literal --. The remaining arguments are positional.
        this->classification.double_dash_idx = this->idx;
        this->idx += 1;
    } else if (this->arg_has_prefix("--")) {
        // Leading long option
        if (this->parse_separated_option(option_t::double_long, out_errors)) {
            // this will have updated this->idx
        } else {
            // This argument is unused
            // We have to update idx
            this->idx += 1;
        }
    } else if (this->arg_has_prefix("-") && this->arg().length() > 1) {
        // An option with a leading dash, like -foo
        // This can be a lot of different things:
        // 1. A combined short option: tar -cf ...
        // 2. A long option with a single dash: -std=c++
        // 3. A short option with a value: -DNDEBUG
        // Try to parse it as a long option; if that fails try to parse it as a
        // short option. We cache the errors locally so that failing to parse it
        // as a long option doesn't report an error if it parses successfully
        // as a short option. This may result in duplicate error messages.
        error_list_t long_errors, short_errors;
        if (this->parse_separated_option(option_t::single_long, &long_errors)) {
            // successfully parsed as long option
        } else if (this->parse_separated_option(option_t::single_short, &short_errors)) {
            // parse_unseparated_short will have updated idx
        } else if (this->parse_unseparated_short_options(&short_errors)) {
            // parse_unseparated_short_options succeeded.
        } else {
            // Unparseable argument.
            // Say the user enters -Dfoo. This may be an unknown long option, or a
            // short option with a value. If there is a short option -D, then it is
            // more likely that the error from the short option parsing is what we
            // want. So append our short errors first.
            if (out_errors) {
                auto dst = std::back_inserter(*out_errors);
                std::move(short_errors.begin(), short_errors.end(), dst);
                std::move(long_errors.begin(), long_errors.end(), dst);
            }
            this->idx += 1;
        }
    } else {
        // Positional argument
        // Note this includes just single-dash arguments, which are often a
        // stand-in for stdin
        this->classification.positionals.emplace_back(this->idx);
        this->idx += 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x20(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq (%rax), %rdi
callq 0xc910
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0xa022
jmp 0xa041
leaq 0x4144e(%rip), %rdi     # 0x4b477
leaq 0x41058(%rip), %rsi     # 0x4b088
movl $0x2b9, %edx            # imm = 0x2B9
leaq 0x41453(%rip), %rcx     # 0x4b48f
callq 0x81e0
movq -0xa8(%rbp), %rax
cmpq $-0x1, 0x58(%rax)
je 0xa07e
movq -0xa8(%rbp), %rsi
movq %rsi, %rdi
addq $0x28, %rdi
addq $0x20, %rsi
callq 0xcc60
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0xa335
movq -0xa8(%rbp), %rdi
callq 0xc6f0
movq %rax, %rdi
callq 0x88d0
testb $0x1, %al
jne 0xa098
jmp 0xa0b8
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, 0x58(%rax)
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0xa333
movq -0xa8(%rbp), %rdi
leaq 0x4466d(%rip), %rsi     # 0x4e733
callq 0xc720
testb $0x1, %al
jne 0xa0d1
jmp 0xa106
movq -0xa8(%rbp), %rdi
movq -0x10(%rbp), %rdx
movl $0x2, %esi
callq 0x93f0
testb $0x1, %al
jne 0xa0ec
jmp 0xa0ee
jmp 0xa101
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0xa331
movq -0xa8(%rbp), %rdi
leaq 0x44620(%rip), %rsi     # 0x4e734
callq 0xc720
testb $0x1, %al
jne 0xa122
jmp 0xa305
movq -0xa8(%rbp), %rdi
callq 0xc6f0
movq %rax, %rdi
callq 0x85a0
cmpq $0x1, %rax
jbe 0xa305
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0xbe50
leaq -0x40(%rbp), %rdi
callq 0xbe50
movq -0xa8(%rbp), %rdi
movq -0xb8(%rbp), %rdx
movl $0x1, %esi
callq 0x93f0
movb %al, -0xa9(%rbp)
jmp 0xa179
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0xa185
jmp 0xa1ad
jmp 0xa2f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xc3d0
leaq -0x28(%rbp), %rdi
callq 0xc3d0
jmp 0xa33e
movq -0xa8(%rbp), %rdi
xorl %esi, %esi
leaq -0x40(%rbp), %rdx
callq 0x93f0
movb %al, -0xb9(%rbp)
jmp 0xa1c7
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0xa1d3
jmp 0xa1d8
jmp 0xa2ef
movq -0xa8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9940
movb %al, -0xba(%rbp)
jmp 0xa1f0
movb -0xba(%rbp), %al
testb $0x1, %al
jne 0xa1fc
jmp 0xa201
jmp 0xa2ed
cmpq $0x0, -0x10(%rbp)
je 0xa2da
movq -0x10(%rbp), %rdi
callq 0xc3a0
movq %rax, -0xc8(%rbp)
jmp 0xa21e
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0xc340
movq -0xd8(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0xc370
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0xc2d0
movq %rax, -0xd0(%rbp)
jmp 0xa26f
movq -0xd0(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xc340
movq -0xe8(%rbp), %rdi
movq %rax, -0x80(%rbp)
callq 0xc370
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0xc2d0
movq %rax, -0xe0(%rbp)
jmp 0xa2cc
movq -0xe0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0xa2ef
jmp 0xa2f1
leaq -0x40(%rbp), %rdi
callq 0xc3d0
leaq -0x28(%rbp), %rdi
callq 0xc3d0
jmp 0xa32f
movq -0xa8(%rbp), %rsi
movq %rsi, %rdi
addq $0x28, %rdi
addq $0x20, %rsi
callq 0xcc60
movq -0xa8(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
jmp 0xa331
jmp 0xa333
jmp 0xa335
addq $0xf0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x85d0
nopw (%rax,%rax)