// File: /workspace/github_cpp_makefile_star2_O2/cybozu[P]yrmcds/src/memcache/memcache.cpp
// Function: yrmcds::memcache::text_request::parse_storage(char const*, char const*, bool)
inline void
text_request::parse_storage(const char* b, const char* e, bool is_cas) noexcept {
    while( *b == SP ) ++b;
    if( b == e ) return;
    const char* key_end = cfind(b, SP, e-b);
    if( key_end == nullptr ) return;
    m_key = item(b, key_end-b);
    b = key_end;

    while( *b == SP ) ++b;
    if( b == e ) return;
    const char* flags_end = cfind(b, SP, e-b);
    if( flags_end == nullptr ) return;
    bool result;
    m_flags = to_uint<std::uint32_t>(b, result);
    if( ! result ) return;
    b = flags_end;

    while( *b == SP ) ++b;
    if( b == e ) return;
    const char* exptime_end = cfind(b, SP, e-b);
    if( exptime_end == nullptr ) return;
    std::time_t t = to_uint<std::time_t>(b, result);
    if( ! result ) return;
    if( t != 0 )
        m_exptime = (t > EXPTIME_THRESHOLD) ? t :
            (g_current_time.load(relaxed) + t);
    b = exptime_end;

    while( *b == SP ) ++b;
    if( b == e ) return;
    std::uint32_t nbytes = to_uint<std::uint32_t>(b, result);
    if( ! result ) return;
    const char* bytes_end = cfind(b, SP, e-b);
    b = (bytes_end == nullptr) ? e : bytes_end;

    if( is_cas ) {
        while( *b == SP ) ++b;
        if( b == e ) return;
        m_cas_unique = to_uint<std::uint64_t>(b, result);
        if( ! result ) return;
        const char* cas_end = cfind(b, SP, e-b);
        b = (cas_end == nullptr) ? e : cas_end;
    }

    while( *b == SP ) ++b;
    if( b != e ) {
        // noreply ?
        const char* we = cfind(b, SP, e-b);
        std::size_t noreply_len = (we != nullptr) ? (we - b) : (e - b);
        if( noreply_len != 7 ) return;
        if( std::memcmp(b, "noreply", 7) != 0 ) return;
        m_no_reply = true;
        b = (we != nullptr) ? we : e;
    }

    while( *b == SP ) ++b;
    if( b != e ) return; // garbage left

    // here, parsing was successful.  check data length.
    b += 2; // CRLF
    m_request_len = (b - m_p) + nbytes + 2;
    if( m_len < m_request_len ) {
        m_request_len = 0;
        return;
    }

    // check CRLF following the data
    if( *(b+nbytes) != CR || *(b+nbytes+1) != LF )
        return;

    // passed all checks.
    m_data = item(b, nbytes);
    m_valid = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
decq %r15
movq %r15, %r13
incq %r15
cmpb $0x20, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0x246c4
cmpq %r14, %r13
je 0x24949
movq %r14, %rdx
subq %r15, %rdx
pushq $0x20
popq %rsi
movq %r13, %rdi
callq 0x7560
testq %rax, %rax
je 0x24949
movq %rax, %r12
subq %r15, %rax
movq %r13, 0x28(%rbx)
movq %rax, 0x20(%rbx)
movq %r14, %rdx
subq %r12, %rdx
decq %r12
incq %rdx
decq %rdx
cmpb $0x20, 0x1(%r12)
leaq 0x1(%r12), %r12
je 0x2470f
cmpq %r14, %r12
je 0x24949
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x7560
testq %rax, %rax
je 0x24949
movq %rax, %r15
leaq 0x3(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2433c
movl %eax, 0x30(%rbx)
cmpb $0x1, (%r13)
jne 0x24949
movq %r14, %rdx
subq %r15, %rdx
decq %r15
incq %rdx
decq %rdx
cmpb $0x20, 0x1(%r15)
leaq 0x1(%r15), %r15
je 0x24769
cmpq %r14, %r15
je 0x24949
pushq $0x20
popq %rsi
movq %r15, %rdi
callq 0x7560
testq %rax, %rax
je 0x24949
movq %rax, %r12
leaq 0x3(%rsp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x242c6
cmpb $0x1, (%r13)
jne 0x24949
testq %rax, %rax
je 0x247d0
cmpq $0x278d00, %rax         # imm = 0x278D00
jg 0x247cc
leaq 0x176ba(%rip), %rcx     # 0x3be80
movq (%rcx), %rcx
addq %rcx, %rax
movq %rax, 0x38(%rbx)
movq %r14, %r13
subq %r12, %r13
decq %r12
incq %r13
decq %r13
cmpb $0x20, 0x1(%r12)
leaq 0x1(%r12), %r12
je 0x247dc
cmpq %r14, %r12
je 0x24949
leaq 0x3(%rsp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x2433c
movl %eax, 0x4(%rsp)
cmpb $0x1, (%r15)
jne 0x24949
pushq $0x20
popq %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x7560
movq %rax, %r12
testq %rax, %rax
cmoveq %r14, %r12
testb %bpl, %bpl
je 0x2488b
movq %r14, %r13
subq %r12, %r13
decq %r12
incq %r13
decq %r13
cmpb $0x20, 0x1(%r12)
leaq 0x1(%r12), %r12
je 0x2483c
cmpq %r14, %r12
je 0x24949
leaq 0x3(%rsp), %r15
movq %r12, %rdi
movq %r15, %rsi
callq 0x243bb
movq %rax, 0x40(%rbx)
cmpb $0x1, (%r15)
jne 0x24949
pushq $0x20
popq %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x7560
movq %rax, %r12
testq %rax, %rax
cmoveq %r14, %r12
decq %r12
movq %r12, %r13
incq %r12
cmpb $0x20, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0x24891
cmpq %r14, %r13
je 0x248ef
movq %r14, %r15
subq %r12, %r15
pushq $0x20
popq %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x7560
movq %rax, %rbp
subq %r12, %rax
testq %rbp, %rbp
cmoveq %r15, %rax
cmpq $0x7, %rax
jne 0x24949
leaq 0x5367(%rip), %rsi      # 0x29c39
pushq $0x7
popq %rdx
movq %r13, %rdi
callq 0x7530
testl %eax, %eax
jne 0x24949
testq %rbp, %rbp
movb $0x1, 0x1d(%rbx)
cmoveq %r14, %rbp
movq %rbp, %r13
pushq $-0x3
popq %rax
subq %r13, %rax
decq %r13
decq %rax
cmpb $0x20, 0x1(%r13)
leaq 0x1(%r13), %r13
je 0x248f8
cmpq %r14, %r13
jne 0x24949
movl 0x4(%rsp), %ecx
movq %rcx, %rdx
subq (%rbx), %rdx
subq %rax, %rdx
movq %rdx, 0x10(%rbx)
cmpq %rdx, 0x8(%rbx)
jae 0x24929
andq $0x0, 0x10(%rbx)
jmp 0x24949
cmpb $0xd, 0x2(%r13,%rcx)
jne 0x24949
cmpb $0xa, 0x3(%r13,%rcx)
jne 0x24949
addq $0x2, %r13
movq %r13, 0x50(%rbx)
movq %rcx, 0x48(%rbx)
movb $0x1, 0x1c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq