// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyStringToList
void _addReplyStringToList(redisClient *c, char *s, size_t len) {
    robj *tail;

    if (c->flags & REDIS_CLOSE_AFTER_REPLY) return;

    if (listLength(c->reply) == 0) {
        // 为字符串创建字符串对象并追加到回复链表末尾
        robj *o = createStringObject(s,len);

        listAddNodeTail(c->reply,o);
        c->reply_bytes += getStringObjectSdsUsedMemory(o);
    } else {
        tail = listNodeValue(listLast(c->reply));

        /* Append to this object when possible. */
        if (tail->ptr != NULL && tail->encoding == REDIS_ENCODING_RAW &&
            sdslen(tail->ptr)+len <= REDIS_REPLY_CHUNK_BYTES)
        {
            c->reply_bytes -= zmalloc_size_sds(tail->ptr);
            tail = dupLastObjectIfNeeded(c->reply);
            // 将字符串拼接到一个 SDS 之后
            tail->ptr = sdscatlen(tail->ptr,s,len);
            c->reply_bytes += zmalloc_size_sds(tail->ptr);
        } else {
            // 为字符串创建字符串对象并追加到回复链表末尾
            robj *o = createStringObject(s,len);

            listAddNodeTail(c->reply,o);
            c->reply_bytes += getStringObjectSdsUsedMemory(o);
        }
    }
    asyncCloseClientOnOutputBufferLimitReached(c);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x3590b
jmp 0x35a5d
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
cmpq $0x0, 0x28(%rax)
jne 0x35959
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3a2e0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x1ff90
movq -0x28(%rbp), %rdi
callq 0x34860
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq 0x68(%rax), %rcx
movq %rcx, 0x68(%rax)
jmp 0x35a54
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x35a18
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x0, %eax
jne 0x35a18
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x34800
addq -0x18(%rbp), %rax
cmpq $0x4000, %rax           # imm = 0x4000
ja 0x35a18
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x34840
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x35350
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x2c500
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x34840
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq 0x68(%rax), %rcx
movq %rcx, 0x68(%rax)
jmp 0x35a52
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3a2e0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x1ff90
movq -0x30(%rbp), %rdi
callq 0x34860
movq %rax, %rcx
movq -0x8(%rbp), %rax
addq 0x68(%rax), %rcx
movq %rcx, 0x68(%rax)
jmp 0x35a54
movq -0x8(%rbp), %rdi
callq 0x35650
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)