// File: /workspace/github_cpp_makefile_star2_O2/ridiculousfish[P]docopt_fish/docopt_fish.cpp
// Function: docopt_fish::uniqueize_options(std::vector<docopt_fish::option_t, std::allocator<docopt_fish::option_t>>*, bool, std::vector<docopt_fish::error_t, std::allocator<docopt_fish::error_t>>*)
static void uniqueize_options(option_list_t *options, bool error_on_duplicates,
                              error_list_t *errors) {
    // Maintain an outer cursor. For each option, loop over the remainder,
    // deleting those that share
    // a name
    // Grab the best description as we go
    // We "delete" from the middle of the vector by moving the last element into
    // the slot, and then
    // decrementing the length
    size_t options_count = options->size();  // note this changes as we go
    for (size_t outer = 0; outer < options_count; outer++) {
        const option_t representative = options->at(outer);

        // Find all options that share a name with this representative
        // Determine which one is best
        for (size_t match_cursor = outer + 1; match_cursor < options_count; match_cursor++) {
            option_t *candidate = &options->at(match_cursor);
            if (!representative.has_same_name(*candidate)) {
                continue;
            }

            // Ok, we know that candidate has the same name as the best match
            // Generate an error if we're supposed to
            // TODO: verify agreement in the parameters, etc.
            // Then we copy the description over if it's better, then "erase" the
            // candidate
            // That will cause us to skip over it later
            if (error_on_duplicates) {
                // Generate an error, and then continue on
                append_token_error(errors, candidate->best_name(),
                                    error_option_duplicated_in_options_section,
                                    "Option specified more than once");
            }

            // "Delete" candidate by overwriting it with the last value, and
            // decrementing the count
            *candidate = std::move(options->back());
            options->pop_back();
            options_count -= 1;
            match_cursor -= 1;  // have to re-evaluate this value
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, 0x10(%rsp)
movq %rdi, %r14
movq 0x8(%rdi), %r12
subq (%rdi), %r12
movl %esi, %ebp
sarq $0x7, %r12
xorl %r15d, %r15d
leaq 0x18(%rsp), %r13
cmpq %r12, %r15
jae 0x8ec5
movq %r14, %rdi
movq %r15, %rsi
callq 0x93bc
pushq $0x10
popq %rcx
movq %r13, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
incq %r15
movq %r15, 0x8(%rsp)
cmpq %r12, %r15
jae 0x8ebb
movq %r14, %rdi
movq %r15, %rsi
callq 0x93bc
movq %rax, %rbx
movq %r13, %rdi
movq %rax, %rsi
callq 0xdfba
testb %al, %al
je 0x8eb6
testb %bpl, %bpl
je 0x8e9c
movq %rbx, %rdi
callq 0xdffe
movq 0x10(%rsp), %rdi
movq %rax, %rsi
pushq $0xd
popq %rdx
leaq 0x13edf(%rip), %rcx     # 0x1cd76
callq 0x7961
movq 0x8(%r14), %rsi
addq $-0x80, %rsi
pushq $0x7c
popq %rcx
movq %rbx, %rdi
rep  movsb (%rsi), %es:(%rdi)
addq $-0x80, 0x8(%r14)
decq %r12
jmp 0x8e56
incq %r15
jmp 0x8e56
movq 0x8(%rsp), %r15
jmp 0x8e2e
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop