LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationSendAck
void replicationSendAck(void) {
    redisClient *c = server.master;

    if (c != NULL) {
        c->flags |= REDIS_MASTER_FORCE_REPLY;
        addReplyMultiBulkLen(c,3);
        addReplyBulkCString(c,"REPLCONF");
        addReplyBulkCString(c,"ACK");
        // 发送偏移量
        addReplyBulkLongLong(c,c->reploff);
        c->flags &= ~REDIS_MASTER_FORCE_REPLY;
    }
}

// Assembly:
pushq %rbx
leaq 0x9608c(%rip), %rax     # 0xc9fa8
movq 0x660(%rax), %rbx
testq %rbx, %rbx
je 0x33f70
orb $0x20, 0x91(%rbx)
movl $0x3, %esi
movq %rbx, %rdi
callq 0x2ded8
leaq 0x608e1(%rip), %rsi     # 0x94824
movq %rbx, %rdi
callq 0x2ddc1
leaq 0x608de(%rip), %rsi     # 0x94830
movq %rbx, %rdi
callq 0x2ddc1
movq 0xb8(%rbx), %rsi
movq %rbx, %rdi
callq 0x2dfe7
andb $-0x21, 0x91(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationAbortSyncTransfer
void replicationAbortSyncTransfer(void) {
    redisAssert(server.repl_state == REDIS_REPL_TRANSFER);

    aeDeleteFileEvent(server.el,server.repl_transfer_s,AE_READABLE);
    close(server.repl_transfer_s);
    close(server.repl_transfer_fd);
    unlink(server.repl_transfer_tmpfile);
    zfree(server.repl_transfer_tmpfile);
    server.repl_state = REDIS_REPL_CONNECT;
}

// Assembly:
pushq %rbx
leaq 0x95c2c(%rip), %rbx     # 0xc9fa8
cmpl $0x4, 0x674(%rbx)
jne 0x343d3
movq 0x28(%rbx), %rdi
movl 0x690(%rbx), %esi
movl $0x1, %edx
callq 0x20a9d
movl 0x690(%rbx), %edi
callq 0x1f170
movl 0x694(%rbx), %edi
callq 0x1f170
movq 0x698(%rbx), %rdi
callq 0x1f3a0
movq 0x698(%rbx), %rdi
callq 0x2984b
movl $0x1, 0x674(%rbx)
popq %rbx
retq
leaq 0x63985(%rip), %rdi     # 0x97d5f
leaq 0x6333b(%rip), %rsi     # 0x9771c
movl $0x38d, %edx            # imm = 0x38D
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationSendNewlineToMaster
void replicationSendNewlineToMaster(void) {
    static time_t newline_sent;
    if (time(NULL) != newline_sent) {
        newline_sent = time(NULL);
        if (write(server.repl_transfer_s,"\n",1) == -1) {
            /* Pinging back in this stage is best-effort. */
        }
    }
}

// Assembly:
pushq %rax
xorl %edi, %edi
callq 0x1fc50
cmpq 0xaa214(%rip), %rax     # 0xde618
jne 0x34408
popq %rax
retq
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0xaa202(%rip)     # 0xde618
leaq 0x95b8b(%rip), %rax     # 0xc9fa8
movl 0x690(%rax), %edi
leaq 0x62317(%rip), %rsi     # 0x96741
movl $0x1, %edx
popq %rax
jmp 0x1fb30
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationDiscardCachedMaster
void replicationDiscardCachedMaster(void) {

    if (server.cached_master == NULL) return;

    redisLog(REDIS_NOTICE,"Discarding previously cached master state.");
    server.cached_master->flags &= ~REDIS_MASTER;
    freeClient(server.cached_master);
    server.cached_master = NULL;
}

// Assembly:
pushq %rbx
leaq 0x9538f(%rip), %rbx     # 0xc9fa8
cmpq $0x0, 0x668(%rbx)
je 0x34c54
leaq 0x63aef(%rip), %rsi     # 0x98719
movl $0x2, %edi
xorl %eax, %eax
callq 0x23064
movq 0x668(%rbx), %rdi
andl $-0x3, 0x90(%rdi)
callq 0x2e287
movq $0x0, 0x668(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationResurrectCachedMaster
void replicationResurrectCachedMaster(int newfd) {
    
    // 设置 master
    server.master = server.cached_master;
    server.cached_master = NULL;

    server.master->fd = newfd;

    server.master->flags &= ~(REDIS_CLOSE_AFTER_REPLY|REDIS_CLOSE_ASAP);

    server.master->authenticated = 1;
    server.master->lastinteraction = server.unixtime;

    // 回到已连接状态
    server.repl_state = REDIS_REPL_CONNECTED;

    /* Re-add to the list of clients. */
    // 将 master 重新加入到客户端列表中
    listAddNodeTail(server.clients,server.master);
    // 监听 master 的读事件
    if (aeCreateFileEvent(server.el, newfd, AE_READABLE,
                          readQueryFromClient, server.master)) {
        redisLog(REDIS_WARNING,"Error resurrecting the cached master, impossible to add the readable handler: %s", strerror(errno));
        freeClientAsync(server.master); /* Close ASAP. */
    }

    /* We may also need to install the write handler as well if there is
     * pending data in the write buffers. */
    if (server.master->bufpos || listLength(server.master->reply)) {
        if (aeCreateFileEvent(server.el, newfd, AE_WRITABLE,
                          sendReplyToClient, server.master)) {
            redisLog(REDIS_WARNING,"Error resurrecting the cached master, impossible to add the writable handler: %s", strerror(errno));
            freeClientAsync(server.master); /* Close ASAP. */
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x95345(%rip), %r14     # 0xc9fa8
movq 0x668(%r14), %rsi
movq %rsi, 0x660(%r14)
movq $0x0, 0x668(%r14)
movl %edi, (%rsi)
andl $0xfffffbbf, 0x90(%rsi) # imm = 0xFFFFFBBF
movl $0x1, 0x94(%rsi)
movq 0x798(%r14), %rax
movq %rax, 0x80(%rsi)
movl $0x5, 0x674(%r14)
movq 0x1b0(%r14), %rdi
callq 0x2045f
movq 0x28(%r14), %rdi
movq 0x660(%r14), %r8
leaq -0x7dab(%rip), %rcx     # 0x2cf1e
movl %ebx, %esi
movl $0x1, %edx
callq 0x209d7
testl %eax, %eax
je 0x34d07
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x63a58(%rip), %rsi     # 0x98744
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
movq 0x660(%r14), %rdi
callq 0x2e669
movq 0x660(%r14), %r8
cmpl $0x0, 0x170(%r8)
jne 0x34d23
movq 0x60(%r8), %rax
cmpq $0x0, 0x28(%rax)
je 0x34d73
movq 0x28(%r14), %rdi
leaq -0x7bf4(%rip), %rcx     # 0x2d13a
movl %ebx, %esi
movl $0x2, %edx
callq 0x209d7
testl %eax, %eax
je 0x34d73
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x63a44(%rip), %rsi     # 0x98795
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
movq 0x660(%r14), %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2e669
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: connectWithMaster
int connectWithMaster(void) {
    int fd;

    // 连接主服务器
    fd = anetTcpNonBlockConnect(NULL,server.masterhost,server.masterport);
    if (fd == -1) {
        redisLog(REDIS_WARNING,"Unable to connect to MASTER: %s",
            strerror(errno));
        return REDIS_ERR;
    }

    // 监听主服务器 fd 的读和写事件，并绑定文件事件处理器
    if (aeCreateFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE,syncWithMaster,NULL) ==
            AE_ERR)
    {
        close(fd);
        redisLog(REDIS_WARNING,"Can't create readable event for SYNC");
        return REDIS_ERR;
    }

    // 初始化统计变量
    server.repl_transfer_lastio = server.unixtime;
    server.repl_transfer_s = fd;

    // 将状态改为已连接
    server.repl_state = REDIS_REPL_CONNECTING;

    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
leaq 0x94dc4(%rip), %r15     # 0xc9fa8
movq 0x650(%r15), %rsi
movl 0x658(%r15), %edx
xorl %edi, %edi
callq 0x21766
cmpl $-0x1, %eax
je 0x35244
movl %eax, %ebx
movq 0x28(%r15), %rdi
leaq -0x490(%rip), %rcx      # 0x34d7b
xorl %r14d, %r14d
movl %eax, %esi
movl $0x3, %edx
xorl %r8d, %r8d
callq 0x209d7
cmpl $-0x1, %eax
je 0x35268
movq 0x798(%r15), %rax
movq %rax, 0x6a0(%r15)
movl %ebx, 0x690(%r15)
movl $0x2, 0x674(%r15)
jmp 0x35288
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x632b6(%rip), %rsi     # 0x9850d
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
jmp 0x35282
movl %ebx, %edi
callq 0x1f170
leaq 0x632b7(%rip), %rsi     # 0x9852d
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: undoConnectWithMaster
void undoConnectWithMaster(void) {
    int fd = server.repl_transfer_s;

    // 连接必须处于正在连接状态
    redisAssert(server.repl_state == REDIS_REPL_CONNECTING ||
                server.repl_state == REDIS_REPL_RECEIVE_PONG);
    aeDeleteFileEvent(server.el,fd,AE_READABLE|AE_WRITABLE);
    close(fd);
    server.repl_transfer_s = -1;
    // 回到 CONNECT 状态
    server.repl_state = REDIS_REPL_CONNECT;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x94d0c(%rip), %r14     # 0xc9fa8
movl 0x674(%r14), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x352e7
movl 0x690(%r14), %ebx
movq 0x28(%r14), %rdi
movl %ebx, %esi
movl $0x3, %edx
callq 0x20a9d
movl %ebx, %edi
callq 0x1f170
movl $0xffffffff, 0x690(%r14) # imm = 0xFFFFFFFF
movl $0x1, 0x674(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x63264(%rip), %rdi     # 0x98552
leaq 0x62427(%rip), %rsi     # 0x9771c
movl $0x615, %edx            # imm = 0x615
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: cancelReplicationHandshake
int cancelReplicationHandshake(void) {
    if (server.repl_state == REDIS_REPL_TRANSFER) {
        replicationAbortSyncTransfer();
    } else if (server.repl_state == REDIS_REPL_CONNECTING ||
             server.repl_state == REDIS_REPL_RECEIVE_PONG)
    {
        undoConnectWithMaster();
    } else {
        return 0;
    }
    return 1;
}

// Assembly:
pushq %rax
leaq 0x94c97(%rip), %rax     # 0xc9fa8
movl 0x674(%rax), %ecx
cmpl $0x4, %ecx
jne 0x35323
callq 0x34374
jmp 0x35332
andl $-0x2, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
jne 0x35337
callq 0x35291
movl $0x1, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationSetMaster
void replicationSetMaster(char *ip, int port) {

    // 清除原有的主服务器地址（如果有的话）
    sdsfree(server.masterhost);

    // IP
    server.masterhost = sdsnew(ip);

    // 端口
    server.masterport = port;

    // 清除原来可能有的主服务器信息。。。

    // 如果之前有其他地址，那么释放它
    if (server.master) freeClient(server.master);
    // 断开所有从服务器的连接，强制所有从服务器执行重同步
    disconnectSlaves(); /* Force our slaves to resync with us as well. */
    // 清空可能有的 master 缓存，因为已经不会执行 PSYNC 了
    replicationDiscardCachedMaster(); /* Don't try a PSYNC. */
    // 释放 backlog ，同理， PSYNC 目前已经不会执行了
    freeReplicationBacklog(); /* Don't allow our chained slaves to PSYNC. */
    // 取消之前的复制进程（如果有的话）
    cancelReplicationHandshake();

    // 进入连接状态（重点）
    server.repl_state = REDIS_REPL_CONNECT;
    server.master_repl_offset = 0;
    server.repl_down_since = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leaq 0x94c5e(%rip), %r15     # 0xc9fa8
movq 0x650(%r15), %rdi
callq 0x28204
movq %r14, %rdi
callq 0x281da
movq %rax, 0x650(%r15)
movl %ebx, 0x658(%r15)
movq 0x660(%r15), %rdi
testq %rdi, %rdi
je 0x3537d
callq 0x2e287
callq 0x2e261
callq 0x34c11
callq 0x331a9
callq 0x35309
movl $0x1, 0x674(%r15)
xorl %eax, %eax
movq %rax, 0x5f0(%r15)
movq %rax, 0x6b0(%r15)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationCacheMaster
void replicationCacheMaster(redisClient *c) {
    listNode *ln;

    redisAssert(server.master != NULL && server.cached_master == NULL);
    redisLog(REDIS_NOTICE,"Caching the disconnected master state.");

    /* Remove from the list of clients, we don't want this client to be
     * listed by CLIENT LIST or processed in any way by batch operations. */
    // 从客户端链表中移除主服务器
    ln = listSearchKey(server.clients,c);
    redisAssert(ln != NULL);
    listDelNode(server.clients,ln);

    /* Save the master. Server.master will be set to null later by
     * replicationHandleMasterDisconnection(). */
    // 缓存 master
    server.cached_master = server.master;

    /* Remove the event handlers and close the socket. We'll later reuse
     * the socket of the new connection with the master during PSYNC. */
    // 删除事件监视，关闭 socket
    aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
    aeDeleteFileEvent(server.el,c->fd,AE_WRITABLE);
    close(c->fd);

    /* Set fd to -1 so that we can safely call freeClient(c) later. */
    c->fd = -1;

    /* Invalidate the Peer ID cache. */
    if (c->peerid) {
        sdsfree(c->peerid);
        c->peerid = NULL;
    }

    /* Caching the master happens instead of the actual freeClient() call,
     * so make sure to adjust the replication state. This function will
     * also set server.master to NULL. */
    // 重置复制状态，并将 server.master 设为 NULL
    // 并强制断开这个服务器的所有从服务器，让它们执行 resync 
    replicationHandleMasterDisconnection();
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x94a1e(%rip), %r14     # 0xc9fa8
cmpq $0x0, 0x660(%r14)
je 0x35646
cmpq $0x0, 0x668(%r14)
jne 0x35646
movq %rdi, %rbx
leaq 0x63142(%rip), %rsi     # 0x986f2
movl $0x2, %edi
xorl %eax, %eax
callq 0x23064
movq 0x1b0(%r14), %rdi
movq %rbx, %rsi
callq 0x206d5
testq %rax, %rax
je 0x3565b
movq 0x1b0(%r14), %rdi
movq %rax, %rsi
callq 0x20544
movq 0x660(%r14), %rax
movq %rax, 0x668(%r14)
movq 0x28(%r14), %rdi
movl (%rbx), %esi
movl $0x1, %edx
callq 0x20a9d
movq 0x28(%r14), %rdi
movl (%rbx), %esi
movl $0x2, %edx
callq 0x20a9d
movl (%rbx), %edi
callq 0x1f170
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq 0x168(%rbx), %rdi
testq %rdi, %rdi
je 0x3563a
callq 0x28204
movq $0x0, 0x168(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2e5f0
leaq 0x6306f(%rip), %rdi     # 0x986bc
leaq 0x620c8(%rip), %rsi     # 0x9771c
movl $0x6e0, %edx            # imm = 0x6E0
jmp 0x3566e
leaq 0x6394b(%rip), %rdi     # 0x98fad
leaq 0x620b3(%rip), %rsi     # 0x9771c
movl $0x6e7, %edx            # imm = 0x6E7
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationScriptCacheInit
void replicationScriptCacheInit(void) {
    // 最大缓存脚本数
    server.repl_scriptcache_size = 10000;
    // 字典
    server.repl_scriptcache_dict = dictCreate(&replScriptCacheDictType,NULL);
    // FIFO 队列
    server.repl_scriptcache_fifo = listCreate();
}

// Assembly:
pushq %rbx
leaq 0x94923(%rip), %rbx     # 0xc9fa8
movl $0x2710, 0x708(%rbx)    # imm = 0x2710
leaq 0x943ea(%rip), %rdi     # 0xc9a80
xorl %esi, %esi
callq 0x21f97
movq %rax, 0x6f8(%rbx)
callq 0x2038c
movq %rax, 0x700(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationScriptCacheAdd
void replicationScriptCacheAdd(sds sha1) {
    int retval;
    sds key = sdsdup(sha1);

    /* Evict oldest. */
    // 如果大小超过数量限制，那么删除最旧
    if (listLength(server.repl_scriptcache_fifo) == server.repl_scriptcache_size)
    {
        listNode *ln = listLast(server.repl_scriptcache_fifo);
        sds oldest = listNodeValue(ln);

        retval = dictDelete(server.repl_scriptcache_dict,oldest);
        redisAssert(retval == DICT_OK);
        listDelNode(server.repl_scriptcache_fifo,ln);
    }

    /* Add current. */
    // 添加 SHA1
    retval = dictAdd(server.repl_scriptcache_dict,key,NULL);
    listAddNodeHead(server.repl_scriptcache_fifo,key);
    redisAssert(retval == DICT_OK);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
callq 0x281fb
movq %rax, %rbx
leaq 0x948e0(%rip), %r15     # 0xc9fa8
movq 0x700(%r15), %rax
movslq 0x708(%r15), %rcx
cmpq %rcx, 0x28(%rax)
jne 0x35703
movq 0x8(%rax), %r14
movq 0x10(%r14), %rsi
movq 0x6f8(%r15), %rdi
callq 0x225d3
testl %eax, %eax
jne 0x35749
movq 0x700(%r15), %rdi
movq %r14, %rsi
callq 0x20544
movq 0x6f8(%r15), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x222b6
movl %eax, %ebp
movq 0x700(%r15), %rdi
movq %rbx, %rsi
callq 0x20400
testl %ebp, %ebp
jne 0x35734
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x630ab(%rip), %rdi     # 0x987e6
leaq 0x61fda(%rip), %rsi     # 0x9771c
movl $0x7ea, %edx            # imm = 0x7EA
jmp 0x3575c
leaq 0x63096(%rip), %rdi     # 0x987e6
leaq 0x61fc5(%rip), %rsi     # 0x9771c
movl $0x7e2, %edx            # imm = 0x7E2
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationCountAcksByOffset
int replicationCountAcksByOffset(long long offset) {
    listIter li;
    listNode *ln;
    int count = 0;

    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        redisClient *slave = ln->value;

        if (slave->replstate != REDIS_REPL_ONLINE) continue;
        if (slave->repl_ack_off >= offset) count++;
    }
    return count;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x947f6(%rip), %rax     # 0xc9fa8
movq 0x1c0(%rax), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x205d2
movq %r14, %rdi
callq 0x205ef
xorl %ebp, %ebp
testq %rax, %rax
je 0x357fe
movq %rsp, %r14
movq 0x10(%rax), %rax
cmpl $0x9, 0x98(%rax)
jne 0x357f1
xorl %ecx, %ecx
cmpq %rbx, 0xc0(%rax)
setge %cl
addl %ecx, %ebp
movq %r14, %rdi
callq 0x205ef
testq %rax, %rax
jne 0x357d6
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: waitCommand
void waitCommand(redisClient *c) {
    mstime_t timeout;
    long numreplicas, ackreplicas;
    long long offset = c->woff;

    /* Argument parsing. */
    if (getLongFromObjectOrReply(c,c->argv[1],&numreplicas,NULL) != REDIS_OK)
        return;
    if (getTimeoutFromObjectOrReply(c,c->argv[2],&timeout,UNIT_MILLISECONDS)
        != REDIS_OK) return;

    /* First try without blocking at all. */
    ackreplicas = replicationCountAcksByOffset(c->woff);
    if (ackreplicas >= numreplicas || c->flags & REDIS_MULTI) {
        addReplyLongLong(c,ackreplicas);
        return;
    }

    /* Otherwise block the client and put it into our list of clients
     * waiting for ack from slaves. */
    c->bpop.timeout = timeout;
    c->bpop.reploffset = offset;
    c->bpop.numreplicas = numreplicas;
    listAddNodeTail(server.clients_waiting_acks,c);
    blockClient(c,REDIS_BLOCKED_WAIT);

    /* Make sure that the server will send an ACK request to all the slaves
     * before returning to the event loop. */
    replicationRequestAckFromSlaves();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x148(%rdi), %r14
movq 0x8(%rax), %rsi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x310df
testl %eax, %eax
jne 0x358c7
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x60d78
testl %eax, %eax
jne 0x358c7
movq 0x148(%rbx), %rdi
callq 0x357a0
movslq %eax, %rsi
movq 0x8(%rsp), %rax
cmpq %rsi, %rax
jle 0x358bf
testb $0x8, 0x90(%rbx)
jne 0x358bf
movq 0x10(%rsp), %rcx
movq %rcx, 0x120(%rbx)
movq %r14, 0x140(%rbx)
movl %eax, 0x138(%rbx)
leaq 0x94712(%rip), %r14     # 0xc9fa8
movq 0x710(%r14), %rdi
movq %rbx, %rsi
callq 0x2045f
movq %rbx, %rdi
movl $0x2, %esi
callq 0x60dec
movl $0x1, 0x718(%r14)
jmp 0x358c7
movq %rbx, %rdi
callq 0x2dea3
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: processClientsWaitingReplicas
void processClientsWaitingReplicas(void) {
    long long last_offset = 0;
    int last_numreplicas = 0;

    listIter li;
    listNode *ln;

    listRewind(server.clients_waiting_acks,&li);
    while((ln = listNext(&li))) {
        redisClient *c = ln->value;

        /* Every time we find a client that is satisfied for a given
         * offset and number of replicas, we remember it so the next client
         * may be unblocked without calling replicationCountAcksByOffset()
         * if the requested offset / replicas were equal or less. */
        if (last_offset && last_offset > c->bpop.reploffset &&
                           last_numreplicas > c->bpop.numreplicas)
        {
            unblockClient(c);
            addReplyLongLong(c,last_numreplicas);
        } else {
            int numreplicas = replicationCountAcksByOffset(c->bpop.reploffset);

            if (numreplicas >= c->bpop.numreplicas) {
                last_offset = c->bpop.reploffset;
                last_numreplicas = numreplicas;
                unblockClient(c);
                addReplyLongLong(c,numreplicas);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x9467a(%rip), %rax     # 0xc9fa8
movq 0x710(%rax), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x205d2
movq %rbx, %rdi
callq 0x205ef
testq %rax, %rax
je 0x359b2
xorl %r15d, %r15d
leaq 0x8(%rsp), %rbx
xorl %ebp, %ebp
movq 0x10(%rax), %r14
testq %r15, %r15
je 0x35974
cmpq 0x140(%r14), %r15
jle 0x35974
cmpl 0x138(%r14), %ebp
jg 0x35992
movq 0x140(%r14), %rdi
callq 0x357a0
cmpl 0x138(%r14), %eax
jl 0x359a5
movq 0x140(%r14), %r15
movl %eax, %ebp
movq %r14, %rdi
callq 0x60e97
movslq %ebp, %rsi
movq %r14, %rdi
callq 0x2dea3
movq %rbx, %rdi
callq 0x205ef
testq %rax, %rax
jne 0x35959
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/replication.c
// Function: replicationGetSlaveOffset
long long replicationGetSlaveOffset(void) {
    long long offset = 0;

    if (server.masterhost != NULL) {
        if (server.master) {
            offset = server.master->reploff;
        } else if (server.cached_master) {
            offset = server.cached_master->reploff;
        }
    }
    /* offset may be -1 when the master does not support it at all, however
     * this function is designed to return an offset that can express the
     * amount of data processed by the master, so we return a positive
     * integer. */
    if (offset < 0) offset = 0;
    return offset;
}

// Assembly:
leaq 0x945e4(%rip), %rcx     # 0xc9fa8
cmpq $0x0, 0x650(%rcx)
je 0x359ef
movq 0x660(%rcx), %rax
testq %rax, %rax
jne 0x359e6
movq 0x668(%rcx), %rax
testq %rax, %rax
je 0x359ef
movq 0xb8(%rax), %rcx
jmp 0x359f1
xorl %ecx, %ecx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %rcx, %rax
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveLen
int rdbSaveLen(rio *rdb, uint32_t len) {
    unsigned char buf[2];
    size_t nwritten;

    if (len < (1<<6)) {
        /* Save a 6 bit len */
        buf[0] = (len&0xFF)|(REDIS_RDB_6BITLEN<<6);
        if (rdbWriteRaw(rdb,buf,1) == -1) return -1;
        nwritten = 1;

    } else if (len < (1<<14)) {
        /* Save a 14 bit len */
        buf[0] = ((len>>8)&0xFF)|(REDIS_RDB_14BITLEN<<6);
        buf[1] = len&0xFF;
        if (rdbWriteRaw(rdb,buf,2) == -1) return -1;
        nwritten = 2;

    } else {
        /* Save a 32 bit len */
        buf[0] = (REDIS_RDB_32BITLEN<<6);
        if (rdbWriteRaw(rdb,buf,1) == -1) return -1;
        len = htonl(len);
        if (rdbWriteRaw(rdb,&len,4) == -1) return -1;
        nwritten = 1+4;
    }

    return nwritten;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, 0x4(%rsp)
cmpl $0x3f, %esi
ja 0x35ffe
leaq 0x2(%rsp), %rax
movb %sil, (%rax)
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x35d7c
movl $0x1, %ecx
jmp 0x3602e
cmpl $0x3fff, %esi           # imm = 0x3FFF
ja 0x3603e
movl %esi, %ecx
shrl $0x8, %ecx
orb $0x40, %cl
leaq 0x2(%rsp), %rax
movb %cl, (%rax)
movb %sil, 0x1(%rax)
movl $0x2, %edx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x35d7c
movl $0x2, %ecx
cmpl $-0x1, %eax
je 0x36037
movl %ecx, %ebp
jmp 0x3607f
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x3607f
leaq 0x2(%rsp), %rsi
movb $-0x80, (%rsi)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x35d7c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x3607f
leaq 0x4(%rsp), %rsi
movl (%rsi), %eax
bswapl %eax
movl %eax, (%rsi)
movl $0x4, %edx
movq %rbx, %rdi
callq 0x35d7c
movl $0x5, %ecx
cmpl $-0x1, %eax
jne 0x36033
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbEncodeInteger
int rdbEncodeInteger(long long value, unsigned char *enc) {

    if (value >= -(1<<7) && value <= (1<<7)-1) {
        enc[0] = (REDIS_RDB_ENCVAL<<6)|REDIS_RDB_ENC_INT8;
        enc[1] = value&0xFF;
        return 2;

    } else if (value >= -(1<<15) && value <= (1<<15)-1) {
        enc[0] = (REDIS_RDB_ENCVAL<<6)|REDIS_RDB_ENC_INT16;
        enc[1] = value&0xFF;
        enc[2] = (value>>8)&0xFF;
        return 3;

    } else if (value >= -((long long)1<<31) && value <= ((long long)1<<31)-1) {
        enc[0] = (REDIS_RDB_ENCVAL<<6)|REDIS_RDB_ENC_INT32;
        enc[1] = value&0xFF;
        enc[2] = (value>>8)&0xFF;
        enc[3] = (value>>16)&0xFF;
        enc[4] = (value>>24)&0xFF;
        return 5;

    } else {
        return 0;
    }
}

// Assembly:
movq %rdi, %rcx
movsbq %cl, %rax
cmpq %rdi, %rax
jne 0x36272
movb $-0x40, (%rsi)
movl $0x2, %eax
movl $0x1, %edx
jmp 0x362ba
movswq %cx, %rax
cmpq %rcx, %rax
jne 0x36291
movb $-0x3f, (%rsi)
movb %cl, 0x1(%rsi)
shrq $0x8, %rcx
movl $0x3, %eax
movl $0x2, %edx
jmp 0x362ba
movslq %ecx, %rdx
xorl %eax, %eax
cmpq %rcx, %rdx
jne 0x362bd
movb $-0x3e, (%rsi)
movb %cl, 0x1(%rsi)
movb %ch, 0x2(%rsi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x3(%rsi)
shrq $0x18, %rcx
movl $0x5, %eax
movl $0x4, %edx
movb %cl, (%rsi,%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbTryIntegerEncoding
int rdbTryIntegerEncoding(char *s, size_t len, unsigned char *enc) {
    long long value;
    char *endptr, buf[32];

    /* Check if it's possible to encode this value as a number */
    // 尝试将值转换为整数
    value = strtoll(s, &endptr, 10);
    if (endptr[0] != '\0') return 0;

    // 尝试将转换后的整数转换回字符串
    ll2string(buf,32,value);

    /* If the number converted back into a string is not identical
     * then it's not possible to encode the string as integer */
    // 检查两次转换后的整数值能否还原回原来的字符串
    // 如果不行的话，那么转换失败
    if (strlen(buf) != len || memcmp(buf,s,len)) return 0;

    // 转换成功，对转换所得的整数进行特殊编码
    return rdbEncodeInteger(value,enc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
leaq 0x8(%rsp), %r13
movq %r13, %rsi
movl $0xa, %edx
callq 0x1fa70
movq %rax, %r14
movq (%r13), %rax
xorl %ebp, %ebp
cmpb $0x0, (%rax)
jne 0x36525
leaq 0x10(%rsp), %r13
movl $0x20, %esi
movq %r13, %rdi
movq %r14, %rdx
callq 0x2fe12
movq %r13, %rdi
callq 0x1f4f0
cmpq %r15, %rax
jne 0x36525
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1f6a0
testl %eax, %eax
jne 0x36525
movq %r14, %rdi
movq %rbx, %rsi
callq 0x36257
movl %eax, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveLzfStringObject
int rdbSaveLzfStringObject(rio *rdb, unsigned char *s, size_t len) {
    size_t comprlen, outlen;
    unsigned char byte;
    int n, nwritten = 0;
    void *out;

    /* We require at least four bytes compression for this to be worth it */
    // 压缩字符串
    if (len <= 4) return 0;
    outlen = len-4;
    if ((out = zmalloc(outlen+1)) == NULL) return 0;
    comprlen = lzf_compress(s, len, out, outlen);
    if (comprlen == 0) {
        zfree(out);
        return 0;
    }

    /* Data compressed! Let's save it on disk 
     *
     * 保存压缩后的字符串到 rdb 。
     */

    // 写入类型，说明这是一个 LZF 压缩字符串
    byte = (REDIS_RDB_ENCVAL<<6)|REDIS_RDB_ENC_LZF;
    if ((n = rdbWriteRaw(rdb,&byte,1)) == -1) goto writeerr;
    nwritten += n;

    // 写入字符串压缩后的长度
    if ((n = rdbSaveLen(rdb,comprlen)) == -1) goto writeerr;
    nwritten += n;
    
    // 写入字符串未压缩时的长度
    if ((n = rdbSaveLen(rdb,len)) == -1) goto writeerr;
    nwritten += n;

    // 写入压缩后的字符串
    if ((n = rdbWriteRaw(rdb,out,comprlen)) == -1) goto writeerr;
    nwritten += n;

    zfree(out);

    return nwritten;

writeerr:
    zfree(out);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebp, %ebp
cmpq $0x5, %rdx
jb 0x36601
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq -0x3(%rdx), %rdi
callq 0x29709
testq %rax, %rax
je 0x36601
movq %rax, %rbx
leal -0x4(%r15), %ecx
movq %r12, %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x1fce0
testl %eax, %eax
je 0x365f7
movl %eax, %r13d
leaq 0xf(%rsp), %rsi
movb $-0x3d, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0x35d7c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x365f9
movl %eax, %r12d
movl %r13d, %esi
movq %r14, %rdi
movq %rsi, 0x10(%rsp)
callq 0x35fd0
cmpl $-0x1, %eax
je 0x365f9
movl %eax, %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x35fd0
cmpl $-0x1, %eax
je 0x365f9
movl %eax, %r15d
movq %r14, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
callq 0x35d7c
cmpl $-0x1, %eax
je 0x365f9
addl %r12d, %r13d
addl %eax, %r15d
addl %r13d, %r15d
movl %r15d, %ebp
jmp 0x365f9
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x2984b
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadLzfStringObject
robj *rdbLoadLzfStringObject(rio *rdb) {
    unsigned int len, clen;
    unsigned char *c = NULL;
    sds val = NULL;

    // 读入压缩后的缓存长度
    if ((clen = rdbLoadLen(rdb,NULL)) == REDIS_RDB_LENERR) return NULL;
    // 读入字符串未压缩前的长度
    if ((len = rdbLoadLen(rdb,NULL)) == REDIS_RDB_LENERR) return NULL;
    // 压缩缓存空间
    if ((c = zmalloc(clen)) == NULL) goto err;
    // 字符串空间
    if ((val = sdsnewlen(NULL,len)) == NULL) goto err;

    // 读入压缩后的缓存
    if (rioRead(rdb,c,clen) == 0) goto err;

    // 解压缓存，得出字符串
    if (lzf_decompress(c,clen,val,len) == 0) goto err;
    zfree(c);

    // 创建字符串对象
    return createObject(REDIS_STRING,val);
err:
    zfree(c);
    sdsfree(val);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %esi, %esi
callq 0x36088
cmpl $-0x1, %eax
je 0x36750
movl %eax, %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x36088
cmpl $-0x1, %eax
je 0x36750
movl %eax, %r13d
movl %r12d, %ebp
movq %rbp, %rdi
callq 0x29709
movq %rax, %r15
testq %rax, %rax
je 0x366fb
movl %r13d, %esi
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x28148
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x36740
movl %r13d, (%rsp)
movl %r12d, 0x4(%rsp)
movq %r15, 0x8(%rsp)
movq %r15, %r13
testq %rbp, %rbp
je 0x36700
movq %rbp, %r12
movq 0x30(%rbx), %rax
cmpq %rbp, %rax
movq %rbp, %r14
cmovbq %rax, %r14
testq %rax, %rax
cmoveq %rbp, %r14
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq *(%rbx)
movq %rax, %r15
testq %rax, %rax
je 0x366e2
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x366d3
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq *%rax
addq %r14, %r13
movq %r12, %rbp
subq %r14, %rbp
addq %r14, 0x28(%rbx)
jmp 0x366e5
movq %r12, %rbp
testq %r15, %r15
jne 0x3668f
testq %r12, %r12
je 0x36700
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
jmp 0x36740
xorl %r14d, %r14d
jmp 0x36740
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl 0x4(%rsp), %esi
movq 0x10(%rsp), %r14
movq %r14, %rdx
movl (%rsp), %ecx
callq 0x29b1c
testl %eax, %eax
je 0x36740
movq %r15, %rdi
callq 0x2984b
xorl %edi, %edi
movq %r14, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x302c4
movq %r15, %rdi
callq 0x2984b
movq %r14, %rdi
callq 0x28204
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveRawString
int rdbSaveRawString(rio *rdb, unsigned char *s, size_t len) {
    int enclen;
    int n, nwritten = 0;

    /* Try integer encoding 
     *
     * 尝试进行整数值编码
     */
    if (len <= 11) {
        unsigned char buf[5];
        if ((enclen = rdbTryIntegerEncoding((char*)s,len,buf)) > 0) {
            // 整数转换成功，写入
            if (rdbWriteRaw(rdb,buf,enclen) == -1) return -1;
            // 返回字节数
            return enclen;
        }
    }

    /* Try LZF compression - under 20 bytes it's unable to compress even
     * aaaaaaaaaaaaaaaaaa so skip it 
     *
     * 如果字符串长度大于 20 ，并且服务器开启了 LZF 压缩，
     * 那么在保存字符串到数据库之前，先对字符串进行 LZF 压缩。
     */
    if (server.rdb_compression && len > 20) {

        // 尝试压缩
        n = rdbSaveLzfStringObject(rdb,s,len);

        if (n == -1) return -1;
        if (n > 0) return n;
        /* Return value of 0 means data can't be compressed, save the old way */
    }

    // 执行到这里，说明值 s 既不能编码为整数
    // 也不能被压缩
    // 那么直接将它写入到 rdb 中
    /* Store verbatim */

    // 写入长度
    if ((n = rdbSaveLen(rdb,len)) == -1) return -1;
    nwritten += n;

    // 写入内容
    if (len > 0) {
        if (rdbWriteRaw(rdb,s,len) == -1) return -1;
        nwritten += len;
    }

    return nwritten;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpq $0xb, %rdx
ja 0x367b3
leaq 0xb(%rsp), %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x364ab
movl %eax, %r12d
testl %eax, %eax
je 0x367ae
movl %r12d, %edx
leaq 0xb(%rsp), %rsi
movq %r15, %rdi
callq 0x35d7c
movl %eax, %ebp
cmpl $-0x1, %eax
cmovnel %r12d, %ebp
jmp 0x367ae
testl %r12d, %r12d
jne 0x36815
cmpq $0x15, %rbx
jb 0x367e2
leaq 0x937e8(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x590(%rax)
je 0x367e2
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x36536
cmpl $-0x1, %eax
je 0x36810
movl %eax, %ebp
testl %eax, %eax
jg 0x36815
movq %r15, %rdi
movl %ebx, %esi
callq 0x35fd0
cmpl $-0x1, %eax
je 0x36810
movl %eax, %ebp
testq %rbx, %rbx
je 0x36815
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x35d7c
addl %ebx, %ebp
cmpl $-0x1, %eax
cmovel %eax, %ebp
jmp 0x36815
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveLongLongAsStringObject
int rdbSaveLongLongAsStringObject(rio *rdb, long long value) {
    unsigned char buf[32];
    int n, nwritten = 0;

    // 尝试以节省空间的方式编码整数值 value 
    int enclen = rdbEncodeInteger(value,buf);

    // 编码成功，直接写入编码后的缓存
    // 比如，值 1 可以编码为 11 00 0001
    if (enclen > 0) {
        return rdbWriteRaw(rdb,buf,enclen);

    // 编码失败，将整数值转换成对应的字符串来保存
    // 比如，值 999999999 要编码成 "999999999" ，
    // 因为这个值没办法用节省空间的方式编码
    } else {
        /* Encode as string */
        // 转换成字符串表示
        enclen = ll2string((char*)buf,32,value);
        redisAssert(enclen < 32);
        // 写入字符串长度
        if ((n = rdbSaveLen(rdb,enclen)) == -1) return -1;
        nwritten += n;
        // 写入字符串
        if ((n = rdbWriteRaw(rdb,buf,enclen)) == -1) return -1;
        nwritten += n;
    }

    // 返回长度
    return nwritten;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rdx
movq %rdi, %rbx
movsbq %dl, %rax
cmpq %rsi, %rax
jne 0x3684a
movb $-0x40, (%rsp)
movb %dl, 0x1(%rsp)
movl $0x2, %eax
jmp 0x36895
movswq %dx, %rax
cmpq %rdx, %rax
jne 0x36866
movb $-0x3f, (%rsp)
movb %dl, 0x1(%rsp)
movb %dh, 0x2(%rsp)
movl $0x3, %eax
jmp 0x36895
movslq %edx, %rax
cmpq %rdx, %rax
jne 0x368fb
movb $-0x3e, (%rsp)
movb %dl, 0x1(%rsp)
movb %dh, 0x2(%rsp)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x3(%rsp)
movl %edx, %eax
shrl $0x18, %eax
movb %al, 0x4(%rsp)
movl $0x5, %eax
xorl %ecx, %ecx
testb %cl, %cl
je 0x368d9
movq %rsp, %rdi
movl $0x20, %esi
callq 0x2fe12
cmpl $0x20, %eax
jge 0x36901
movl %eax, %r14d
movq %rbx, %rdi
movl %eax, %esi
callq 0x35fd0
cmpl $-0x1, %eax
je 0x368eb
movl %eax, %ebp
movslq %r14d, %rdx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x35d7c
addl %eax, %ebp
cmpl $-0x1, %eax
cmovel %eax, %ebp
jmp 0x368f0
movq %rsp, %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x35d7c
movl %eax, %ebp
jmp 0x368f0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movb $0x1, %cl
xorl %eax, %eax
jmp 0x36897
leaq 0x6213a(%rip), %rdi     # 0x98a42
leaq 0x6212d(%rip), %rsi     # 0x98a3c
movl $0x1e0, %edx            # imm = 0x1E0
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveStringObject
int rdbSaveStringObject(rio *rdb, robj *obj) {

    /* Avoid to decode the object, then encode it again, if the
     * object is already integer encoded. */
    // 尝试对 INT 编码的字符串进行特殊编码
    if (obj->encoding == REDIS_ENCODING_INT) {
        return rdbSaveLongLongAsStringObject(rdb,(long)obj->ptr);

    // 保存 STRING 编码的字符串
    } else {
        redisAssertWithInfo(NULL,obj,sdsEncodedObject(obj));
        return rdbSaveRawString(rdb,obj->ptr,sdslen(obj->ptr));
    }
}

// Assembly:
movl (%rsi), %eax
shrl $0x4, %eax
andl $0xf, %eax
je 0x36940
cmpl $0x8, %eax
je 0x36940
cmpl $0x1, %eax
jne 0x3694d
movq 0x8(%rsi), %rsi
jmp 0x36824
movq 0x8(%rsi), %rsi
movslq -0x8(%rsi), %rdx
jmp 0x36761
pushq %rax
leaq 0x620f9(%rip), %rdx     # 0x98a4e
leaq 0x620e0(%rip), %rcx     # 0x98a3c
xorl %edi, %edi
movl $0x1ff, %r8d            # imm = 0x1FF
callq 0x4d872
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbGenericLoadStringObject
robj *rdbGenericLoadStringObject(rio *rdb, int encode) {
    int isencoded;
    uint32_t len;
    sds val;

    // 长度
    len = rdbLoadLen(rdb,&isencoded);

    // 这是一个特殊编码字符串
    if (isencoded) {

        switch(len) {

        // 整数编码
        case REDIS_RDB_ENC_INT8:
        case REDIS_RDB_ENC_INT16:
        case REDIS_RDB_ENC_INT32:
            return rdbLoadIntegerObject(rdb,len,encode);

        // LZF 压缩
        case REDIS_RDB_ENC_LZF:
            return rdbLoadLzfStringObject(rdb);

        default:
            redisPanic("Unknown RDB encoding type");
        }
    }

    if (len == REDIS_RDB_LENERR) return NULL;

    // 执行到这里，说明这个字符串即没有被压缩，也不是整数
    // 那么直接从 rdb 中读入它
    val = sdsnewlen(NULL,len);
    if (len && rioRead(rdb,val,len) == 0) {
        sdsfree(val);
        return NULL;
    }

    return createObject(REDIS_STRING,val);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x14(%rsp), %r15
movq %r15, %rsi
callq 0x36088
movl %eax, %ebp
cmpl $0x0, (%r15)
je 0x369b7
cmpl $0x3, %ebp
jae 0x36a57
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x362be
jmp 0x36a61
cmpl $-0x1, %ebp
je 0x36a45
movl %ebp, %r14d
xorl %edi, %edi
movq %r14, %rsi
callq 0x28148
movq %rax, 0x8(%rsp)
testl %ebp, %ebp
je 0x36a49
movq 0x8(%rsp), %r15
testq %r14, %r14
je 0x36a49
movq %r14, %r12
movq 0x30(%rbx), %rax
cmpq %r14, %rax
movq %r14, %r13
cmovbq %rax, %r13
testq %rax, %rax
cmoveq %r14, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *(%rbx)
movq %rax, %rbp
testq %rax, %rax
je 0x36a2e
movq 0x18(%rbx), %rax
testq %rax, %rax
je 0x36a1f
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq *%rax
addq %r13, %r15
movq %r12, %r14
subq %r13, %r14
addq %r13, 0x28(%rbx)
jmp 0x36a31
movq %r12, %r14
testq %rbp, %rbp
jne 0x369db
testq %r12, %r12
je 0x36a49
movq 0x8(%rsp), %rdi
callq 0x28204
xorl %eax, %eax
jmp 0x36a61
xorl %edi, %edi
movq 0x8(%rsp), %rsi
callq 0x302c4
jmp 0x36a61
jne 0x36a70
movq %rbx, %rdi
callq 0x36612
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x61fed(%rip), %rdi     # 0x98a64
leaq 0x61fbe(%rip), %rsi     # 0x98a3c
movl $0x221, %edx            # imm = 0x221
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadDoubleValue
int rdbLoadDoubleValue(rio *rdb, double *val) {
    char buf[256];
    unsigned char len;

    // 载入字符串长度
    if (rioRead(rdb,&len,1) == 0) return -1;

    switch(len) {
    // 特殊值
    case 255: *val = R_NegInf; return 0;
    case 254: *val = R_PosInf; return 0;
    case 253: *val = R_Nan; return 0;
    // 载入字符串
    default:
        if (rioRead(rdb,buf,len) == 0) return -1;
        buf[len] = '\0';
        sscanf(buf, "%lg", val);
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movl $0x1, %eax
leaq 0x7(%rsp), %r15
testq %rax, %rax
je 0x36bb8
movq %rax, %rbx
movq 0x30(%r14), %rax
cmpq %rbx, %rax
movq %rbx, %r12
cmovbq %rax, %r12
testq %rax, %rax
cmoveq %rbx, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *(%r14)
movq %rax, %r13
testq %rax, %rax
je 0x36ba6
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x36b97
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
addq %r12, %r15
movq %rbx, %rax
subq %r12, %rax
addq %r12, 0x28(%r14)
jmp 0x36ba9
movq %rbx, %rax
testq %r13, %r13
jne 0x36b52
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
jne 0x36bfa
movzbl 0x7(%rsp), %eax
cmpl $0xfd, %eax
je 0x36be4
cmpl $0xfe, %eax
je 0x36bdb
cmpl $0xff, %eax
jne 0x36c0e
leaq 0xa7867(%rip), %rax     # 0xde440
jmp 0x36beb
leaq 0xa7856(%rip), %rax     # 0xde438
jmp 0x36beb
leaq 0xa785d(%rip), %rax     # 0xde448
movsd (%rax), %xmm0
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %r15
testq %rax, %rax
je 0x36c79
movq %rax, %rbx
movq 0x30(%r14), %rax
cmpq %rbx, %rax
movq %rbx, %r12
cmovbq %rax, %r12
testq %rax, %rax
cmoveq %rbx, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *(%r14)
movq %rax, %r13
testq %rax, %rax
je 0x36c67
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x36c58
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
addq %r12, %r15
movq %rbx, %rax
subq %r12, %rax
addq %r12, 0x28(%r14)
jmp 0x36c6a
movq %rbx, %rax
testq %r13, %r13
jne 0x36c13
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rbx, %rbx
jne 0x36bfa
movzbl 0x7(%rsp), %eax
movb $0x0, 0x10(%rsp,%rax)
leaq 0x61df6(%rip), %rsi     # 0x98a80
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x1f280
jmp 0x36bfa
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveKeyValuePair
int rdbSaveKeyValuePair(rio *rdb, robj *key, robj *val,
                        long long expiretime, long long now)
{
    /* Save the expire time 
     *
     * 保存键的过期时间
     */
    if (expiretime != -1) {
        /* If this key is already expired skip it 
         *
         * 不写入已经过期的键
         */
        if (expiretime < now) return 0;

        if (rdbSaveType(rdb,REDIS_RDB_OPCODE_EXPIRETIME_MS) == -1) return -1;
        if (rdbSaveMillisecondTime(rdb,expiretime) == -1) return -1;
    }

    /* Save type, key, value 
     *
     * 保存类型，键，值
     */
    if (rdbSaveObjectType(rdb,val) == -1) return -1;
    if (rdbSaveStringObject(rdb,key) == -1) return -1;
    if (rdbSaveObject(rdb,val) == -1) return -1;

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpq $-0x1, %rcx
je 0x3720c
movq %rcx, %r12
xorl %ebp, %ebp
cmpq %r8, %rcx
jl 0x3724b
leaq 0x7(%rsp), %rsi
movb $-0x4, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0x35d7c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x3724b
leaq 0x8(%rsp), %rsi
movq %r12, (%rsi)
movl $0x8, %edx
movq %r14, %rdi
callq 0x35d7c
cmpl $-0x1, %eax
je 0x3724b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x36ca2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x3724b
movq %r14, %rdi
movq %r15, %rsi
callq 0x36923
cmpl $-0x1, %eax
je 0x3724b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x36e19
xorl %ecx, %ecx
cmpl $-0x1, %eax
setne %cl
leal -0x1(,%rcx,2), %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: startLoading
void startLoading(FILE *fp) {
    struct stat sb;

    /* Load the DB */

    // 正在载入
    server.loading = 1;

    // 开始进行载入的时间
    server.loading_start_time = time(NULL);

    // 文件的大小
    if (fstat(fileno(fp), &sb) == -1) {
        server.loading_total_bytes = 1; /* just to avoid division by zero */
    } else {
        server.loading_total_bytes = sb.st_size;
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
leaq 0x91fae(%rip), %r14     # 0xc9fa8
movl $0x1, 0x2f0(%r14)
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0x308(%r14)
movq %rbx, %rdi
callq 0x1f070
leaq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x1f690
movl $0x1, %ecx
cmpl $-0x1, %eax
je 0x38036
movq 0x38(%rsp), %rcx
movq %rcx, 0x2f8(%r14)
addq $0x98, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadProgressCallback
void rdbLoadProgressCallback(rio *r, const void *buf, size_t len) {
    if (server.rdb_checksum)
        rioGenericUpdateChecksum(r, buf, len);
    if (server.loading_process_events_interval_bytes &&
        (r->processed_bytes + len)/server.loading_process_events_interval_bytes > r->processed_bytes/server.loading_process_events_interval_bytes)
    {
        /* The DB can take some non trivial amount of time to load. Update
         * our cached time since it is used to create and update the last
         * interaction time with clients and for other important things. */
        updateCachedTime();
        if (server.masterhost && server.repl_state == REDIS_REPL_TRANSFER)
            replicationSendNewlineToMaster();
        loadingProgress(r->processed_bytes);
        processEventsWhileBlocked();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x91f05(%rip), %r15     # 0xc9fa8
cmpl $0x0, 0x594(%r15)
je 0x380b8
movq %rbx, %rdi
movq %r14, %rdx
callq 0x58e67
movq 0x310(%r15), %rdi
testq %rdi, %rdi
je 0x38114
movq 0x28(%rbx), %rcx
addq %rcx, %r14
movq %r14, %rax
xorl %edx, %edx
divq %rdi
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
cmpq %rax, %rsi
jbe 0x38114
callq 0x23c9a
cmpq $0x0, 0x650(%r15)
je 0x38101
cmpl $0x4, 0x674(%r15)
jne 0x38101
callq 0x343f5
movq 0x28(%rbx), %rdi
callq 0x38048
popq %rbx
popq %r14
popq %r15
jmp 0x2f949
popq %rbx
popq %r14
popq %r15
retq