LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/zipmap.c
// Function: zipmapLen
unsigned int zipmapLen(unsigned char *zm) {

    unsigned int len = 0;

    if (zm[0] < ZIPMAP_BIGLEN) {
        // 长度可以用 1 字节保存
        // T = O(1)
        len = zm[0];
    } else {
        // 长度不能用 1 字节保存，需要遍历整个 zipmap
        // T = O(N)
        unsigned char *p = zipmapRewind(zm);
        while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) len++;

        /* Re-store length if small enough */
        // 如果字节数量已经少于 ZIPMAP_BIGLEN ，那么重新将值保存到 len 中
        // 这种情况在节点数超过 ZIPMAP_BIGLEN 之后，有节点被删除时会出现
        if (len < ZIPMAP_BIGLEN) zm[0] = len;
    }

    return len;
}

// Assembly:
movzbl (%rdi), %eax
cmpl $0xfd, %eax
jbe 0x2ab77
leaq 0x1(%rdi), %rcx
xorl %eax, %eax
movzbl (%rcx), %edx
cmpl $0xfe, %edx
je 0x2ab24
cmpl $0xff, %edx
jne 0x2ab27
jmp 0x2ab6e
movl 0x1(%rcx), %edx
xorl %esi, %esi
cmpl $0xfe, %edx
setae %sil
leal (%rdx,%rsi,4), %esi
incl %esi
leaq (%rcx,%rsi), %rdx
movzbl (%rcx,%rsi), %ecx
cmpl $0xfd, %ecx
jbe 0x2ab4b
movl 0x1(%rdx), %ecx
xorl %esi, %esi
cmpl $0xfe, %ecx
setae %sil
movzbl 0x1(%rdx,%rsi,4), %r8d
addl %ecx, %r8d
leal (%r8,%rsi,4), %ecx
addl $0x2, %ecx
addq %rdx, %rcx
incl %eax
jmp 0x2ab0f
cmpl $0xfd, %eax
ja 0x2ab77
movb %al, (%rdi)
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/sha1.c
// Function: SHA1Update
void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len)
{
    u_int32_t i, j;

    j = context->count[0];
    if ((context->count[0] += len << 3) < j)
        context->count[1]++;
    context->count[1] += (len>>29);
    j = (j >> 3) & 63;
    if ((j + len) > 63) {
        memcpy(&context->buffer[j], data, (i = 64-j));
        SHA1Transform(context->state, context->buffer);
        for ( ; i + 63 < len; i += 64) {
            SHA1Transform(context->state, &data[i]);
        }
        j = 0;
    }
    else i = 0;
    memcpy(&context->buffer[j], &data[i], len - i);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
movl 0x14(%rdi), %ebp
leal (,%rbx,8), %eax
movl %edx, %ecx
shrl $0x1d, %ecx
addl %ebp, %eax
movl %eax, 0x14(%rdi)
adcl %ecx, 0x18(%rdi)
shrl $0x3, %ebp
andl $0x3f, %ebp
leal (%rbx,%rbp), %eax
cmpl $0x40, %eax
jb 0x2bd29
leaq 0x1c(%r15), %r13
leaq (%r15,%rbp), %rdi
addq $0x1c, %rdi
movl $0x40, %r12d
subl %ebp, %r12d
movq %r14, %rsi
movq %r12, %rdx
callq 0x1fbd0
movq %r15, %rdi
movq %r13, %rsi
callq 0x2ab98
xorl $0x7f, %ebp
cmpl %ebx, %ebp
jae 0x2bd30
leal -0x3f(%rbp), %esi
addq %r14, %rsi
movq %r15, %rdi
callq 0x2ab98
addl $0x40, %ebp
cmpl %ebx, %ebp
jb 0x2bd0a
addl $-0x3f, %ebp
xorl %eax, %eax
movl %ebp, %r12d
jmp 0x2bd32
movl %ebp, %eax
xorl %r12d, %r12d
jmp 0x2bd32
xorl %eax, %eax
leaq (%r15,%rax), %rdi
addq $0x1c, %rdi
movl %r12d, %eax
addq %rax, %r14
subl %r12d, %ebx
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1fbd0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistPush
unsigned char *ziplistPush(unsigned char *zl, unsigned char *s, unsigned int slen, int where) {

    // 根据 where 参数的值，决定将值推入到表头还是表尾
    unsigned char *p;
    p = (where == ZIPLIST_HEAD) ? ZIPLIST_ENTRY_HEAD(zl) : ZIPLIST_ENTRY_END(zl);

    // 返回添加新值后的 ziplist
    // T = O(N^2)
    return __ziplistInsert(zl,p,s,slen);
}

// Assembly:
movl %ecx, %eax
movl %edx, %ecx
movq %rsi, %rdx
testl %eax, %eax
je 0x2be7a
movl (%rdi), %eax
leaq (%rdi,%rax), %rsi
decq %rsi
jmp 0x2be80
leaq 0xa(%rdi), %rsi
jmp 0x2be80
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistIndex
unsigned char *ziplistIndex(unsigned char *zl, int index) {

    unsigned char *p;

    zlentry entry;

    // 处理负数索引
    if (index < 0) {

        // 将索引转换为正数
        index = (-index)-1;
        
        // 定位到表尾节点
        p = ZIPLIST_ENTRY_TAIL(zl);

        // 如果列表不为空，那么。。。
        if (p[0] != ZIP_END) {

            // 从表尾向表头遍历
            entry = zipEntry(p);
            // T = O(N)
            while (entry.prevrawlen > 0 && index--) {
                // 前移指针
                p -= entry.prevrawlen;
                // T = O(1)
                entry = zipEntry(p);
            }
        }

    // 处理正数索引
    } else {

        // 定位到表头节点
        p = ZIPLIST_ENTRY_HEAD(zl);

        // T = O(N)
        while (p[0] != ZIP_END && index--) {
            // 后移指针
            // T = O(1)
            p += zipRawEntryLength(p);
        }
    }

    // 返回结果
    return (p[0] == ZIP_END || index > 0) ? NULL : p;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %esi, %ebx
testl %esi, %esi
js 0x2c2c3
leaq 0xa(%rdi), %r15
cmpb $-0x1, 0xa(%rdi)
je 0x2c30f
subl $0x1, %ebx
jb 0x2c30a
movq %r15, %rdi
callq 0x2c46a
movl %eax, %eax
leaq (%r15,%rax), %r14
cmpb $-0x1, (%r15,%rax)
movq %r14, %r15
jne 0x2c2a4
jmp 0x2c312
notl %ebx
movl 0x4(%rdi), %eax
leaq (%rdi,%rax), %r14
cmpb $-0x1, (%rdi,%rax)
je 0x2c312
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2c336
movl 0x4(%r15), %eax
testl %eax, %eax
je 0x2c312
movq %rsp, %r15
subl $0x1, %ebx
jb 0x2c32f
movl %eax, %eax
subq %rax, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2c336
movl 0x4(%rsp), %eax
testl %eax, %eax
jne 0x2c2eb
jmp 0x2c312
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r15, %r14
xorl %ecx, %ecx
testl %ebx, %ebx
movq %r14, %rax
cmovgq %rcx, %rax
cmpb $-0x1, (%r14)
cmoveq %rcx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x2c312
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: zipEntry
static zlentry zipEntry(unsigned char *p) {
    zlentry e;

    // e.prevrawlensize 保存着编码前一个节点的长度所需的字节数
    // e.prevrawlen 保存着前一个节点的长度
    // T = O(1)
    ZIP_DECODE_PREVLEN(p, e.prevrawlensize, e.prevrawlen);

    // p + e.prevrawlensize 将指针移动到列表节点本身
    // e.encoding 保存着节点值的编码类型
    // e.lensize 保存着编码节点值长度所需的字节数
    // e.len 保存着节点值的长度
    // T = O(1)
    ZIP_DECODE_LENGTH(p + e.prevrawlensize, e.encoding, e.lensize, e.len);

    // 计算头结点的字节数
    e.headersize = e.prevrawlensize + e.lensize;

    // 记录指针
    e.p = p;

    return e;
}

// Assembly:
movzbl (%rsi), %ecx
xorl %eax, %eax
cmpl $0xfe, %ecx
setae %al
leal 0x1(,%rax,4), %eax
movl %eax, (%rdi)
jb 0x2c352
movl 0x1(%rsi), %ecx
movl %ecx, 0x4(%rdi)
movl %eax, %edx
movzbl (%rsi,%rdx), %ecx
movl %ecx, %r8d
andb $-0x40, %r8b
movzbl %r8b, %r8d
cmpl $0xc0, %ecx
cmovael %ecx, %r8d
movb %r8b, 0x14(%rdi)
jae 0x2c3ad
movl %ecx, %r8d
shrb $0x6, %r8b
xorb $0x2, %r8b
movzbl %r8b, %r8d
leaq 0x6a904(%rip), %r9      # 0x96c90
movslq (%r9,%r8,4), %r8
addq %r9, %r8
jmpq *%r8
movl $0x5, 0x8(%rdi)
movl 0x1(%rsi,%rdx), %ecx
bswapl %ecx
movl $0x5, %edx
jmp 0x2c43a
movl $0x1, 0x8(%rdi)
movl $0x1, %edx
cmpl $0xdf, %ecx
jle 0x2c3e0
cmpl $0xe0, %ecx
je 0x2c423
cmpl $0xf0, %ecx
je 0x2c42a
cmpl $0xfe, %ecx
jne 0x2c438
movl $0x1, %ecx
jmp 0x2c43a
cmpl $0xc0, %ecx
je 0x2c431
cmpl $0xd0, %ecx
jne 0x2c438
movl $0x4, %ecx
jmp 0x2c43a
movl $0x1, 0x8(%rdi)
andl $0x3f, %ecx
movl $0x1, %edx
jmp 0x2c43a
movl $0x2, 0x8(%rdi)
andl $0x3f, %ecx
shll $0x8, %ecx
movzbl 0x1(%rsi,%rdx), %edx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x2c43a
movl $0x8, %ecx
jmp 0x2c43a
movl $0x3, %ecx
jmp 0x2c43a
movl $0x2, %ecx
jmp 0x2c43a
xorl %ecx, %ecx
movl %ecx, 0xc(%rdi)
addl %eax, %edx
movl %edx, 0x10(%rdi)
movq %rsi, 0x18(%rdi)
retq
pushq %rax
leaq 0x6cead(%rip), %rdi     # 0x992fc
leaq 0x6a85f(%rip), %rsi     # 0x96cb5
movl $0x2e9, %edx            # imm = 0x2E9
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: zipRawEntryLength
static unsigned int zipRawEntryLength(unsigned char *p) {
    unsigned int prevlensize, encoding, lensize, len;

    // 取出编码前置节点的长度所需的字节数
    // T = O(1)
    ZIP_DECODE_PREVLENSIZE(p, prevlensize);

    // 取出当前节点值的编码类型，编码节点值长度所需的字节数，以及节点值的长度
    // T = O(1)
    ZIP_DECODE_LENGTH(p + prevlensize, encoding, lensize, len);

    // 计算节点占用的字节数总和
    return prevlensize + lensize + len;
}

// Assembly:
xorl %eax, %eax
cmpb $-0x2, (%rdi)
setae %al
leal 0x1(,%rax,4), %eax
movzbl (%rdi,%rax), %ecx
movl %ecx, %edx
andl $-0x40, %edx
cmpl $0xc0, %ecx
cmovael %ecx, %edx
cmpl $0xbf, %edx
ja 0x2c4b2
cmpb $-0x80, %dl
je 0x2c50c
movzbl %dl, %edx
cmpl $0x40, %edx
je 0x2c4f8
testl %edx, %edx
jne 0x2c535
andl $0x3f, %ecx
movl $0x1, %edx
jmp 0x2c530
movzbl %dl, %ecx
movl $0x1, %edx
cmpl $0xdf, %ecx
jle 0x2c4e1
cmpl $0xe0, %ecx
je 0x2c519
cmpl $0xf0, %ecx
je 0x2c520
cmpl $0xfe, %ecx
jne 0x2c52e
movl $0x1, %ecx
jmp 0x2c530
cmpl $0xc0, %ecx
je 0x2c527
cmpl $0xd0, %ecx
jne 0x2c52e
movl $0x4, %ecx
jmp 0x2c530
andl $0x3f, %ecx
shll $0x8, %ecx
movzbl 0x1(%rdi,%rax), %edx
orl %edx, %ecx
movl $0x2, %edx
jmp 0x2c530
movl 0x1(%rdi,%rax), %ecx
bswapl %ecx
movl $0x5, %edx
jmp 0x2c530
movl $0x8, %ecx
jmp 0x2c530
movl $0x3, %ecx
jmp 0x2c530
movl $0x2, %ecx
jmp 0x2c530
xorl %ecx, %ecx
addl %edx, %eax
addl %ecx, %eax
retq
pushq %rax
leaq 0x6cdbf(%rip), %rdi     # 0x992fc
leaq 0x6a771(%rip), %rsi     # 0x96cb5
movl $0x253, %edx            # imm = 0x253
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistPrev
unsigned char *ziplistPrev(unsigned char *zl, unsigned char *p) {
    zlentry entry;

    /* Iterating backwards from ZIP_END should return the tail. When "p" is
     * equal to the first element of the list, we're already at the head,
     * and should return NULL. */
    
    // 如果 p 指向列表末端（列表为空，或者刚开始从表尾向表头迭代）
    // 那么尝试取出列表尾端节点
    if (p[0] == ZIP_END) {
        p = ZIPLIST_ENTRY_TAIL(zl);
        // 尾端节点也指向列表末端，那么列表为空
        return (p[0] == ZIP_END) ? NULL : p;
    
    // 如果 p 指向列表头，那么说明迭代已经完成
    } else if (p == ZIPLIST_ENTRY_HEAD(zl)) {
        return NULL;

    // 既不是表头也不是表尾，从表尾向表头移动指针
    } else {
        // 计算前一个节点的节点数
        entry = zipEntry(p);
        assert(entry.prevrawlen > 0);
        // 移动指针，指向前一个节点
        return p-entry.prevrawlen;
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
cmpb $-0x1, (%rsi)
je 0x2c5b4
movq %rsi, %rbx
addq $0xa, %rdi
cmpq %rsi, %rdi
je 0x2c5c7
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2c336
movl 0x4(%r14), %eax
testq %rax, %rax
je 0x2c5d4
subq %rax, %rbx
jmp 0x2c5c9
movl 0x4(%rdi), %eax
leaq (%rdi,%rax), %rcx
xorl %ebx, %ebx
cmpb $-0x1, (%rdi,%rax)
cmovneq %rcx, %rbx
jmp 0x2c5c9
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
leaq 0x6a6c5(%rip), %rdi     # 0x96ca0
leaq 0x6a6d3(%rip), %rsi     # 0x96cb5
movl $0x55c, %edx            # imm = 0x55C
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistGet
unsigned int ziplistGet(unsigned char *p, unsigned char **sstr, unsigned int *slen, long long *sval) {

    zlentry entry;
    if (p == NULL || p[0] == ZIP_END) return 0;
    if (sstr) *sstr = NULL;

    // 取出 p 所指向的节点的各项信息，并保存到结构 entry 中
    // T = O(1)
    entry = zipEntry(p);

    // 节点的值为字符串，将字符串长度保存到 *slen ，字符串保存到 *sstr
    // T = O(1)
    if (ZIP_IS_STR(entry.encoding)) {
        if (sstr) {
            *slen = entry.len;
            *sstr = p+entry.headersize;
        }
    
    // 节点的值为整数，解码值，并将值保存到 *sval
    // T = O(1)
    } else {
        if (sval) {
            *sval = zipLoadInteger(p+entry.headersize,entry.encoding);
        }
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x2c675
movq %rdi, %rbx
cmpb $-0x1, (%rdi)
je 0x2c675
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
testq %rsi, %rsi
je 0x2c628
movq $0x0, (%r15)
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2c336
movl 0x10(%r13), %eax
movb 0x14(%r13), %cl
movl $0x1, %ebp
cmpb $-0x41, %cl
jbe 0x2c662
testq %r14, %r14
je 0x2c675
addq %rax, %rbx
movzbl %cl, %esi
movq %rbx, %rdi
callq 0x2c686
movq %rax, (%r14)
jmp 0x2c675
testq %r15, %r15
je 0x2c675
movl 0x14(%rsp), %ecx
movl %ecx, (%r12)
addq %rax, %rbx
movq %rbx, (%r15)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistCompare
unsigned int ziplistCompare(unsigned char *p, unsigned char *sstr, unsigned int slen) {
    zlentry entry;
    unsigned char sencoding;
    long long zval, sval;
    if (p[0] == ZIP_END) return 0;

    // 取出节点
    entry = zipEntry(p);
    if (ZIP_IS_STR(entry.encoding)) {

        // 节点值为字符串，进行字符串对比

        /* Raw compare */
        if (entry.len == slen) {
            // T = O(N)
            return memcmp(p+entry.headersize,sstr,slen) == 0;
        } else {
            return 0;
        }
    } else {
        
        // 节点值为整数，进行整数对比

        /* Try to compare encoded values. Don't compare encoding because
         * different implementations may encoded integers differently. */
        if (zipTryEncoding(sstr,slen,&sval,&sencoding)) {
          // T = O(1)
          zval = zipLoadInteger(p+entry.headersize,entry.encoding);
          return zval == sval;
        }
    }

    return 0;
}

// Assembly:
cmpb $-0x1, (%rdi)
je 0x2c962
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2c336
movl 0x10(%r15), %r12d
movb 0x14(%r15), %r15b
cmpb $-0x41, %r15b
jbe 0x2c966
leaq 0x10(%rsp), %rdx
leaq 0xf(%rsp), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0x2c995
testl %eax, %eax
je 0x2c983
addq %r12, %rbx
movzbl %r15b, %esi
movq %rbx, %rdi
callq 0x2c686
cmpq 0x10(%rsp), %rax
jmp 0x2c97e
xorl %eax, %eax
jmp 0x2c991
cmpl %ebp, 0x1c(%rsp)
jne 0x2c983
addq %r12, %rbx
movl %ebp, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f6a0
testl %eax, %eax
sete %al
jmp 0x2c985
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movzbl %al, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/ziplist.c
// Function: ziplistLen
unsigned int ziplistLen(unsigned char *zl) {

    unsigned int len = 0;

    // 节点数小于 UINT16_MAX
    // T = O(1)
    if (intrev16ifbe(ZIPLIST_LENGTH(zl)) < UINT16_MAX) {
        len = intrev16ifbe(ZIPLIST_LENGTH(zl));

    // 节点数大于 UINT16_MAX 时，需要遍历整个列表才能计算出节点数
    // T = O(N)
    } else {
        unsigned char *p = zl+ZIPLIST_HEADER_SIZE;
        while (*p != ZIP_END) {
            p += zipRawEntryLength(p);
            len++;
        }

        /* Re-store length if small enough */
        if (len < UINT16_MAX) ZIPLIST_LENGTH(zl) = intrev16ifbe(len);
    }

    return len;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movzwl 0x8(%rdi), %ebp
cmpl $0xffff, %ebp           # imm = 0xFFFF
jne 0x2cc5d
movq %rdi, %rbx
cmpb $-0x1, 0xa(%rdi)
je 0x2cc57
leaq 0xa(%rbx), %r14
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x2c46a
movl %eax, %eax
incl %ebp
cmpb $-0x1, (%r14,%rax)
leaq (%r14,%rax), %r14
jne 0x2cc36
cmpl $0xfffe, %ebp           # imm = 0xFFFE
jbe 0x2cc59
jmp 0x2cc5d
xorl %ebp, %ebp
movw %bp, 0x8(%rbx)
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: getStringObjectSdsUsedMemory
size_t getStringObjectSdsUsedMemory(robj *o) {
    redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
    switch(o->encoding) {
    case REDIS_ENCODING_RAW: return zmalloc_size_sds(o->ptr);
    case REDIS_ENCODING_EMBSTR: return sdslen(o->ptr);
    default: return 0; /* Just integer encoding for now. */
    }
}

// Assembly:
movq %rdi, %rsi
movl (%rdi), %eax
testb $0xf, %al
jne 0x2cfae
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x2cfa2
testl %eax, %eax
jne 0x2cfab
movq 0x8(%rsi), %rdi
addq $-0x8, %rdi
jmp 0x7e530
movq 0x8(%rsi), %rax
movslq -0x8(%rax), %rax
retq
xorl %eax, %eax
retq
pushq %rax
leaq 0x69dd0(%rip), %rdx     # 0x96d86
leaq 0x69de1(%rip), %rcx     # 0x96d9e
xorl %edi, %edi
movl $0x31, %r8d
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: prepareClientToWrite
int prepareClientToWrite(redisClient *c) {

    // LUA 脚本环境所使用的伪客户端总是可写的
    if (c->flags & REDIS_LUA_CLIENT) return REDIS_OK;
    
    // 客户端是主服务器并且不接受查询，
    // 那么它是不可写的，出错
    if ((c->flags & REDIS_MASTER) &&
        !(c->flags & REDIS_MASTER_FORCE_REPLY)) return REDIS_ERR;

    // 无连接的伪客户端总是不可写的
    if (c->fd <= 0) return REDIS_ERR; /* Fake client */

    // 一般情况，为客户端套接字安装写处理器到事件循环
    if (c->bufpos == 0 && listLength(c->reply) == 0 &&
        (c->replstate == REDIS_REPL_NONE ||
         c->replstate == REDIS_REPL_ONLINE) &&
        aeCreateFileEvent(server.el, c->fd, AE_WRITABLE,
        sendReplyToClient, c) == AE_ERR) return REDIS_ERR;

    return REDIS_OK;
}

// Assembly:
pushq %rbx
movl 0x90(%rdi), %eax
xorl %ebx, %ebx
btl $0x8, %eax
jb 0x2d395
andl $0x2002, %eax           # imm = 0x2002
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
je 0x2d395
movq %rdi, %r8
movl (%rdi), %esi
testl %esi, %esi
jle 0x2d395
cmpl $0x0, 0x170(%r8)
jne 0x2d393
movq 0x60(%r8), %rax
cmpq $0x0, 0x28(%rax)
je 0x2d399
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
retq
movl 0x98(%r8), %eax
cmpl $0x9, %eax
je 0x2d3a9
testl %eax, %eax
jne 0x2d393
leaq 0x9cbf8(%rip), %rax     # 0xc9fa8
movq 0x28(%rax), %rdi
leaq 0x11(%rip), %rcx        # 0x2d3cc
movl $0x2, %edx
callq 0x20c22
cmpl $-0x1, %eax
jne 0x2d393
jmp 0x2d395
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyToBuffer
int _addReplyToBuffer(redisClient *c, char *s, size_t len) {
    size_t available = sizeof(c->buf)-c->bufpos;

    // 正准备关闭客户端，无须再发送内容
    if (c->flags & REDIS_CLOSE_AFTER_REPLY) return REDIS_OK;

    /* If there already are entries in the reply list, we cannot
     * add anything more to the static buffer. */
    // 回复链表里已经有内容，再添加内容到 c->buf 里面就是错误了
    if (listLength(c->reply) > 0) return REDIS_ERR;

    /* Check that the buffer has enough space available for this string. */
    // 空间必须满足
    if (len > available) return REDIS_ERR;

    // 复制内容到 c->buf 里面
    memcpy(c->buf+c->bufpos,s,len);
    c->bufpos+=len;

    return REDIS_OK;
}

// Assembly:
xorl %eax, %eax
testb $0x40, 0x90(%rdi)
jne 0x2d67f
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movslq 0x170(%rdi), %rcx
movl $0x4000, %eax           # imm = 0x4000
subq %rcx, %rax
movq 0x60(%rdi), %rdx
cmpq $0x0, 0x28(%rdx)
setne %dl
cmpq %rbx, %rax
setb %al
orb %dl, %al
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jne 0x2d678
leaq (%r14,%rcx), %rdi
addq $0x174, %rdi            # imm = 0x174
movq %rbx, %rdx
callq 0x1fbd0
addl %ebx, 0x170(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyObjectToList
void _addReplyObjectToList(redisClient *c, robj *o) {
    robj *tail;

    // 客户端即将被关闭，无须再发送回复
    if (c->flags & REDIS_CLOSE_AFTER_REPLY) return;

    // 链表中无缓冲块，直接将对象追加到链表中
    if (listLength(c->reply) == 0) {
        incrRefCount(o);
        listAddNodeTail(c->reply,o);

        // 链表中已有缓冲块，尝试将回复添加到块内
        // 如果当前的块不能容纳回复的话，那么新建一个块
        c->reply_bytes += getStringObjectSdsUsedMemory(o);
    } else {

        // 取出表尾的 SDS
        tail = listNodeValue(listLast(c->reply));

        /* Append to this object when possible. */
        // 如果表尾 SDS 的已用空间加上对象的长度，小于 REDIS_REPLY_CHUNK_BYTES
        // 那么将新对象的内容拼接到表尾 SDS 的末尾
        if (tail->ptr != NULL &&
            tail->encoding == REDIS_ENCODING_RAW &&
            sdslen(tail->ptr)+sdslen(o->ptr) <= REDIS_REPLY_CHUNK_BYTES)
        {
            c->reply_bytes -= zmalloc_size_sds(tail->ptr);
            tail = dupLastObjectIfNeeded(c->reply);
            // 拼接
            tail->ptr = sdscatlen(tail->ptr,o->ptr,sdslen(o->ptr));
            c->reply_bytes += zmalloc_size_sds(tail->ptr);

        // 直接将对象追加到末尾
        } else {
            incrRefCount(o);
            listAddNodeTail(c->reply,o);
            c->reply_bytes += getStringObjectSdsUsedMemory(o);
        }
    }

    // 检查回复缓冲区的大小，如果超过系统限制的话，那么关闭客户端
    asyncCloseClientOnOutputBufferLimitReached(c);
}

// Assembly:
testb $0x40, 0x90(%rdi)
jne 0x2d706
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x60(%rdi), %rax
cmpq $0x0, 0x28(%rax)
je 0x2d707
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x2d707
testb $-0x10, (%rax)
jne 0x2d707
movslq -0x8(%rdi), %rax
movq 0x8(%r14), %rcx
movslq -0x8(%rcx), %rcx
addq %rax, %rcx
cmpq $0x4000, %rcx           # imm = 0x4000
ja 0x2d707
addq $-0x8, %rdi
callq 0x7e530
subq %rax, 0x68(%rbx)
movq 0x60(%rbx), %rdi
callq 0x2d5be
movq %rax, %r15
movq 0x8(%rax), %rdi
movq 0x8(%r14), %rsi
movslq -0x8(%rsi), %rdx
callq 0x28689
movq %rax, 0x8(%r15)
leaq -0x8(%rax), %rdi
callq 0x7e530
jmp 0x2d723
retq
movq %r14, %rdi
callq 0x306f3
movq 0x60(%rbx), %rdi
movq %r14, %rsi
callq 0x204cb
movq %r14, %rdi
callq 0x2cf7d
addq %rax, 0x68(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2d734
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: asyncCloseClientOnOutputBufferLimitReached
void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) {
    redisAssert(c->reply_bytes < ULONG_MAX-(1024*64));

    // 已经被标记了
    if (c->reply_bytes == 0 || c->flags & REDIS_CLOSE_ASAP) return;

    // 检查限制
    if (checkClientOutputBufferLimits(c)) {
        sds client = catClientInfoString(sdsempty(),c);

        // 异步关闭
        freeClientAsync(c);
        redisLog(REDIS_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client);
        sdsfree(client);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x68(%rdi), %rax
cmpq $-0x10001, %rax         # imm = 0xFFFEFFFF
jae 0x2d7d2
testq %rax, %rax
je 0x2d7ca
movq %rdi, %rbx
testb $0x4, 0x91(%rdi)
jne 0x2d7ca
movq %rbx, %rdi
callq 0x2fafe
testl %eax, %eax
je 0x2d7ca
callq 0x2845e
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2f0da
movq %rax, %r14
movl 0x90(%rbx), %eax
btl $0xa, %eax
jb 0x2d7a5
orl $0x400, %eax            # imm = 0x400
movl %eax, 0x90(%rbx)
leaq 0x9c812(%rip), %rax     # 0xc9fa8
movq 0x1b8(%rax), %rdi
movq %rbx, %rsi
callq 0x204cb
leaq 0x69a79(%rip), %rsi     # 0x97225
movl $0x3, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x23223
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2850d
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x69a27(%rip), %rdi     # 0x97200
leaq 0x695be(%rip), %rsi     # 0x96d9e
movl $0x81a, %edx            # imm = 0x81A
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplySdsToList
void _addReplySdsToList(redisClient *c, sds s) {
    robj *tail;

    if (c->flags & REDIS_CLOSE_AFTER_REPLY) {
        sdsfree(s);
        return;
    }

    if (listLength(c->reply) == 0) {
        listAddNodeTail(c->reply,createObject(REDIS_STRING,s));
        c->reply_bytes += zmalloc_size_sds(s);
    } else {
        tail = listNodeValue(listLast(c->reply));

        /* Append to this object when possible. */
        if (tail->ptr != NULL && tail->encoding == REDIS_ENCODING_RAW &&
            sdslen(tail->ptr)+sdslen(s) <= REDIS_REPLY_CHUNK_BYTES)
        {
            c->reply_bytes -= zmalloc_size_sds(tail->ptr);
            tail = dupLastObjectIfNeeded(c->reply);
            tail->ptr = sdscatlen(tail->ptr,s,sdslen(s));
            c->reply_bytes += zmalloc_size_sds(tail->ptr);
            sdsfree(s);
        } else {
            listAddNodeTail(c->reply,createObject(REDIS_STRING,s));
            c->reply_bytes += zmalloc_size_sds(s);
        }
    }
    asyncCloseClientOnOutputBufferLimitReached(c);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
testb $0x40, 0x90(%rdi)
jne 0x2d881
movq %rdi, %rbx
movq 0x60(%rdi), %r15
cmpq $0x0, 0x28(%r15)
je 0x2d88e
movq 0x8(%r15), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x2d88e
testb $-0x10, (%rax)
jne 0x2d88e
movslq -0x8(%rdi), %rax
movslq -0x8(%r14), %rcx
addq %rax, %rcx
cmpq $0x4000, %rcx           # imm = 0x4000
ja 0x2d88e
addq $-0x8, %rdi
callq 0x7e530
subq %rax, 0x68(%rbx)
movq 0x60(%rbx), %rdi
callq 0x2d5be
movq %rax, %r15
movq 0x8(%rax), %rdi
movslq -0x8(%r14), %rdx
movq %r14, %rsi
callq 0x28689
movq %rax, 0x8(%r15)
leaq -0x8(%rax), %rdi
callq 0x7e530
addq %rax, 0x68(%rbx)
movq %r14, %rdi
callq 0x2850d
jmp 0x2d8b3
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2850d
xorl %edi, %edi
movq %r14, %rsi
callq 0x3059c
movq %r15, %rdi
movq %rax, %rsi
callq 0x204cb
addq $-0x8, %r14
movq %r14, %rdi
callq 0x7e530
addq %rax, 0x68(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2d734
// File: /workspace/github_c_makefile_star2_O3/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:
testb $0x40, 0x90(%rdi)
jne 0x2d942
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x60(%rdi), %rax
cmpq $0x0, 0x28(%rax)
je 0x2d943
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x2d943
testb $-0x10, (%rax)
jne 0x2d943
movslq -0x8(%rdi), %rax
addq %r14, %rax
cmpq $0x4000, %rax           # imm = 0x4000
ja 0x2d943
addq $-0x8, %rdi
callq 0x7e530
subq %rax, 0x68(%rbx)
movq 0x60(%rbx), %rdi
callq 0x2d5be
movq %rax, %r12
movq 0x8(%rax), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x28689
movq %rax, 0x8(%r12)
leaq -0x8(%rax), %rdi
callq 0x7e530
jmp 0x2d965
retq
movq %r15, %rdi
movq %r14, %rsi
callq 0x3068f
movq %rax, %r14
movq 0x60(%rbx), %rdi
movq %rax, %rsi
callq 0x204cb
movq %r14, %rdi
callq 0x2cf7d
addq %rax, 0x68(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2d734
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplySds
void addReplySds(redisClient *c, sds s) {
    if (prepareClientToWrite(c) != REDIS_OK) {
        /* The caller expects the sds to be free'd. */
        sdsfree(s);
        return;
    }
    if (_addReplyToBuffer(c,s,sdslen(s)) == REDIS_OK) {
        sdsfree(s);
    } else {
        /* This method free's the sds when it is no longer needed. */
        _addReplySdsToList(c,s);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x2d357
testl %eax, %eax
jne 0x2db94
testb $0x40, 0x90(%r14)
jne 0x2db94
movslq -0x8(%rbx), %r15
movslq 0x170(%r14), %rax
movl $0x4000, %ecx           # imm = 0x4000
subq %rax, %rcx
movq 0x60(%r14), %rdx
cmpq $0x0, 0x28(%rdx)
setne %dl
cmpq %r15, %rcx
setb %cl
orb %dl, %cl
je 0x2db77
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x2d7f4
leaq (%r14,%rax), %rdi
addq $0x174, %rdi            # imm = 0x174
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1fbd0
addl %r15d, 0x170(%r14)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2850d
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyStatusFormat
void addReplyStatusFormat(redisClient *c, const char *fmt, ...) {
    va_list ap;
    va_start(ap,fmt);
    sds s = sdscatvprintf(sdsempty(),fmt,ap);
    va_end(ap);
    addReplyStatusLength(c,s,sdslen(s));
    sdsfree(s);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xd0, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x2de40
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r15
movq %rsi, 0x10(%r15)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r15)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%r15)
callq 0x2845e
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2897a
movq %rax, %rbx
movslq -0x8(%rax), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2dd71
movq %rbx, %rdi
callq 0x2850d
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addDeferredMultiBulkLength
void *addDeferredMultiBulkLength(redisClient *c) {
    /* Note that we install the write event here even if the object is not
     * ready to be sent, since we are sure that before returning to the
     * event loop setDeferredMultiBulkLength() will be called. */
    if (prepareClientToWrite(c) != REDIS_OK) return NULL;
    listAddNodeTail(c->reply,createObject(REDIS_STRING,NULL));
    return listLast(c->reply);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2d357
testl %eax, %eax
je 0x2deae
xorl %eax, %eax
jmp 0x2dece
movq 0x60(%rbx), %r14
xorl %edi, %edi
xorl %esi, %esi
callq 0x3059c
movq %r14, %rdi
movq %rax, %rsi
callq 0x204cb
movq 0x60(%rbx), %rax
movq 0x8(%rax), %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: setDeferredMultiBulkLength
void setDeferredMultiBulkLength(redisClient *c, void *node, long length) {
    listNode *ln = (listNode*)node;
    robj *len, *next;

    /* Abort when *node is NULL (see addDeferredMultiBulkLength). */
    if (node == NULL) return;

    len = listNodeValue(ln);
    len->ptr = sdscatprintf(sdsempty(),"*%ld\r\n",length);
    len->encoding = REDIS_ENCODING_RAW; /* in case it was an EMBSTR. */
    c->reply_bytes += zmalloc_size_sds(len->ptr);
    if (ln->next != NULL) {
        next = listNodeValue(ln->next);

        /* Only glue when the next node is non-NULL (an sds in this case) */
        if (next->ptr != NULL) {
            c->reply_bytes -= zmalloc_size_sds(len->ptr);
            c->reply_bytes -= getStringObjectSdsUsedMemory(next);
            len->ptr = sdscatlen(len->ptr,next->ptr,sdslen(next->ptr));
            c->reply_bytes += zmalloc_size_sds(len->ptr);
            listDelNode(c->reply,ln->next);
        }
    }
    asyncCloseClientOnOutputBufferLimitReached(c);
}

// Assembly:
testq %rsi, %rsi
je 0x2df9a
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq 0x10(%rsi), %r12
callq 0x2845e
leaq 0x68eeb(%rip), %rsi     # 0x96deb
movq %rax, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x28a5e
movq %rax, 0x8(%r12)
andb $0xf, (%r12)
leaq -0x8(%rax), %rdi
callq 0x7e530
addq %rax, 0x68(%rbx)
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x2df87
movq 0x10(%rax), %r15
cmpq $0x0, 0x8(%r15)
je 0x2df87
movq 0x8(%r12), %rdi
addq $-0x8, %rdi
callq 0x7e530
subq %rax, 0x68(%rbx)
movq %r15, %rdi
callq 0x2cf7d
subq %rax, 0x68(%rbx)
movq 0x8(%r12), %rdi
movq 0x8(%r15), %rsi
movslq -0x8(%rsi), %rdx
callq 0x28689
movq %rax, 0x8(%r12)
leaq -0x8(%rax), %rdi
callq 0x7e530
addq %rax, 0x68(%rbx)
movq 0x60(%rbx), %rdi
movq 0x8(%r14), %rsi
callq 0x205b1
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2d734
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyBulkCString
void addReplyBulkCString(redisClient *c, char *s) {
    if (s == NULL) {
        addReply(c,shared.nullbulk);
    } else {
        addReplyBulkCBuffer(c,s,strlen(s));
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testq %rsi, %rsi
je 0x2e07d
movq %rsi, %r14
movq %rsi, %rdi
callq 0x1f4f0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2e237
leaq 0x9c77c(%rip), %rax     # 0xca800
movq 0x50(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2d97c
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyLongLongWithPrefix
void addReplyLongLongWithPrefix(redisClient *c, long long ll, char prefix) {
    char buf[128];
    int len;

    /* Things like $3\r\n or *2\r\n are emitted very often by the protocol
     * so we have a few shared objects to use if the integer is small
     * like it is most of the times. */
    if (prefix == '*' && ll < REDIS_SHARED_BULKHDR_LEN) {
        // 多条批量回复
        addReply(c,shared.mbulkhdr[ll]);
        return;
    } else if (prefix == '$' && ll < REDIS_SHARED_BULKHDR_LEN) {
        // 批量回复
        addReply(c,shared.bulkhdr[ll]);
        return;
    }

    buf[0] = prefix;
    len = ll2string(buf+1,sizeof(buf)-1,ll);
    buf[len+1] = '\r';
    buf[len+2] = '\n';
    addReplyString(c,buf,len+3);
}

// Assembly:
pushq %rbx
subq $0x80, %rsp
movq %rsi, %rax
movq %rdi, %rbx
cmpb $0x2a, %dl
setne %cl
cmpq $0x20, %rsi
setge %sil
orb %cl, %sil
jne 0x2e0c9
leaq 0x9c741(%rip), %rcx     # 0xca800
movq 0x13a30(%rcx,%rax,8), %rsi
jmp 0x2e0eb
cmpq $0x20, %rax
setge %cl
cmpb $0x24, %dl
setne %sil
orb %cl, %sil
jne 0x2e0fb
leaq 0x9c71d(%rip), %rcx     # 0xca800
movq 0x13b30(%rcx,%rax,8), %rsi
movq %rbx, %rdi
addq $0x80, %rsp
popq %rbx
jmp 0x2d97c
leaq 0x1(%rsp), %rdi
movb %dl, -0x1(%rdi)
movl $0x7f, %esi
movq %rax, %rdx
callq 0x300c7
cltq
movq %rsp, %rsi
movw $0xa0d, 0x1(%rax,%rsi)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rdx
movq %rbx, %rdi
callq 0x2dba1
addq $0x80, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: addReplyLongLong
void addReplyLongLong(redisClient *c, long long ll) {
    if (ll == 0)
        addReply(c,shared.czero);
    else if (ll == 1)
        addReply(c,shared.cone);
    else
        addReplyLongLongWithPrefix(c,ll,':');
}

// Assembly:
cmpq $0x1, %rsi
je 0x2e14e
testq %rsi, %rsi
jne 0x2e15e
leaq 0x9c6bb(%rip), %rax     # 0xca800
movq 0x20(%rax), %rsi
jmp 0x2d97c
leaq 0x9c6ab(%rip), %rax     # 0xca800
movq 0x28(%rax), %rsi
jmp 0x2d97c
movl $0x3a, %edx
jmp 0x2e097
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: acceptTcpHandler
void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    int cport, cfd, max = MAX_ACCEPTS_PER_CALL;
    char cip[REDIS_IP_STR_LEN];
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(mask);
    REDIS_NOTUSED(privdata);

    while(max--) {
        // accept 客户端连接
        cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
        if (cfd == ANET_ERR) {
            if (errno != EWOULDBLOCK)
                redisLog(REDIS_WARNING,
                    "Accepting client connection: %s", server.neterr);
            return;
        }
        redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport);
        // 为客户端创建客户端状态（redisClient）
        acceptCommonHandler(cfd,0);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebx
movl $0x1e8, %r14d           # imm = 0x1E8
addq 0x97c9c(%rip), %r14     # 0xc5fb8
movl $0xfffffc18, %r13d      # imm = 0xFFFFFC18
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
movl $0x2e, %ecx
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
movq %r12, %r8
callq 0x21dea
cmpl $-0x1, %eax
je 0x2e372
movl %eax, %ebp
movl 0xc(%rsp), %ecx
movl $0x1, %edi
leaq 0x68ac5(%rip), %rsi     # 0x96e1d
movq %r15, %rdx
xorl %eax, %eax
callq 0x23223
movl %ebp, %edi
xorl %esi, %esi
callq 0x2e3aa
incl %r13d
jne 0x2e32c
jmp 0x2e39b
callq 0x1f810
cmpl $0xb, (%rax)
je 0x2e39b
movl $0x1e8, %edx            # imm = 0x1E8
addq 0x97c30(%rip), %rdx     # 0xc5fb8
leaq 0x68a6e(%rip), %rsi     # 0x96dfd
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: acceptUnixHandler
void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
    int cfd, max = MAX_ACCEPTS_PER_CALL;
    REDIS_NOTUSED(el);
    REDIS_NOTUSED(mask);
    REDIS_NOTUSED(privdata);

    while(max--) {
        // accept 本地客户端连接
        cfd = anetUnixAccept(server.neterr, fd);
        if (cfd == ANET_ERR) {
            if (errno != EWOULDBLOCK)
                redisLog(REDIS_WARNING,
                    "Accepting client connection: %s", server.neterr);
            return;
        }
        redisLog(REDIS_VERBOSE,"Accepted connection to %s", server.unixsocket);
        // 为本地客户端创建客户端状态
        acceptCommonHandler(cfd,REDIS_UNIX_SOCKET);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movl $0xfffffc18, %r12d      # imm = 0xFFFFFC18
movl $0x1e8, %r14d           # imm = 0x1E8
addq 0x97b55(%rip), %r14     # 0xc5fb8
leaq 0x9bb3e(%rip), %r13     # 0xc9fa8
leaq 0x689bb(%rip), %r15     # 0x96e2c
movq %r14, %rdi
movl %ebx, %esi
callq 0x21ec9
cmpl $-0x1, %eax
je 0x2e4ab
movl %eax, %ebp
movq 0x118(%r13), %rdx
movl $0x1, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x23223
movl %ebp, %edi
movl $0x800, %esi            # imm = 0x800
callq 0x2e3aa
incl %r12d
jne 0x2e471
jmp 0x2e4b5
callq 0x1f810
cmpl $0xb, (%rax)
jne 0x2e4c4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1e8, %edx            # imm = 0x1E8
addq 0x97ae8(%rip), %rdx     # 0xc5fb8
leaq 0x68926(%rip), %rsi     # 0x96dfd
movl $0x3, %edi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23223
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: freeClientArgv
static void freeClientArgv(redisClient *c) {
    int j;
    for (j = 0; j < c->argc; j++)
        decrRefCount(c->argv[j]);
    c->argc = 0;
    c->cmd = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x30(%rdi)
jle 0x2e8f4
xorl %r14d, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x30b0c
incq %r14
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jl 0x2e8db
movl $0x0, 0x30(%rbx)
movq $0x0, 0x40(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: resetClient
void resetClient(redisClient *c) {
    redisCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL;

    freeClientArgv(c);
    c->reqtype = 0;
    c->multibulklen = 0;
    c->bulklen = -1;
    /* We clear the ASKING flag as well if we are not inside a MULTI, and
     * if what we just executed is not the ASKING command itself. */
    if (!(c->flags & REDIS_MULTI) && prevcmd != askingCommand)
        c->flags &= (~REDIS_ASKING);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x40(%rdi), %rax
testq %rax, %rax
je 0x2e9a1
movq 0x8(%rax), %rax
cmpq 0x9755d(%rip), %rax     # 0xc5ef8
setne %bpl
jmp 0x2e9a4
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x2e8cb
movq $0x0, 0x50(%rbx)
movq $-0x1, 0x58(%rbx)
movl 0x90(%rbx), %eax
testb $0x8, %al
jne 0x2e9d6
testb %bpl, %bpl
je 0x2e9d6
andl $0xfffffdf7, %eax       # imm = 0xFFFFFDF7
movl %eax, 0x90(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: setProtocolError
static void setProtocolError(redisClient *c, int pos) {
    if (server.verbosity >= REDIS_VERBOSE) {
        sds client = catClientInfoString(sdsempty(),c);
        redisLog(REDIS_VERBOSE,
            "Protocol error from client: %s", client);
        sdsfree(client);
    }
    c->flags |= REDIS_CLOSE_AFTER_REPLY;
    sdsrange(c->querybuf,pos,-1);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leaq 0x9b437(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x464(%rax)
jle 0x2ebab
callq 0x2845e
movq %rax, %rdi
movq %r14, %rsi
callq 0x2f0da
movq %rax, %r15
leaq 0x6873e(%rip), %rsi     # 0x972d2
movl $0x1, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23223
movq %r15, %rdi
callq 0x2850d
orb $0x40, 0x90(%r14)
movq 0x20(%r14), %rdi
movl %ebx, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
popq %rbx
popq %r14
popq %r15
jmp 0x28f3c
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: clientsArePaused
int clientsArePaused(void) {
    if (server.clients_paused && server.clients_pause_end_time < server.mstime) {
        listNode *ln;
        listIter li;
        redisClient *c;

        server.clients_paused = 0;

        /* Put all the clients in the unblocked clients queue in order to
         * force the re-processing of the input buffer if any. */
        listRewind(server.clients,&li);
        while ((ln = listNext(&li)) != NULL) {
            c = listNodeValue(ln);

            if (c->flags & REDIS_SLAVE) continue;
            listAddNodeTail(server.unblocked_clients,c);
        }
    }
    return server.clients_paused;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x9af53(%rip), %r14     # 0xc9fa8
movl 0x1d8(%r14), %eax
testl %eax, %eax
je 0x2f0d0
movq 0x1e0(%r14), %rcx
cmpq 0x7a0(%r14), %rcx
jge 0x2f0d2
movl $0x0, 0x1d8(%r14)
movq 0x1b0(%r14), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x20637
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
je 0x2f0c7
leaq 0x8(%rsp), %rbx
movq 0x10(%rax), %rsi
testb $0x1, 0x90(%rsi)
jne 0x2f0ba
movq 0x738(%r14), %rdi
callq 0x204cb
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
jne 0x2f0a1
movl 0x1d8(%r14), %eax
jmp 0x2f0d2
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: genClientPeerId
int genClientPeerId(redisClient *client, char *peerid, size_t peerid_len) {
    char ip[REDIS_IP_STR_LEN];
    int port;

    if (client->flags & REDIS_UNIX_SOCKET) {
        /* Unix socket client. */
        snprintf(peerid,peerid_len,"%s:0",server.unixsocket);
        return REDIS_OK;
    } else {
        /* TCP client. */
        int retval = anetPeerToString(client->fd,ip,sizeof(ip),&port);
        formatPeerId(peerid,peerid_len,ip,port);
        return (retval == -1) ? REDIS_ERR : REDIS_OK;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r14
testb $0x8, 0x91(%rdi)
jne 0x2f48b
movl (%rdi), %edi
leaq 0x10(%rsp), %r15
leaq 0xc(%rsp), %r12
movl $0x2e, %edx
movq %r15, %rsi
movq %r12, %rcx
callq 0x21ee7
movl %eax, %r13d
movl (%r12), %ebp
movq %r15, %rdi
movl $0x3a, %esi
callq 0x1f790
testq %rax, %rax
leaq 0x69542(%rip), %rax     # 0x989a1
leaq 0x67c28(%rip), %rdx     # 0x9708e
cmoveq %rax, %rdx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x1f120
xorl %ebp, %ebp
cmpl $-0x1, %r13d
sete %bpl
negl %ebp
jmp 0x2f4af
leaq 0x9ab16(%rip), %rax     # 0xc9fa8
movq 0x118(%rax), %rcx
leaq 0x67bf6(%rip), %rdx     # 0x97096
xorl %ebp, %ebp
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1f120
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: getClientPeerId
char *getClientPeerId(redisClient *c) {
    char peerid[REDIS_PEER_ID_LEN];

    if (c->peerid == NULL) {
        genClientPeerId(c,peerid,sizeof(peerid));
        c->peerid = sdsnew(peerid);
    }
    return c->peerid;
}

// Assembly:
movq 0x168(%rdi), %rax
testq %rax, %rax
je 0x2f4cd
retq
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq %rsp, %r14
movl $0x4e, %edx
movq %r14, %rsi
callq 0x2f408
movq %r14, %rdi
callq 0x28486
movq %rax, 0x168(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: rewriteClientCommandVector
void rewriteClientCommandVector(redisClient *c, int argc, ...) {
    va_list ap;
    int j;
    robj **argv; /* The new argument vector */

    // 创建新参数
    argv = zmalloc(sizeof(robj*)*argc);
    va_start(ap,argc);
    for (j = 0; j < argc; j++) {
        robj *a;
        
        a = va_arg(ap, robj*);
        argv[j] = a;
        incrRefCount(a);
    }
    /* We free the objects in the original vector at the end, so we are
     * sure that if the same objects are reused in the new vector the
     * refcount gets incremented before it gets decremented. */
    // 释放旧参数
    for (j = 0; j < c->argc; j++) decrRefCount(c->argv[j]);
    zfree(c->argv);

    /* Replace argv and argc with our new versions. */
    // 用新参数替换
    c->argv = argv;
    c->argc = argc;
    c->cmd = lookupCommandOrOriginal(c->argv[0]->ptr);
    redisAssertWithInfo(c,NULL,c->cmd != NULL);
    va_end(ap);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x20(%rsp), %r15
movq %rdx, 0x10(%r15)
movq %rcx, 0x18(%r15)
movq %r8, 0x20(%r15)
movq %r9, 0x28(%r15)
testb %al, %al
je 0x2f8d4
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movslq %esi, %r12
leaq (,%r12,8), %rdi
callq 0x299b5
movq %rax, %r14
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r15, 0x10(%rsp)
testl %r12d, %r12d
jle 0x2f94d
movl %ebp, %r15d
xorl %r12d, %r12d
movl (%rsp), %ecx
cmpq $0x28, %rcx
ja 0x2f92b
movq %rcx, %rax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x2f939
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdi
movq %rdi, (%r14,%r12,8)
callq 0x306f3
incq %r12
cmpq %r12, %r15
jne 0x2f912
cmpl $0x0, 0x30(%rbx)
jle 0x2f96f
xorl %r15d, %r15d
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x30b0c
incq %r15
movslq 0x30(%rbx), %rax
cmpq %rax, %r15
jl 0x2f956
movq 0x38(%rbx), %rdi
callq 0x29af7
movq %r14, 0x38(%rbx)
movl %ebp, 0x30(%rbx)
movq (%r14), %rax
movq 0x8(%rax), %rdi
callq 0x25c2f
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x2f9a4
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x67833(%rip), %rdx     # 0x971de
leaq 0x673ec(%rip), %rcx     # 0x96d9e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x768, %r8d            # imm = 0x768
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0