// File: /workspace/github_c_makefile_star2_O1/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
movq %r15, %rdi
movl $0xa, %esi
callq 0x1f790
testq %rax, %rax
je 0x2e85e
movq %rax, %r12
cmpq %r15, %rax
je 0x2e77a
leaq -0x1(%r12), %rax
cmpb $0xd, -0x1(%r12)
cmoveq %rax, %r12
movq %r12, %r13
subq %r15, %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x28148
movq %rax, %rbp
leaq 0x4(%rsp), %rsi
movq %rax, %rdi
callq 0x291c9
movq %rax, %r14
movq %rbp, %rdi
callq 0x28204
testq %r14, %r14
je 0x2e88d
cmpq %r15, %r12
jne 0x2e7d2
testb $0x1, 0x90(%rbx)
je 0x2e7d2
leaq 0x9b7e4(%rip), %rax     # 0xc9fa8
movq 0x798(%rax), %rax
movq %rax, 0xc8(%rbx)
movq 0x20(%rbx), %rdi
addl $0x2, %r13d
movl %r13d, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x28c31
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2e7f5
callq 0x2984b
movslq 0x4(%rsp), %rdi
shlq $0x3, %rdi
callq 0x29709
movq %rax, 0x38(%rbx)
movl $0x0, 0x30(%rbx)
cmpl $0x0, 0x4(%rsp)
jle 0x2e852
xorl %r15d, %r15d
movq (%r14,%r15,8), %rsi
cmpl $0x0, -0x8(%rsi)
je 0x2e83d
xorl %edi, %edi
callq 0x302c4
movq 0x38(%rbx), %rcx
movslq 0x30(%rbx), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x30(%rbx)
jmp 0x2e845
movq %rsi, %rdi
callq 0x28204
incq %r15
movslq 0x4(%rsp), %rax
cmpq %rax, %r15
jl 0x2e818
movq %r14, %rdi
callq 0x2984b
xorl %ebp, %ebp
jmp 0x2e8b0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x10001, -0x8(%r15)    # imm = 0x10001
jb 0x2e8b0
leaq 0x685cd(%rip), %rsi     # 0x96e41
movl $0x26, %edx
movq %rbx, %rdi
callq 0x2d991
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2e8c1
jmp 0x2e8b0
leaq 0x685d4(%rip), %rsi     # 0x96e68
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x2d991
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2e8c1
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq