// File: /workspace/github_cpp_makefile_star2_O3/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)
movl %esi, 0x4(%rsp)
movq 0x8(%rdi), %r13
subq (%rdi), %r13
je 0x8b12
movq %rdi, %r14
sarq $0x7, %r13
xorl %r8d, %r8d
movq (%r14), %rsi
movq 0x8(%r14), %rdx
subq %rsi, %rdx
sarq $0x7, %rdx
cmpq %r8, %rdx
jbe 0x8b35
movq %r8, %rax
shlq $0x7, %rax
addq %rax, %rsi
movl $0x10, %ecx
leaq 0x18(%rsp), %rdi
rep  movsq (%rsi), %es:(%rdi)
incq %r8
movq %r8, %r12
movq %r8, 0x8(%rsp)
cmpq %r13, %r8
jae 0x8b04
movq (%r14), %rbp
movq 0x8(%r14), %rdx
subq %rbp, %rdx
sarq $0x7, %rdx
cmpq %r12, %rdx
jbe 0x8b24
movq %r12, %r15
shlq $0x7, %r15
leaq (%r15,%rbp), %rbx
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0xe544
testb %al, %al
je 0x8ab9
cmpb $0x0, 0x4(%rsp)
je 0x8ada
leaq (%r15,%rbp), %rcx
addq $0x48, %rcx
movq $-0x4, %rax
incq %rax
je 0x8abe
leaq -0x18(%rcx), %rdx
cmpq $0x0, -0x10(%rcx)
movq %rdx, %rcx
je 0x8aa4
jmp 0x8ac1
incq %r12
jmp 0x8afb
movq %rbx, %rdx
movq (%rdx), %rsi
movq 0x10(%rsp), %rdi
movl $0xd, %edx
leaq 0x18250(%rip), %rcx     # 0x20d25
callq 0x6bd4
movq 0x8(%r14), %rax
leaq -0x80(%rax), %rsi
movl $0xf, %ecx
movq %rbx, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl -0x8(%rax), %eax
movl %eax, 0x78(%rbx)
addq $-0x80, 0x8(%r14)
decq %r13
cmpq %r13, %r12
jb 0x8a5b
movq 0x8(%rsp), %r8
cmpq %r13, %r8
jb 0x8a19
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x182a3(%rip), %rdi     # 0x20dce
movq %r12, %rsi
xorl %eax, %eax
callq 0x6300
leaq 0x18292(%rip), %rdi     # 0x20dce
movq %r8, %rsi
jmp 0x8b2e
nop