// File: ridiculousfish[P]docopt_fish/docopt_fish.cpp
// Function: docopt_fish::option_t::parse_from_argument(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>> const&, docopt_fish::option_t::name_type_t)
option_t option_t::parse_from_argument(const string_t &str, option_t::name_type_t type) {
    assert(!str.empty());
    assert(str.at(0) == '-');

    option_flags_t flags = 0;
    rstring_t remaining(str);

    // Get the name part
    const rstring_t dashes = remaining.scan_while<it_equals<'-'>>();
    rstring_t name, value;
    if (type == single_short) {
        // Short option, perhaps with unseparated value
        // here the name is just the next character (if any)
        // and the value is anything after it, including an = sign
        if (!remaining.empty()) {
            name = remaining.substr(0, 1);
            value = remaining.substr_from(1);
        }
    } else {
        // Long option
        name = remaining.scan_while<char_is_valid_in_option_name>();

        // Check to see if there's an = sign
        // If we got an equals sign, the rest is the value
        // It can have any character at all, since it's coming from the argument,
        // not from the usage spec
        const rstring_t equals = remaining.scan_1_char('=');
        if (!equals.empty()) {
            value = remaining;
            if (type == single_long) {
                flags |= single_long_strict_eqsep;
            }
        }
    }

    // Return the option
    return option_t(type, dashes.merge(name), value, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xf8(%rbp)
movq %rdi, -0xf0(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x83d0
xorb $-0x1, %al
testb $0x1, %al
jne 0x9181
jmp 0x9183
jmp 0x91a2
leaq 0x4200b(%rip), %rdi     # 0x4b195
leaq 0x41ef7(%rip), %rsi     # 0x4b088
movl $0xc4, %edx
leaq 0x42005(%rip), %rcx     # 0x4b1a2
callq 0x81e0
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8630
cmpl $0x2d, (%rax)
jne 0x91b6
jmp 0x91d5
leaq 0x42049(%rip), %rdi     # 0x4b206
leaq 0x41ec4(%rip), %rsi     # 0x4b088
movl $0xc5, %edx
leaq 0x41fd2(%rip), %rcx     # 0x4b1a2
callq 0x81e0
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq $-0x1, %rcx
callq 0xc430
leaq -0x40(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xc4a0
leaq -0x58(%rbp), %rdi
callq 0xbe70
leaq -0x70(%rbp), %rdi
callq 0xbe70
cmpl $0x0, -0xc(%rbp)
jne 0x9295
leaq -0x28(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x9290
leaq -0x88(%rbp), %rdi
leaq -0x28(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xc520
movq -0x88(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x1, %edx
callq 0xc5d0
movq -0xa0(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x60(%rbp)
jmp 0x9316
leaq -0xb8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x9370
movq -0xb8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x3d, %edx
callq 0xc660
leaq -0xd0(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x9314
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0x9312
movl -0x10(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x10(%rbp)
jmp 0x9314
jmp 0x9316
movl -0xc(%rbp), %eax
movl %eax, -0xfc(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xc010
movq -0xf8(%rbp), %rdi
movl -0xfc(%rbp), %esi
movl -0x10(%rbp), %r8d
leaq -0xe8(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0xc140
movq -0xf0(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)