// File: /workspace/github_cpp_makefile_star2_O2/Rjerk[P]ratabase/Parser.cpp
// Function: ratabase::Parser::parse(cmd_v&)
bool Parser::parse(cmd_v& cmd)
{
    string buf = string(buffer_);
    istringstream cmdstr(buf);
    cmd.cmd_name.clear();
    cmdstr >> cmd.cmd_name; // read command name
    cmd.obj_name.clear();
    cmdstr >> cmd.obj_name; // read object name
    string param;
    cmd.params.clear();
    while (cmdstr >> param) {
        cmd.params.push_back(param);
    }

    if (cmd_map.find(cmd.cmd_name) == cmd_map.end()) {
        string reply = "Unknown command \"" + cmd.cmd_name + "\"\n";
        writeReplyBuf(reply);
        LOG_ERROR << reply;
        return false;
    }
    cmd.type = cmd_map[cmd.cmd_name];
    switch (cmd.type) {
        case cmd_type::DISPLAY: // check 0 argument after command
            return check0(cmd);
        case cmd_type::CREATE:
        case cmd_type::SELECT:
        case cmd_type::DELETE:
        case cmd_type::SLEN:
        case cmd_type::SCLR:
        case cmd_type::LPOP:
        case cmd_type::LSIZE:
        case cmd_type::DSIZE:
            return check1(cmd); // check 1 argument after command

        case cmd_type::SSET:
        case cmd_type::SAPP:
        case cmd_type::LSET:
        case cmd_type::LPUSH:
        case cmd_type::LIDX:
        case cmd_type::LGET:
        case cmd_type::LDEL:
        case cmd_type::DGET:
        case cmd_type::DDEL:
			return check2(cmd); // check 2 arguments after command

        case cmd_type::DSET:
        case cmd_type::DADD:
			return checkMore(cmd); // check more arguments
        default:
            LOG_FATAL << "No way you come here ?!";
            return false; // never come.
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x368, %rsp            # imm = 0x368
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x8(%rdi), %rsi
leaq 0x40(%rsp), %r15
leaq 0x60(%rsp), %rdx
movq %r15, %rdi
callq 0x3130
leaq 0x1e8(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r15, %rsi
callq 0x3470
andq $0x0, 0x10(%r14)
leaq 0x8(%r14), %r15
movq 0x8(%r14), %rax
movb $0x0, (%rax)
leaq 0x1e8(%rsp), %rdi
movq %r15, %rsi
callq 0x3350
andq $0x0, 0x30(%r14)
leaq 0x28(%r14), %rsi
movq 0x28(%r14), %rax
movb $0x0, (%rax)
leaq 0x1e8(%rsp), %rdi
callq 0x3350
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x48(%r14), %r12
movq %r12, %rdi
callq 0x6bf6
leaq 0x1e8(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3350
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6647
movq %r12, %rdi
movq %rbp, %rsi
callq 0x6bfe
jmp 0x6621
leaq 0xad02(%rip), %rdi      # 0x11350
movq %r15, %rsi
callq 0x6eba
testq %rax, %rax
je 0x6699
leaq 0xacee(%rip), %rdi      # 0x11350
movq %r15, %rsi
callq 0x6ee8
movl (%rax), %eax
movl %eax, (%r14)
cmpq $0x14, %rax
ja 0x677d
leaq 0x4c48(%rip), %rcx      # 0xb2c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6a1a
jmp 0x6746
leaq 0x4c7d(%rip), %rsi      # 0xb31d
leaq 0x60(%rsp), %rdi
movq %r15, %rdx
callq 0x6c49
leaq 0x4c7b(%rip), %rdx      # 0xb32f
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
callq 0x6c2a
leaq 0x60(%rsp), %rdi
callq 0x3170
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x651c
leaq 0x4c55(%rip), %rsi      # 0xb332
leaq 0x4c59(%rip), %rcx      # 0xb33d
leaq 0x60(%rsp), %rdi
pushq $0x3d
popq %rdx
pushq $0x4
popq %r8
callq 0x9cd8
leaq 0x60(%rsp), %rdi
callq 0x9f26
addq $0x10, %rax
movq %rsp, %rsi
movq %rax, %rdi
callq 0x32b0
leaq 0x60(%rsp), %rdi
callq 0x9e18
movq %rsp, %rdi
callq 0x3170
xorl %ebx, %ebx
jmp 0x6748
movq %rbx, %rdi
movq %r14, %rsi
callq 0x692e
jmp 0x6746
movq %r14, %rsi
callq 0x6b0a
jmp 0x6746
movq %rbx, %rdi
movq %r14, %rsi
callq 0x683c
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0x3170
leaq 0x1e8(%rsp), %rdi
callq 0x3180
leaq 0x40(%rsp), %rdi
callq 0x3170
movl %ebx, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4bae(%rip), %rsi      # 0xb332
leaq 0x4bb2(%rip), %rcx      # 0xb33d
leaq 0x60(%rsp), %rdi
pushq $0x5d
popq %rdx
pushq $0x5
popq %r8
callq 0x9cd8
leaq 0x60(%rsp), %rdi
callq 0x9f26
addq $0x10, %rax
leaq 0x4b92(%rip), %rsi      # 0xb343
movq %rax, %rdi
callq 0x3300
leaq 0x60(%rsp), %rdi
callq 0x9e18
jmp 0x6720
jmp 0x680f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x9e18
jmp 0x6812
movq %rax, %rbx
jmp 0x67f7
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x67fa
jmp 0x680f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x9e18
movq %rsp, %rdi
callq 0x3170
jmp 0x6812
jmp 0x680f
movq %rax, %rbx
jmp 0x6829
jmp 0x680f
movq %rax, %rbx
jmp 0x681c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3170
leaq 0x1e8(%rsp), %rdi
callq 0x3180
leaq 0x40(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x34b0
nop