// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: processInlineBuffer
int processInlineBuffer(redisClient *c) {
    char *newline;
    int argc, j;
    sds *argv, aux;
    size_t querylen;

    /* Search for end of line */
    newline = strchr(c->querybuf,'\n');

    /* Nothing to do without a \r\n */
    // 收到的查询内容不符合协议格式，出错
    if (newline == NULL) {
        if (sdslen(c->querybuf) > REDIS_INLINE_MAX_SIZE) {
            addReplyError(c,"Protocol error: too big inline request");
            setProtocolError(c,0);
        }
        return REDIS_ERR;
    }

    /* Handle the \r\n case. */
    if (newline && newline != c->querybuf && *(newline-1) == '\r')
        newline--;

    /* Split the input buffer up to the \r\n */
    // 根据空格，分割命令的参数
    // 比如说 SET msg hello \r\n 将分割为
    // argv[0] = SET
    // argv[1] = msg
    // argv[2] = hello
    // argc = 3
    querylen = newline-(c->querybuf);
    aux = sdsnewlen(c->querybuf,querylen);
    argv = sdssplitargs(aux,&argc);
    sdsfree(aux);
    if (argv == NULL) {
        addReplyError(c,"Protocol error: unbalanced quotes in request");
        setProtocolError(c,0);
        return REDIS_ERR;
    }

    /* Newline from slaves can be used to refresh the last ACK time.
     * This is useful for a slave to ping back while loading a big
     * RDB file. */
    if (querylen == 0 && c->flags & REDIS_SLAVE)
        c->repl_ack_time = server.unixtime;

    /* Leave data after the first line of the query in the buffer */

    // 从缓冲区中删除已 argv 已读取的内容
    // 剩余的内容是未读取的
    sdsrange(c->querybuf,querylen+2,-1);

    /* Setup argv array on client structure */
    // 为客户端的参数分配空间
    if (c->argv) zfree(c->argv);
    c->argv = zmalloc(sizeof(robj*)*argc);

    /* Create redis objects for all arguments. */
    // 为每个参数创建一个字符串对象
    for (c->argc = 0, j = 0; j < argc; j++) {
        if (sdslen(argv[j])) {
            // argv[j] 已经是 SDS 了
            // 所以创建的字符串对象直接指向该 SDS
            c->argv[c->argc] = createObject(REDIS_STRING,argv[j]);
            c->argc++;
        } else {
            sdsfree(argv[j]);
        }
    }

    zfree(argv);

    return REDIS_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %r15
pushq $0xa
popq %rsi
movq %r15, %rdi
callq 0x1f790
testq %rax, %rax
je 0x2d0b9
movq %r15, %rbp
cmpq %r15, %rax
je 0x2cfdf
leaq -0x1(%rax), %rbp
cmpb $0xd, -0x1(%rax)
cmovneq %rax, %rbp
movq %rbp, %r12
subq %r15, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x27158
movq %rax, %r13
leaq 0x4(%rsp), %rsi
movq %rax, %rdi
callq 0x27ee8
movq %rax, %r14
movq %r13, %rdi
callq 0x271f7
testq %r14, %r14
je 0x2d0e1
cmpq %r15, %rbp
jne 0x2d037
testb $0x1, 0x90(%rbx)
je 0x2d037
leaq 0x99f7f(%rip), %rax     # 0xc6fa8
movq 0x798(%rax), %rax
movq %rax, 0xc8(%rbx)
movq 0x20(%rbx), %rdi
addl $0x2, %r12d
pushq $-0x1
popq %rdx
movl %r12d, %esi
callq 0x27a3e
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2d058
callq 0x283cd
movslq 0x4(%rsp), %rdi
shlq $0x3, %rdi
callq 0x2828d
movq %rax, 0x38(%rbx)
andl $0x0, 0x30(%rbx)
xorl %r15d, %r15d
movslq 0x4(%rsp), %rax
cmpq %rax, %r15
jge 0x2d0ad
movq (%r14,%r15,8), %rsi
cmpl $0x0, -0x8(%rsi)
je 0x2d0a0
xorl %edi, %edi
callq 0x2e9b4
movq 0x38(%rbx), %rcx
movslq 0x30(%rbx), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x30(%rbx)
jmp 0x2d0a8
movq %rsi, %rdi
callq 0x271f7
incq %r15
jmp 0x2d071
movq %r14, %rdi
callq 0x283cd
xorl %ebp, %ebp
jmp 0x2d0fd
pushq $-0x1
popq %rbp
cmpl $0x10001, -0x8(%r15)    # imm = 0x10001
jb 0x2d0fd
leaq 0x5fda4(%rip), %rsi     # 0x8ce71
movq %rbx, %rdi
callq 0x2c2da
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2d10e
jmp 0x2d0fd
leaq 0x5fdb0(%rip), %rsi     # 0x8ce98
movq %rbx, %rdi
callq 0x2c2da
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2d10e
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq