// File: /workspace/github_c_makefile_star2_O3/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 0x2eafd
movq %r15, %rbp
cmpq %r15, %rax
je 0x2ea19
leaq -0x1(%rax), %rbp
cmpb $0xd, -0x1(%rax)
cmovneq %rax, %rbp
movq %rbp, %r12
subq %r15, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x283f4
movq %rax, %r13
leaq 0x4(%rsp), %rsi
movq %rax, %rdi
callq 0x294d6
movq %rax, %r14
movq %r13, %rdi
callq 0x2850d
testq %r14, %r14
je 0x2eb2c
cmpq %r15, %rbp
jne 0x2ea71
testb $0x1, 0x90(%rbx)
je 0x2ea71
leaq 0x9b545(%rip), %rax     # 0xc9fa8
movq 0x798(%rax), %rax
movq %rax, 0xc8(%rbx)
movq 0x20(%rbx), %rdi
addl $0x2, %r12d
movl %r12d, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x28f3c
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2ea94
callq 0x29af7
movslq 0x4(%rsp), %rdi
shlq $0x3, %rdi
callq 0x299b5
movq %rax, 0x38(%rbx)
movl $0x0, 0x30(%rbx)
cmpl $0x0, 0x4(%rsp)
jle 0x2eaf1
xorl %r15d, %r15d
movq (%r14,%r15,8), %rsi
cmpl $0x0, -0x8(%rsi)
je 0x2eadc
xorl %edi, %edi
callq 0x3059c
movq 0x38(%rbx), %rcx
movslq 0x30(%rbx), %rdx
movq %rax, (%rcx,%rdx,8)
leal 0x1(%rdx), %eax
movl %eax, 0x30(%rbx)
jmp 0x2eae4
movq %rsi, %rdi
callq 0x2850d
incq %r15
movslq 0x4(%rsp), %rax
cmpq %rax, %r15
jl 0x2eab7
movq %r14, %rdi
callq 0x29af7
xorl %ebp, %ebp
jmp 0x2eb4f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x10001, -0x8(%r15)    # imm = 0x10001
jb 0x2eb4f
leaq 0x6838e(%rip), %rsi     # 0x96ea1
movl $0x26, %edx
movq %rbx, %rdi
callq 0x2dc1d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2eb60
jmp 0x2eb4f
leaq 0x68395(%rip), %rsi     # 0x96ec8
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x2dc1d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2eb60
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq