LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/anet.c
// Function: anetPeerToString
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
    struct sockaddr_storage sa;
    socklen_t salen = sizeof(sa);

    if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) {
        if (port) *port = 0;
        ip[0] = '?';
        ip[1] = '\0';
        return -1;
    }
    if (sa.ss_family == AF_INET) {
        struct sockaddr_in *s = (struct sockaddr_in *)&sa;
        if (ip) inet_ntop(AF_INET,(void*)&(s->sin_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin_port);
    } else {
        struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
        if (ip) inet_ntop(AF_INET6,(void*)&(s->sin6_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin6_port);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x80, -0xa4(%rbp)
movl -0x8(%rbp), %edi
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xa4(%rbp), %rdx
callq 0x1f2b0
cmpl $-0x1, %eax
jne 0x22c59
cmpq $0x0, -0x20(%rbp)
je 0x22c3e
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movb $0x3f, (%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x1(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x22d18
movzwl -0xa0(%rbp), %eax
cmpl $0x2, %eax
jne 0x22cbb
leaq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x22c99
movq -0xb8(%rbp), %rsi
addq $0x4, %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movl %eax, %ecx
movl $0x2, %edi
callq 0x1fbe0
cmpq $0x0, -0x20(%rbp)
je 0x22cb9
movq -0xb8(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x1f560
movzwl %ax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x22d11
leaq -0xa0(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x22cef
movq -0xc0(%rbp), %rsi
addq $0x8, %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movl %eax, %ecx
movl $0xa, %edi
callq 0x1fbe0
cmpq $0x0, -0x20(%rbp)
je 0x22d0f
movq -0xc0(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x1f560
movzwl %ax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x22d11
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictResize
int dictResize(dict *d)
{
    int minimal;

    // 不能在关闭 rehash 或者正在 rehash 的时候调用
    if (!dict_can_resize || dictIsRehashing(d)) return DICT_ERR;

    // 计算让比率接近 1：1 所需要的最少节点数量
    minimal = d->ht[0].used;
    if (minimal < DICT_HT_INITIAL_SIZE)
        minimal = DICT_HT_INITIAL_SIZE;

    // 调整字典的大小
    // T = O(N)
    return dictExpand(d, minimal);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpl $0x0, 0xec411(%rip)     # 0x10f674
je 0x2326f
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
je 0x23278
movl $0x1, -0x4(%rbp)
jmp 0x232a0
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jge 0x23290
movl $0x4, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x232b0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictExpand
int dictExpand(dict *d, unsigned long size)
{
    // 新哈希表
    dictht n; /* the new hash table */

    // 根据 size 参数，计算哈希表的大小
    // T = O(1)
    unsigned long realsize = _dictNextPower(size);

    /* the size is invalid if it is smaller than the number of
     * elements already inside the hash table */
    // 不能在字典正在 rehash 时进行
    // size 的值也不能小于 0 号哈希表的当前已使用节点
    if (dictIsRehashing(d) || d->ht[0].used > size)
        return DICT_ERR;

    /* Allocate the new hash table and initialize all pointers to NULL */
    // 为哈希表分配空间，并将所有指针指向 NULL
    n.size = realsize;
    n.sizemask = realsize-1;
    // T = O(N)
    n.table = zcalloc(realsize*sizeof(dictEntry*));
    n.used = 0;

    /* Is this the first initialization? If so it's not really a rehashing
     * we just set the first hash table so that it can accept keys. */
    // 如果 0 号哈希表为空，那么这是一次初始化：
    // 程序将新哈希表赋给 0 号哈希表的指针，然后字典就可以开始处理键值对了。
    if (d->ht[0].table == NULL) {
        d->ht[0] = n;
        return DICT_OK;
    }

    /* Prepare a second hash table for incremental rehashing */
    // 如果 0 号哈希表非空，那么这是一次 rehash ：
    // 程序将新哈希表设置为 1 号哈希表，
    // 并将字典的 rehash 标识打开，让程序可以开始对字典进行 rehash
    d->ht[1] = n;
    d->rehashidx = 0;
    return DICT_OK;

    /* 顺带一提，上面的代码可以重构成以下形式：
    
    if (d->ht[0].table == NULL) {
        // 初始化
        d->ht[0] = n;
    } else {
        // rehash 
        d->ht[1] = n;
        d->rehashidx = 0;
    }

    return DICT_OK;

    */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x233a0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
jne 0x232e5
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x18(%rbp), %rax
jbe 0x232f1
movl $0x1, -0x4(%rbp)
jmp 0x2338c
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2e1d0
movq %rax, -0x38(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x23356
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x28(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x2338c
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x50(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictAdd
int dictAdd(dict *d, void *key, void *val)
{
    // 尝试添加键到字典，并返回包含了这个键的新哈希节点
    // T = O(N)
    dictEntry *entry = dictAddRaw(d,key);

    // 键已存在，添加失败
    if (!entry) return DICT_ERR;

    // 键不存在，设置节点的值
    // T = O(1)
    dictSetVal(d, entry, val);

    // 添加成功
    return DICT_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x23760
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x23705
movl $0x1, -0x4(%rbp)
jmp 0x23750
jmp 0x23707
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x2373b
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x23747
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x23749
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictAddRaw
dictEntry *dictAddRaw(dict *d, void *key)
{
    int index;
    dictEntry *entry;
    dictht *ht;

    // 如果条件允许的话，进行单步 rehash
    // T = O(1)
    if (dictIsRehashing(d)) _dictRehashStep(d);

    /* Get the index of the new element, or -1 if
     * the element already exists. */
    // 计算键在哈希表中的索引值
    // 如果值为 -1 ，那么表示键已经存在
    // T = O(N)
    if ((index = _dictKeyIndex(d, key)) == -1)
        return NULL;

    // T = O(1)
    /* Allocate the memory and store the new entry */
    // 如果字典正在 rehash ，那么将新键添加到 1 号哈希表
    // 否则，将新键添加到 0 号哈希表
    ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0];
    // 为新节点分配空间
    entry = zmalloc(sizeof(*entry));
    // 将新节点插入到链表表头
    entry->next = ht->table[index];
    ht->table[index] = entry;
    // 更新哈希表已使用节点数量
    ht->used++;

    /* Set the hash entry fields. */
    // 设置新节点的键
    // T = O(1)
    dictSetKey(d, entry, key);

    return entry;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
je 0x23783
movq -0x10(%rbp), %rdi
callq 0x23870
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x238a0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
jne 0x237a5
movq $0x0, -0x8(%rbp)
jmp 0x23865
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
je 0x237c1
movq -0x10(%rbp), %rax
addq $0x10, %rax
addq $0x20, %rax
movq %rax, -0x38(%rbp)
jmp 0x237cd
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x18, %edi
callq 0x2e130
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x8(%rax)
je 0x23850
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rsi
callq *%rax
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2385b
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2385d
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictKeyIndex
static int _dictKeyIndex(dict *d, const void *key)
{
    unsigned int h, idx, table;
    dictEntry *he;

    /* Expand the hash table if needed */
    // 单步 rehash
    // T = O(N)
    if (_dictExpandIfNeeded(d) == DICT_ERR)
        return -1;

    /* Compute the key hash value */
    // 计算 key 的哈希值
    h = dictHashKey(d, key);
    // T = O(1)
    for (table = 0; table <= 1; table++) {

        // 计算索引值
        idx = h & d->ht[table].sizemask;

        /* Search if this slot does not already contain the given key */
        // 查找 key 是否存在
        // T = O(1)
        he = d->ht[table].table[idx];
        while(he) {
            if (dictCompareKeys(d, key, he->key))
                return -1;
            he = he->next;
        }

        // 如果运行到这里时，说明 0 号哈希表中所有节点都不包含 key
        // 如果这时 rehahs 正在进行，那么继续对 1 号哈希表进行 rehash
        if (!dictIsRehashing(d)) break;
    }

    // 返回索引值
    return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x24a80
cmpl $0x1, %eax
jne 0x238ca
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x239ac
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
ja 0x239a6
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movl -0x24(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
andq 0x10(%rcx), %rax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movl -0x24(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2398a
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x18(%rax)
je 0x23966
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq (%rcx), %rdx
callq *%rax
cmpl $0x0, %eax
jne 0x23973
jmp 0x2397c
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x2397c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x239ac
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x2392a
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
jne 0x23996
jmp 0x239a6
jmp 0x23998
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x238e4
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictFind
dictEntry *dictFind(dict *d, const void *key)
{
    dictEntry *he;
    unsigned int h, idx, table;

    // 字典（的哈希表）为空
    if (d->ht[0].size == 0) return NULL; /* We don't have a table at all */

    // 如果条件允许的话，进行单步 rehash
    if (dictIsRehashing(d)) _dictRehashStep(d);

    // 计算键的哈希值
    h = dictHashKey(d, key);
    // 在字典的哈希表中查找这个键
    // T = O(1)
    for (table = 0; table <= 1; table++) {

        // 计算索引值
        idx = h & d->ht[table].sizemask;

        // 遍历给定索引上的链表的所有节点，查找 key
        he = d->ht[table].table[idx];
        // T = O(1)
        while(he) {

            if (dictCompareKeys(d, key, he->key))
                return he;

            he = he->next;
        }

        // 如果程序遍历完 0 号哈希表，仍然没找到指定的键的节点
        // 那么程序会检查字典是否在进行 rehash ，
        // 然后才决定是直接返回 NULL ，还是继续查找 1 号哈希表
        if (!dictIsRehashing(d)) return NULL;
    }

    // 进行到这里时，说明两个哈希表都没找到
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x23ac8
movq $0x0, -0x8(%rbp)
jmp 0x23bc8
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
je 0x23adb
movq -0x10(%rbp), %rdi
callq 0x23870
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rdi
callq *%rax
movl %eax, -0x24(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x1, -0x2c(%rbp)
ja 0x23bc0
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
movl -0x2c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rcx
andq 0x10(%rcx), %rax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
movl -0x2c(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x23b9c
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x18(%rax)
je 0x23b77
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rcx
movq (%rcx), %rdx
callq *%rax
cmpl $0x0, %eax
jne 0x23b84
jmp 0x23b8e
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq (%rcx), %rax
jne 0x23b8e
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x23bc8
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x23b3b
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
jne 0x23bb0
movq $0x0, -0x8(%rbp)
jmp 0x23bc8
jmp 0x23bb2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x23af5
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictReplaceRaw
dictEntry *dictReplaceRaw(dict *d, void *key) {
    
    // 使用 key 在字典中查找节点
    // T = O(1)
    dictEntry *entry = dictFind(d,key);

    // 如果节点找到了直接返回节点，否则添加并返回一个新节点
    // T = O(N)
    return entry ? entry : dictAddRaw(d,key);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x23aa0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x23c12
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x23c23
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x23760
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictFetchValue
void *dictFetchValue(dict *d, const void *key) {
    dictEntry *he;

    // T = O(1)
    he = dictFind(d,key);

    return he ? dictGetVal(he) : NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x23aa0
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x24086
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x2408e
xorl %eax, %eax
movq %rax, -0x20(%rbp)
jmp 0x2408e
movq -0x20(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictGetSafeIterator
dictIterator *dictGetSafeIterator(dict *d) {
    dictIterator *i = dictGetIterator(d);

    // 设置安全迭代器标识
    i->safe = 1;

    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x241d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x10(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictEmpty
void dictEmpty(dict *d, void(callback)(void*)) {

    // 删除两个哈希表上的所有节点
    // T = O(N)
    _dictClear(d,&d->ht[0],callback);
    _dictClear(d,&d->ht[1],callback);
    // 重置属性 
    d->rehashidx = -1;
    d->iterators = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x10, %rsi
movq -0x10(%rbp), %rdx
callq 0x23ea0
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x10, %rsi
addq $0x20, %rsi
movq -0x10(%rbp), %rdx
callq 0x23ea0
movq -0x8(%rbp), %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0x54(%rax)
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictExpandIfNeeded
static int _dictExpandIfNeeded(dict *d)
{
    /* Incremental rehashing already in progress. Return. */
    // 渐进式 rehash 已经在进行了，直接返回
    if (dictIsRehashing(d)) return DICT_OK;

    /* If the hash table is empty expand it to the initial size. */
    // 如果字典（的 0 号哈希表）为空，那么创建并返回初始化大小的 0 号哈希表
    // T = O(1)
    if (d->ht[0].size == 0) return dictExpand(d, DICT_HT_INITIAL_SIZE);

    /* If we reached the 1:1 ratio, and we are allowed to resize the hash
     * table (global setting) or we should avoid it but the ratio between
     * elements/buckets is over the "safe" threshold, we resize doubling
     * the number of buckets. */
    // 一下两个条件之一为真时，对字典进行扩展
    // 1）字典已使用节点数和字典大小之间的比率接近 1：1
    //    并且 dict_can_resize 为真
    // 2）已使用节点数和字典大小之间的比率超过 dict_force_resize_ratio
    if (d->ht[0].used >= d->ht[0].size &&
        (dict_can_resize ||
         d->ht[0].used/d->ht[0].size > dict_force_resize_ratio))
    {
        // 新哈希表的大小至少是目前已使用节点数的两倍
        // T = O(N)
        return dictExpand(d, d->ht[0].used*2);
    }

    return DICT_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
je 0x24a9f
movl $0x0, -0x4(%rbp)
jmp 0x24b15
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x24abd
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x232b0
movl %eax, -0x4(%rbp)
jmp 0x24b15
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jb 0x24b0e
cmpl $0x0, 0xeab9e(%rip)     # 0x10f674
jne 0x24af5
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
xorl %edx, %edx
divq 0x18(%rcx)
movl 0xeab88(%rip), %ecx     # 0x10f678
cmpq %rcx, %rax
jbe 0x24b0e
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
shlq %rsi
callq 0x232b0
movl %eax, -0x4(%rbp)
jmp 0x24b15
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: infoCommand
void infoCommand(redisClient *c) {
    char *section = c->argc == 2 ? c->argv[1]->ptr : "default";

    if (c->argc > 2) {
        addReply(c,shared.syntaxerr);
        return;
    }
    sds info = genRedisInfoString(section);
    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
        (unsigned long)sdslen(info)));
    addReplySds(c,info);
    addReply(c,shared.crlf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x30(%rax)
jne 0x24c7c
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x24c89
leaq 0xba900(%rip), %rax     # 0xdf583
movq %rax, -0x20(%rbp)
jmp 0x24c89
movq -0x20(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x30(%rax)
jle 0x24cad
movq -0x8(%rbp), %rdi
movq 0xef52a(%rip), %rsi     # 0x1141d0
callq 0x35a70
jmp 0x24d12
movq -0x10(%rbp), %rdi
callq 0x29db0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
callq 0x2c0c0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x24b20
movq -0x30(%rbp), %rdi
movq %rax, %rdx
leaq 0xbb2c5(%rip), %rsi     # 0xdffa7
movb $0x0, %al
callq 0x2cad0
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0x35c00
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x35c00
movq -0x8(%rbp), %rdi
movq 0xef443(%rip), %rsi     # 0x114150
callq 0x35a70
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: monitorCommand
void monitorCommand(redisClient *c) {
    /* ignore MONITOR if already slave or in monitor mode */

    // 这个客户端是从服务器，或者已经是监视器
    if (c->flags & REDIS_SLAVE) return;

    // 打开 SLAVE 标志和 MONITOR 标志
    c->flags |= (REDIS_SLAVE|REDIS_MONITOR);

    // 添加客户端到 monitors 链表
    listAddNodeTail(server.monitors,c);

    // 返回 OK
    addReply(c,shared.ok);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x24d40
jmp 0x24d73
movq -0x8(%rbp), %rax
movl 0x90(%rax), %ecx
orl $0x5, %ecx
movl %ecx, 0x90(%rax)
movq 0xeed66(%rip), %rdi     # 0x113ac0
movq -0x8(%rbp), %rsi
callq 0x1ff90
movq -0x8(%rbp), %rdi
movq 0xef3ea(%rip), %rsi     # 0x114158
callq 0x35a70
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisLog
void redisLog(int level, const char *fmt, ...) {
    va_list ap;
    char msg[REDIS_MAX_LOGMSG_LEN];

    if ((level&0xff) < server.verbosity) return;

    va_start(ap, fmt);
    vsnprintf(msg, sizeof(msg), fmt, ap);
    va_end(ap);

    redisLogRaw(level,msg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4e0, %rsp            # imm = 0x4E0
testb %al, %al
je 0x24ff7
movaps %xmm0, -0x4b0(%rbp)
movaps %xmm1, -0x4a0(%rbp)
movaps %xmm2, -0x490(%rbp)
movaps %xmm3, -0x480(%rbp)
movaps %xmm4, -0x470(%rbp)
movaps %xmm5, -0x460(%rbp)
movaps %xmm6, -0x450(%rbp)
movaps %xmm7, -0x440(%rbp)
movq %r9, -0x4b8(%rbp)
movq %r8, -0x4c0(%rbp)
movq %rcx, -0x4c8(%rbp)
movq %rdx, -0x4d0(%rbp)
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x4(%rbp), %eax
andl $0xff, %eax
cmpl 0xeed34(%rip), %eax     # 0x113d5c
jge 0x2502c
jmp 0x2507c
leaq -0x30(%rbp), %rax
leaq -0x4e0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x10, (%rax)
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq -0x30(%rbp), %rcx
movl $0x400, %esi            # imm = 0x400
callq 0x1f7c0
leaq -0x30(%rbp), %rax
movl -0x4(%rbp), %edi
leaq -0x430(%rbp), %rsi
callq 0x24dd0
addq $0x4e0, %rsp            # imm = 0x4E0
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: dictEncObjHash
unsigned int dictEncObjHash(const void *key) {
    robj *o = (robj*) key;

    if (sdsEncodedObject(o)) {
        return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
    } else {
        if (o->encoding == REDIS_ENCODING_INT) {
            char buf[32];
            int len;

            len = ll2string(buf,32,(long)o->ptr);
            return dictGenHashFunction((unsigned char*)buf, len);
        } else {
            unsigned int hash;

            o = getDecodedObject(o);
            hash = dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
            decrRefCount(o);
            return hash;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x25646
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
jne 0x2566f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x24b20
movq -0x50(%rbp), %rdi
movl %eax, %esi
callq 0x23030
movl %eax, -0x4(%rbp)
jmp 0x256ed
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x1, %eax
jne 0x256aa
leaq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movl $0x20, %esi
callq 0x39660
movl %eax, -0x44(%rbp)
leaq -0x40(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x23030
movl %eax, -0x4(%rbp)
jmp 0x256ed
movq -0x18(%rbp), %rdi
callq 0x3aef0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x24b20
movq -0x58(%rbp), %rdi
movl %eax, %esi
callq 0x23030
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3aaa0
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: htNeedsResize
int htNeedsResize(dict *dict) {
    long long size, used;

    size = dictSlots(dict);
    used = dictSize(dict);
    return (size && used && size > DICT_HT_INITIAL_SIZE &&
            (used*100/size < REDIS_HT_MINFILL));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
addq 0x38(%rcx), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x8(%rbp), %rcx
addq 0x48(%rcx), %rax
movq %rax, -0x18(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x19(%rbp)
je 0x25769
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x19(%rbp)
je 0x25769
xorl %eax, %eax
cmpq $0x4, -0x10(%rbp)
movb %al, -0x19(%rbp)
jle 0x25769
imulq $0x64, -0x18(%rbp), %rax
cqto
idivq -0x10(%rbp)
cmpq $0xa, %rax
setl %al
movb %al, -0x19(%rbp)
movb -0x19(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: trackOperationsPerSecond
void trackOperationsPerSecond(void) {

    // 计算两次抽样之间的时间长度，毫秒格式
    long long t = mstime() - server.ops_sec_last_sample_time;

    // 计算两次抽样之间，执行了多少个命令
    long long ops = server.stat_numcommands - server.ops_sec_last_sample_ops;

    long long ops_sec;

    // 计算距离上一次抽样之后，每秒执行命令的数量
    ops_sec = t > 0 ? (ops*1000/t) : 0;

    // 将计算出的执行命令数量保存到抽样数组
    server.ops_sec_samples[server.ops_sec_idx] = ops_sec;
    // 更新抽样数组的索引
    server.ops_sec_idx = (server.ops_sec_idx+1) % REDIS_OPS_SEC_SAMPLES;
    // 更新最后一次抽样的时间
    server.ops_sec_last_sample_time = mstime();
    // 更新最后一次抽样时的执行命令数量
    server.ops_sec_last_sample_ops = server.stat_numcommands;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
callq 0x252e0
subq 0xedfe4(%rip), %rax     # 0x113cc8
movq %rax, -0x8(%rbp)
movq 0xedf51(%rip), %rax     # 0x113c40
subq 0xedfda(%rip), %rax     # 0x113cd0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x8(%rbp)
jle 0x25d15
imulq $0x3e8, -0x10(%rbp), %rax # imm = 0x3E8
cqto
idivq -0x8(%rbp)
movq %rax, -0x20(%rbp)
jmp 0x25d1d
xorl %eax, %eax
movq %rax, -0x20(%rbp)
jmp 0x25d1d
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdx
movslq 0xee028(%rip), %rcx     # 0x113d58
leaq 0xedbc1(%rip), %rax     # 0x1138f8
movq %rdx, 0x3e0(%rax,%rcx,8)
movl 0xee013(%rip), %eax     # 0x113d58
addl $0x1, %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %edx, 0xee002(%rip)     # 0x113d58
callq 0x252e0
movq %rax, 0xedf66(%rip)     # 0x113cc8
movq 0xeded7(%rip), %rax     # 0x113c40
movq %rax, 0xedf60(%rip)     # 0x113cd0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: getOperationsPerSecond
long long getOperationsPerSecond(void) {
    int j;
    long long sum = 0;

    // 计算所有取样值的总和
    for (j = 0; j < REDIS_OPS_SEC_SAMPLES; j++)
        sum += server.ops_sec_samples[j];

    // 计算取样的平均值
    return sum / REDIS_OPS_SEC_SAMPLES;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq $0x0, -0x10(%rbp)
movl $0x0, -0x4(%rbp)
cmpl $0x10, -0x4(%rbp)
jge 0x25dbf
movslq -0x4(%rbp), %rcx
leaq 0xedb54(%rip), %rax     # 0x1138f8
movq 0x3e0(%rax,%rcx,8), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x25d93
movq -0x10(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: clientsCronHandleTimeout
int clientsCronHandleTimeout(redisClient *c) {

    // 获取当前时间
    time_t now = server.unixtime;

    // 服务器设置了 maxidletime 时间
    if (server.maxidletime &&
        // 不检查作为从服务器的客户端
        !(c->flags & REDIS_SLAVE) &&    /* no timeout for slaves */
        // 不检查作为主服务器的客户端
        !(c->flags & REDIS_MASTER) &&   /* no timeout for masters */
        // 不检查被阻塞的客户端
        !(c->flags & REDIS_BLOCKED) &&  /* no timeout for BLPOP */
        // 不检查订阅了频道的客户端
        dictSize(c->pubsub_channels) == 0 && /* no timeout for pubsub */
        // 不检查订阅了模式的客户端
        listLength(c->pubsub_patterns) == 0 &&
        // 客户端最后一次与服务器通讯的时间已经超过了 maxidletime 时间
        (now - c->lastinteraction > server.maxidletime))
    {
        redisLog(REDIS_VERBOSE,"Closing idle client");
        // 关闭超时客户端
        freeClient(c);
        return 1;
    } else if (c->flags & REDIS_BLOCKED) {

        /* Blocked OPS timeout is handled with milliseconds resolution.
         * However note that the actual resolution is limited by
         * server.hz. */
        // 获取最新的系统时间
        mstime_t now_ms = mstime();

        // 检查被 BLPOP 等命令阻塞的客户端的阻塞时间是否已经到达
        // 如果是的话，取消客户端的阻塞
        if (c->bpop.timeout != 0 && c->bpop.timeout < now_ms) {
            // 向客户端返回空回复
            replyToBlockedClientTimedOut(c);
            // 取消客户端的阻塞状态
            unblockClient(c);
        }
    }

    // 客户度没有被关闭
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq 0xee2ad(%rip), %rax     # 0x114090
movq %rax, -0x18(%rbp)
cmpl $0x0, 0xedf72(%rip)     # 0x113d60
je 0x25ea8
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x25ea8
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x25ea8
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x25ea8
movq -0x10(%rbp), %rax
movq 0x158(%rax), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x158(%rcx), %rcx
addq 0x48(%rcx), %rax
cmpq $0x0, %rax
jne 0x25ea8
movq -0x10(%rbp), %rax
movq 0x160(%rax), %rax
cmpq $0x0, 0x28(%rax)
jne 0x25ea8
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq 0x80(%rcx), %rax
movslq 0xedee2(%rip), %rcx     # 0x113d60
cmpq %rcx, %rax
jle 0x25ea8
movl $0x1, %edi
leaq 0xb88a8(%rip), %rsi     # 0xde737
movb $0x0, %al
callq 0x24fb0
movq -0x10(%rbp), %rdi
callq 0x36a80
movl $0x1, -0x4(%rbp)
jmp 0x25eff
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x25ef6
callq 0x252e0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x25ef4
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rax
cmpq -0x20(%rbp), %rax
jge 0x25ef4
movq -0x10(%rbp), %rdi
callq 0x82060
movq -0x10(%rbp), %rdi
callq 0x81f80
jmp 0x25ef6
jmp 0x25ef8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: clientsCronResizeQueryBuffer
int clientsCronResizeQueryBuffer(redisClient *c) {
    size_t querybuf_size = sdsAllocSize(c->querybuf);
    time_t idletime = server.unixtime - c->lastinteraction;

    /* There are two conditions to resize the query buffer:
     *
     * 符合以下两个条件的话，执行大小调整：
     *
     * 1) Query buffer is > BIG_ARG and too big for latest peak.
     *    查询缓冲区的大小大于 BIG_ARG 以及 querybuf_peak
     *
     * 2) Client is inactive and the buffer is bigger than 1k. 
     *    客户端不活跃，并且缓冲区大于 1k 。
     */
    if (((querybuf_size > REDIS_MBULK_BIG_ARG) &&
         (querybuf_size/(c->querybuf_peak+1)) > 2) ||
         (querybuf_size > 1024 && idletime > 2))
    {
        /* Only resize the query buffer if it is actually wasting space. */
        if (sdsavail(c->querybuf) > 1024) {
            c->querybuf = sdsRemoveFreeSpace(c->querybuf);
        }
    }

    /* Reset the peak again to capture the peak memory usage in the next
     * cycle. */
    // 重置峰值
    c->querybuf_peak = 0;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2c340
movq %rax, -0x10(%rbp)
movq 0xee15c(%rip), %rax     # 0x114090
movq -0x8(%rbp), %rcx
subq 0x80(%rcx), %rax
movq %rax, -0x18(%rbp)
cmpq $0x8000, -0x10(%rbp)    # imm = 0x8000
jbe 0x25f68
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x28(%rcx), %rcx
addq $0x1, %rcx
xorl %edx, %edx
divq %rcx
cmpq $0x2, %rax
ja 0x25f79
cmpq $0x400, -0x10(%rbp)     # imm = 0x400
jbe 0x25fa8
cmpq $0x2, -0x18(%rbp)
jle 0x25fa8
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x24b40
cmpq $0x400, %rax            # imm = 0x400
jbe 0x25fa6
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2c2f0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x25fa8
movq -0x8(%rbp), %rax
movq $0x0, 0x28(%rax)
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: beforeSleep
void beforeSleep(struct aeEventLoop *eventLoop) {
    REDIS_NOTUSED(eventLoop);

    /* Run a fast expire cycle (the called function will return
     * ASAP if a fast cycle is not needed). */
    // 执行一次快速的主动过期检查
    if (server.active_expire_enabled && server.masterhost == NULL)
        activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST);

    /* Send all the slaves an ACK request if at least one client blocked
     * during the previous event loop iteration. */
    if (server.get_ack_from_slaves) {
        robj *argv[3];

        argv[0] = createStringObject("REPLCONF",8);
        argv[1] = createStringObject("GETACK",6);
        argv[2] = createStringObject("*",1); /* Not used argument. */
        replicationFeedSlaves(server.slaves, server.slaveseldb, argv, 3);
        decrRefCount(argv[0]);
        decrRefCount(argv[1]);
        decrRefCount(argv[2]);
        server.get_ack_from_slaves = 0;
    }

    /* Unblock all the clients blocked for synchronous replication
     * in WAIT. */
    if (listLength(server.clients_waiting_acks))
        processClientsWaitingReplicas();

    /* Try to process pending commands for clients that were just unblocked. */
    if (listLength(server.unblocked_clients))
        processUnblockedClients();

    /* Write the AOF buffer on disk */
    // 将 AOF 缓冲区的内容写入到 AOF 文件
    flushAppendOnlyFile(0);

    /* Call the Redis Cluster before sleep function. */
    // 在进入下个事件循环前，执行一些集群收尾工作
    if (server.cluster_enabled) clusterBeforeSleep();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
cmpl $0x0, 0xed485(%rip)     # 0x113d68
je 0x268f9
cmpq $0x0, 0xed65b(%rip)     # 0x113f48
jne 0x268f9
movl $0x1, %edi
callq 0x259c0
cmpl $0x0, 0xed710(%rip)     # 0x114010
je 0x26981
leaq 0xb7f93(%rip), %rdi     # 0xde89c
movl $0x8, %esi
callq 0x3a2e0
movq %rax, -0x20(%rbp)
leaq 0xb7f87(%rip), %rdi     # 0xde8a5
movl $0x6, %esi
callq 0x3a2e0
movq %rax, -0x18(%rbp)
leaq 0xb7f79(%rip), %rdi     # 0xde8ac
movl $0x1, %esi
callq 0x3a2e0
movq %rax, -0x10(%rbp)
movq 0xed170(%rip), %rdi     # 0x113ab8
movl 0xed596(%rip), %esi     # 0x113ee4
leaq -0x20(%rbp), %rdx
movl $0x3, %ecx
callq 0x3f180
movq -0x20(%rbp), %rdi
callq 0x3aaa0
movq -0x18(%rbp), %rdi
callq 0x3aaa0
movq -0x10(%rbp), %rdi
callq 0x3aaa0
movl $0x0, 0xed68f(%rip)     # 0x114010
movq 0xed680(%rip), %rax     # 0x114008
cmpq $0x0, 0x28(%rax)
je 0x26994
callq 0x42870
movq 0xed695(%rip), %rax     # 0x114030
cmpq $0x0, 0x28(%rax)
je 0x269a7
callq 0x81e80
xorl %edi, %edi
callq 0x5ec30
cmpl $0x0, 0xed6ff(%rip)     # 0x1140b4
je 0x269bc
callq 0x6ea00
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: resetServerStats
void resetServerStats(void) {
    server.stat_numcommands = 0;
    server.stat_numconnections = 0;
    server.stat_expiredkeys = 0;
    server.stat_evictedkeys = 0;
    server.stat_keyspace_misses = 0;
    server.stat_keyspace_hits = 0;
    server.stat_fork_time = 0;
    server.stat_rejected_conn = 0;
    server.stat_sync_full = 0;
    server.stat_sync_partial_ok = 0;
    server.stat_sync_partial_err = 0;
    memset(server.ops_sec_samples,0,sizeof(server.ops_sec_samples));
    server.ops_sec_idx = 0;
    server.ops_sec_last_sample_time = mstime();
    server.ops_sec_last_sample_ops = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq $0x0, 0xebef1(%rip) # 0x113c40
movq $0x0, 0xebeee(%rip) # 0x113c48
movq $0x0, 0xebeeb(%rip) # 0x113c50
movq $0x0, 0xebee8(%rip) # 0x113c58
movq $0x0, 0xebeed(%rip) # 0x113c68
movq $0x0, 0xebeda(%rip) # 0x113c60
movq $0x0, 0xebee7(%rip) # 0x113c78
movq $0x0, 0xebee4(%rip) # 0x113c80
movq $0x0, 0xebee1(%rip) # 0x113c88
movq $0x0, 0xebede(%rip) # 0x113c90
movq $0x0, 0xebedb(%rip) # 0x113c98
leaq 0xebb34(%rip), %rdi     # 0x1138f8
addq $0x3e0, %rdi            # imm = 0x3E0
xorl %esi, %esi
movl $0x80, %edx
callq 0x1f110
movl $0x0, 0xebf77(%rip)     # 0x113d58
callq 0x252e0
movq %rax, 0xebedb(%rip)     # 0x113cc8
movq $0x0, 0xebed8(%rip) # 0x113cd0
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: evictionPoolAlloc
struct evictionPoolEntry *evictionPoolAlloc(void) {
    struct evictionPoolEntry *ep;
    int j;

    ep = zmalloc(sizeof(*ep)*REDIS_EVICTION_POOL_SIZE);
    for (j = 0; j < REDIS_EVICTION_POOL_SIZE; j++) {
        ep[j].idle = 0;
        ep[j].key = NULL;
    }
    return ep;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x100, %edi            # imm = 0x100
callq 0x2e130
movq %rax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x10, -0xc(%rbp)
jge 0x2853b
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, (%rax)
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x0, 0x8(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x284fd
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: lookupCommandOrOriginal
struct redisCommand *lookupCommandOrOriginal(sds name) {

    // 查找当前表
    struct redisCommand *cmd = dictFetchValue(server.commands, name);

    // 如果有需要的话，查找原始表
    if (!cmd) cmd = dictFetchValue(server.orig_commands,name);

    return cmd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq 0xeb1bd(%rip), %rdi     # 0x113910
movq -0x8(%rbp), %rsi
callq 0x24050
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2877b
movq 0xeb1aa(%rip), %rdi     # 0x113918
movq -0x8(%rbp), %rsi
callq 0x24050
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: propagate
void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
               int flags)
{
    // 传播到 AOF
    if (server.aof_state != REDIS_AOF_OFF && flags & REDIS_PROPAGATE_AOF)
        feedAppendOnlyFile(cmd,dbid,argv,argc);

    // 传播到 slave
    if (flags & REDIS_PROPAGATE_REPL)
        replicationFeedSlaves(server.slaves,dbid,argv,argc);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
cmpl $0x0, 0xeb617(%rip)     # 0x113dc8
je 0x287d1
movl -0x20(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x287d1
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
callq 0x5f700
movl -0x20(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x287f2
movq 0xeb2d5(%rip), %rdi     # 0x113ab8
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
callq 0x3f180
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: closeListeningSockets
void closeListeningSockets(int unlink_unix_socket) {
    int j;

    for (j = 0; j < server.ipfd_count; j++) close(server.ipfd[j]);

    if (server.sofd != -1) close(server.sofd);

    if (server.cluster_enabled)
        for (j = 0; j < server.cfd_count; j++) close(server.cfd[j]);

    if (unlink_unix_socket && server.unixsocket) {
        redisLog(REDIS_NOTICE,"Removing the unix socket file.");
        unlink(server.unixsocket); /* don't care if this fails */
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0xea191(%rip), %eax     # 0x113a5c
jge 0x298ef
movslq -0x8(%rbp), %rcx
leaq 0xea020(%rip), %rax     # 0x1138f8
movl 0x124(%rax,%rcx,4), %edi
callq 0x1f170
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x298c2
cmpl $-0x1, 0xea16a(%rip)    # 0x113a60
je 0x29903
movl 0xea162(%rip), %edi     # 0x113a60
callq 0x1f170
cmpl $0x0, 0xea7aa(%rip)     # 0x1140b4
je 0x29942
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0xea188(%rip), %eax     # 0x113aa4
jge 0x29940
movslq -0x8(%rbp), %rcx
leaq 0xe9fcf(%rip), %rax     # 0x1138f8
movl 0x16c(%rax,%rcx,4), %edi
callq 0x1f170
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x29913
jmp 0x29942
cmpl $0x0, -0x4(%rbp)
je 0x29971
cmpq $0x0, 0xea0c0(%rip)     # 0x113a10
je 0x29971
movl $0x2, %edi
leaq 0xb5a7a(%rip), %rsi     # 0xdf3d8
movb $0x0, %al
callq 0x24fb0
movq 0xea0a4(%rip), %rdi     # 0x113a10
callq 0x1f3a0
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: time_independent_strcmp
int time_independent_strcmp(char *a, char *b) {
    char bufa[REDIS_AUTHPASS_MAX_LEN], bufb[REDIS_AUTHPASS_MAX_LEN];
    /* The above two strlen perform len(a) + len(b) operations where either
     * a or b are fixed (our password) length, and the difference is only
     * relative to the length of the user provided string, so no information
     * leak is possible in the following two lines of code. */
    int alen = strlen(a);
    int blen = strlen(b);
    int j;
    int diff = 0;

    /* We can't compare strings longer than our static buffers.
     * Note that this will never pass the first test in practical circumstances
     * so there is no info leak. */
    if (alen > sizeof(bufa) || blen > sizeof(bufb)) return 1;

    memset(bufa,0,sizeof(bufa));        /* Constant time. */
    memset(bufb,0,sizeof(bufb));        /* Constant time. */
    /* Again the time of the following two copies is proportional to
     * len(a) + len(b) so no info is leaked. */
    memcpy(bufa,a,alen);
    memcpy(bufb,b,blen);

    /* Always compare all the chars in the two buffers without
     * conditional expressions. */
    for (j = 0; j < sizeof(bufa); j++) {
        diff |= (bufa[j] ^ bufb[j]);
    }
    /* Length must be equal as well. */
    diff |= alen ^ blen;
    return diff; /* If zero strings are the same. */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1f4d0
movl %eax, -0x424(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1f4d0
movl %eax, -0x428(%rbp)
movl $0x0, -0x430(%rbp)
movslq -0x424(%rbp), %rax
cmpq $0x200, %rax            # imm = 0x200
ja 0x29b69
movslq -0x428(%rbp), %rax
cmpq $0x200, %rax            # imm = 0x200
jbe 0x29b75
movl $0x1, -0x4(%rbp)
jmp 0x29c40
leaq -0x220(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x1f110
leaq -0x420(%rbp), %rdi
xorl %esi, %esi
movl $0x200, %edx            # imm = 0x200
callq 0x1f110
leaq -0x220(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x424(%rbp), %rdx
callq 0x1fbf0
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x428(%rbp), %rdx
callq 0x1fbf0
movl $0x0, -0x42c(%rbp)
movslq -0x42c(%rbp), %rax
cmpq $0x200, %rax            # imm = 0x200
jae 0x29c1f
movslq -0x42c(%rbp), %rax
movsbl -0x220(%rbp,%rax), %eax
movslq -0x42c(%rbp), %rcx
movsbl -0x420(%rbp,%rcx), %ecx
xorl %ecx, %eax
orl -0x430(%rbp), %eax
movl %eax, -0x430(%rbp)
movl -0x42c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x29bd3
movl -0x424(%rbp), %eax
xorl -0x428(%rbp), %eax
orl -0x430(%rbp), %eax
movl %eax, -0x430(%rbp)
movl -0x430(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: bytesToHuman
void bytesToHuman(char *s, unsigned long long n) {
    double d;

    if (n < 1024) {
        /* Bytes */
        sprintf(s,"%lluB",n);
        return;
    } else if (n < (1024*1024)) {
        d = (double)n/(1024);
        sprintf(s,"%.2fK",d);
    } else if (n < (1024LL*1024*1024)) {
        d = (double)n/(1024*1024);
        sprintf(s,"%.2fM",d);
    } else if (n < (1024LL*1024*1024*1024)) {
        d = (double)n/(1024LL*1024*1024);
        sprintf(s,"%.2fG",d);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x400, -0x10(%rbp)     # imm = 0x400
jae 0x29c85
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0xb58f2(%rip), %rsi     # 0xdf56b
movb $0x0, %al
callq 0x1f550
jmp 0x29da3
cmpq $0x100000, -0x10(%rbp)  # imm = 0x100000
jae 0x29ce3
movaps 0xb461a(%rip), %xmm1    # 0xde2b0
movq -0x10(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xb4619(%rip), %xmm1    # 0xde2c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xb4532(%rip), %xmm1    # 0xde1f0
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
leaq 0xb589a(%rip), %rsi     # 0xdf571
movb $0x1, %al
callq 0x1f550
jmp 0x29da1
cmpq $0x40000000, -0x10(%rbp) # imm = 0x40000000
jae 0x29d3e
movaps 0xb45bc(%rip), %xmm1    # 0xde2b0
movq -0x10(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xb45bb(%rip), %xmm1    # 0xde2c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xb44cc(%rip), %xmm1    # 0xde1e8
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
leaq 0xb5842(%rip), %rsi     # 0xdf577
movb $0x1, %al
callq 0x1f550
jmp 0x29d9f
movabsq $0x10000000000, %rax    # imm = 0x10000000000
cmpq %rax, -0x10(%rbp)
jae 0x29d9d
movaps 0xb455b(%rip), %xmm1    # 0xde2b0
movq -0x10(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0xb455a(%rip), %xmm1    # 0xde2c0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0xb4463(%rip), %xmm1    # 0xde1e0
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
leaq 0xb57e7(%rip), %rsi     # 0xdf57d
movb $0x1, %al
callq 0x1f550
jmp 0x29d9f
jmp 0x29da1
jmp 0x29da3
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)