// File: cybozu[P]yrmcds/src/memcache/memcache.cpp
// Function: yrmcds::memcache::text_request::parse()
void text_request::parse() noexcept {
    const char* eol = cfind(m_p, LF, m_len);
    if( eol == nullptr ) return; // incomplete

    m_request_len = eol - m_p + 1;
    if( m_request_len == 1 ) return;  // invalid
    if( *(--eol) != CR ) return;

    const char* cmd_start = m_p;
    while( *cmd_start == SP ) ++cmd_start;
    const char* cmd_end = cfind(cmd_start, SP, (eol - cmd_start));
    if( cmd_end == nullptr ) cmd_end = eol;
    std::size_t cmd_len = (cmd_end - cmd_start);

    if( cmd_len == 10 ) {
        if( std::memcmp(cmd_start, "unlock_all", 10) == 0 ) {
            m_command = text_command::UNLOCK_ALL;
            m_valid = true;
            return;
        }
    }
    if( cmd_len == 9 ) {
        if( std::memcmp(cmd_start, "flush_all", 9) == 0 ) {
            m_command = text_command::FLUSH_ALL;
            parse_flushall(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "verbosity", 9) == 0 ) {
            m_command = text_command::VERBOSITY;
            parse_verbosity(cmd_end, eol);
            return;
        }
    }
    if( cmd_len == 7 ) {
        if( std::memcmp(cmd_start, "version", 7) == 0 ) {
            m_command = text_command::VERSION;
            m_valid = true;
            return;
        }
        if( std::memcmp(cmd_start, "prepend", 7) == 0 ) {
            m_command = text_command::PREPEND;
            parse_storage(cmd_end, eol, false);
            return;
        }
        if( std::memcmp(cmd_start, "replace", 7) == 0 ) {
            m_command = text_command::REPLACE;
            parse_storage(cmd_end, eol, false);
            return;
        }
    }
    if( cmd_len == 6 ) {
        if( std::memcmp(cmd_start, "append", 6) == 0 ) {
            m_command = text_command::APPEND;
            parse_storage(cmd_end, eol, false);
            return;
        }
        if( std::memcmp(cmd_start, "delete", 6) == 0 ) {
            m_command = text_command::DELETE;
            parse_delete(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "unlock", 6) == 0 ) {
            m_command = text_command::UNLOCK;
            parse_unlock(cmd_end, eol);
            return;
        }
    }
    if( cmd_len == 5 ) {
        if( std::memcmp(cmd_start, "touch", 5) == 0 ) {
            m_command = text_command::TOUCH;
            parse_touch(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "slabs", 5) == 0 ) {
            m_command = text_command::SLABS;
            m_valid = true;
            // ignore.
            return;
        }
        if( std::memcmp(cmd_start, "stats", 5) == 0 ) {
            m_command = text_command::STATS;
            parse_stats(cmd_end, eol);
            return;
        }
    }
    if( cmd_len == 4 ) {
        if( std::memcmp(cmd_start, "gets", 4) == 0 ) {
            m_command = text_command::GETS;
            parse_get(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "incr", 4) == 0 ) {
            m_command = text_command::INCR;
            parse_incdec(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "decr", 4) == 0 ) {
            m_command = text_command::DECR;
            parse_incdec(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "lock", 4) == 0 ) {
            m_command = text_command::LOCK;
            parse_lock(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "quit", 4) == 0 ) {
            m_command = text_command::QUIT;
            m_valid = true;
            return;
        }
        if( std::memcmp(cmd_start, "keys", 4) == 0 ) {
            m_command = text_command::KEYS;
            parse_keys(cmd_end, eol);
            return;
        }
    }
    if( cmd_len == 3 ) {
        if( std::memcmp(cmd_start, "set", 3) == 0 ) {
            m_command = text_command::SET;
            parse_storage(cmd_end, eol, false);
            return;
        }
        if( std::memcmp(cmd_start, "add", 3) == 0 ) {
            m_command = text_command::ADD;
            parse_storage(cmd_end, eol, false);
            return;
        }
        if( std::memcmp(cmd_start, "get", 3) == 0 ) {
            m_command = text_command::GET;
            parse_get(cmd_end, eol);
            return;
        }
        if( std::memcmp(cmd_start, "cas", 3) == 0 ) {
            m_command = text_command::CAS;
            parse_storage(cmd_end, eol, true);
            return;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq (%rax), %rdi
movq 0x8(%rax), %rdx
movl $0xa, %esi
callq 0x63090
movq %rax, -0x30(%rbp)
jmp 0x62aeb
movq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x62aff
jmp 0x6307b
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
movq (%rax), %rdx
subq %rdx, %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
cmpq $0x1, 0x10(%rax)
jne 0x62b21
jmp 0x6307b
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl -0x1(%rax), %eax
cmpl $0xd, %eax
je 0x62b3e
jmp 0x6307b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0x62b63
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x62b49
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rdx
subq %rdi, %rdx
movl $0x20, %esi
callq 0x63090
movq %rax, -0x40(%rbp)
jmp 0x62b7e
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x62b95
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0xa, -0x28(%rbp)
jne 0x62bdb
movq -0x18(%rbp), %rdi
leaq 0x1b183(%rip), %rsi     # 0x7dd39
movl $0xa, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62bd9
movq -0x38(%rbp), %rax
movl $0xf, 0x18(%rax)
movb $0x1, 0x1c(%rax)
jmp 0x6307b
jmp 0x62bdb
cmpq $0x9, -0x28(%rbp)
jne 0x62c52
movq -0x18(%rbp), %rdi
leaq 0x1b172(%rip), %rsi     # 0x7dd5f
movl $0x9, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62c19
movq -0x38(%rbp), %rdi
movl $0x12, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x75230
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1b157(%rip), %rsi     # 0x7dd7b
movl $0x9, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62c50
movq -0x38(%rbp), %rdi
movl $0x14, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x75560
jmp 0x6307b
jmp 0x62c52
cmpq $0x7, -0x28(%rbp)
jne 0x62cff
movq -0x18(%rbp), %rdi
leaq 0x1b106(%rip), %rsi     # 0x7dd6e
movl $0x7, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62c8b
movq -0x38(%rbp), %rax
movl $0x13, 0x18(%rax)
movb $0x1, 0x1c(%rax)
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1b039(%rip), %rsi     # 0x7dccf
movl $0x7, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62cc4
movq -0x38(%rbp), %rdi
movl $0x5, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x757a0
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1afe7(%rip), %rsi     # 0x7dcb6
movl $0x7, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62cfd
movq -0x38(%rbp), %rdi
movl $0x3, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x757a0
jmp 0x6307b
jmp 0x62cff
cmpq $0x6, -0x28(%rbp)
jne 0x62db3
movq -0x18(%rbp), %rdi
leaq 0x1afae(%rip), %rsi     # 0x7dcc3
movl $0x6, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62d43
movq -0x38(%rbp), %rdi
movl $0x4, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x757a0
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1afaa(%rip), %rsi     # 0x7dcf8
movl $0x6, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62d7a
movq -0x38(%rbp), %rdi
movl $0x9, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x75d40
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1afa8(%rip), %rsi     # 0x7dd2d
movl $0x6, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62db1
movq -0x38(%rbp), %rdi
movl $0xe, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x75ef0
jmp 0x6307b
jmp 0x62db3
cmpq $0x5, -0x28(%rbp)
jne 0x62e5c
movq -0x18(%rbp), %rdi
leaq 0x1af4f(%rip), %rsi     # 0x7dd18
movl $0x5, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62df5
movq -0x38(%rbp), %rdi
movl $0xc, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x75f20
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1af49(%rip), %rsi     # 0x7dd49
movl $0x5, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62e23
movq -0x38(%rbp), %rax
movl $0x10, 0x18(%rax)
movb $0x1, 0x1c(%rax)
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x19fd2(%rip), %rsi     # 0x7ce00
movl $0x5, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62e5a
movq -0x38(%rbp), %rdi
movl $0x11, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76210
jmp 0x6307b
jmp 0x62e5c
cmpq $0x4, -0x28(%rbp)
jne 0x62f92
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x73746567, %eax       # imm = 0x73746567
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62e9a
movq -0x38(%rbp), %rdi
movl $0x8, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76370
jmp 0x6307b
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x72636e69, %eax       # imm = 0x72636E69
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62ecd
movq -0x38(%rbp), %rdi
movl $0xa, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76420
jmp 0x6307b
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x72636564, %eax       # imm = 0x72636564
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62f00
movq -0x38(%rbp), %rdi
movl $0xb, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76420
jmp 0x6307b
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x6b636f6c, %eax       # imm = 0x6B636F6C
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62f33
movq -0x38(%rbp), %rdi
movl $0xd, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76640
jmp 0x6307b
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x74697571, %eax       # imm = 0x74697571
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62f5d
movq -0x38(%rbp), %rax
movl $0x15, 0x18(%rax)
movb $0x1, 0x1c(%rax)
jmp 0x6307b
movq -0x18(%rbp), %rax
movl (%rax), %eax
subl $0x7379656b, %eax       # imm = 0x7379656B
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x62f90
movq -0x38(%rbp), %rdi
movl $0x16, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76720
jmp 0x6307b
jmp 0x62f92
cmpq $0x3, -0x28(%rbp)
jne 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1acfc(%rip), %rsi     # 0x7dca4
movl $0x3, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x62fd6
movq -0x38(%rbp), %rdi
movl $0x1, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x757a0
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1accc(%rip), %rsi     # 0x7dcad
movl $0x3, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x6300c
movq -0x38(%rbp), %rdi
movl $0x2, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
callq 0x757a0
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x19dbd(%rip), %rsi     # 0x7cdd4
movl $0x3, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x63040
movq -0x38(%rbp), %rdi
movl $0x7, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76370
jmp 0x6307b
movq -0x18(%rbp), %rdi
leaq 0x1ac91(%rip), %rsi     # 0x7dcdc
movl $0x3, %edx
callq 0x8280
cmpl $0x0, %eax
jne 0x63079
movq -0x38(%rbp), %rdi
movl $0x6, 0x18(%rdi)
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl $0x1, %ecx
callq 0x757a0
jmp 0x6307b
jmp 0x6307b
addq $0x40, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xa7e0
nopl (%rax)