LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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 0x93c0d(%rip), %r15     # 0xc6fa8
movq 0x650(%r15), %rsi
movl 0x658(%r15), %edx
xorl %edi, %edi
callq 0x20f56
cmpl $-0x1, %eax
je 0x333f9
movl %eax, %ebx
movq 0x28(%r15), %rdi
leaq -0x42f(%rip), %rcx      # 0x32f93
xorl %r14d, %r14d
pushq $0x3
popq %rdx
movl %eax, %esi
xorl %r8d, %r8d
callq 0x2030c
cmpl $-0x1, %eax
je 0x3341b
movq 0x798(%r15), %rax
movq %rax, 0x6a0(%r15)
movl %ebx, 0x690(%r15)
movl $0x2, 0x674(%r15)
jmp 0x33437
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x5b135(%rip), %rsi     # 0x8e541
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x22613
jmp 0x33433
movl %ebx, %edi
callq 0x1f170
leaq 0x5b138(%rip), %rsi     # 0x8e561
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x22613
pushq $-0x1
popq %r14
movl %r14d, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x93b5d(%rip), %r14     # 0xc6fa8
movl 0x674(%r14), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0x33491
movl 0x690(%r14), %ebx
movq 0x28(%r14), %rdi
pushq $0x3
popq %rdx
movl %ebx, %esi
callq 0x203cd
movl %ebx, %edi
callq 0x1f170
orl $-0x1, 0x690(%r14)
movl $0x1, 0x674(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x5b0ee(%rip), %rdi     # 0x8e586
leaq 0x5a2b1(%rip), %rsi     # 0x8d750
movl $0x615, %edx            # imm = 0x615
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x93aef(%rip), %rax     # 0xc6fa8
movl 0x674(%rax), %ecx
cmpl $0x4, %ecx
jne 0x334cb
callq 0x325d1
jmp 0x334da
andl $-0x2, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
jne 0x334dd
callq 0x33440
pushq $0x1
popq %rax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x9388b(%rip), %r14     # 0xc6fa8
cmpq $0x0, 0x660(%r14)
je 0x337c9
cmpq $0x0, 0x668(%r14)
jne 0x337c9
movq %rdi, %rbx
leaq 0x5afe3(%rip), %rsi     # 0x8e726
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x22613
movq 0x1b0(%r14), %rdi
movq %rbx, %rsi
callq 0x20066
testq %rax, %rax
je 0x337de
movq 0x1b0(%r14), %rdi
movq %rax, %rsi
callq 0x1ff28
movq 0x660(%r14), %rax
movq %rax, 0x668(%r14)
movq 0x28(%r14), %rdi
movl (%rbx), %esi
pushq $0x1
popq %rdx
callq 0x203cd
movq 0x28(%r14), %rdi
movl (%rbx), %esi
pushq $0x2
popq %rdx
callq 0x203cd
movl (%rbx), %edi
callq 0x1f170
orl $-0x1, (%rbx)
movq 0x168(%rbx), %rdi
testq %rdi, %rdi
je 0x337bd
callq 0x271f7
andq $0x0, 0x168(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2ce6d
leaq 0x5af20(%rip), %rdi     # 0x8e6f0
leaq 0x59f79(%rip), %rsi     # 0x8d750
movl $0x6e0, %edx            # imm = 0x6E0
jmp 0x337f1
leaq 0x5b7d5(%rip), %rdi     # 0x8efba
leaq 0x59f64(%rip), %rsi     # 0x8d750
movl $0x6e7, %edx            # imm = 0x6E7
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x937a2(%rip), %rbx     # 0xc6fa8
movl $0x2710, 0x708(%rbx)    # imm = 0x2710
leaq 0x93269(%rip), %rdi     # 0xc6a80
xorl %esi, %esi
callq 0x216f0
movq %rax, 0x6f8(%rbx)
callq 0x1fd8c
movq %rax, 0x700(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x93677(%rip), %rax     # 0xc6fa8
movq 0x1c0(%rax), %rdi
movq %rsp, %r14
movq %r14, %rsi
callq 0x1ffac
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x1ffc6
testq %rax, %rax
je 0x3396f
movq 0x10(%rax), %rax
cmpl $0x9, 0x98(%rax)
jne 0x33945
xorl %ecx, %ecx
cmpq %rbx, 0xc0(%rax)
setge %cl
addl %ecx, %ebp
jmp 0x33945
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2f672
testl %eax, %eax
jne 0x33a34
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x10(%rsp), %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x5b94c
testl %eax, %eax
jne 0x33a34
movq 0x148(%rbx), %rdi
callq 0x3391f
movslq %eax, %rsi
movq 0x8(%rsp), %rax
cmpq %rsi, %rax
jle 0x33a2c
testb $0x8, 0x90(%rbx)
jne 0x33a2c
movq 0x10(%rsp), %rcx
movq %rcx, 0x120(%rbx)
movq %r14, 0x140(%rbx)
movl %eax, 0x138(%rbx)
leaq 0x935a3(%rip), %r14     # 0xc6fa8
movq 0x710(%r14), %rdi
movq %rbx, %rsi
callq 0x1fe4c
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x5b9be
movl $0x1, 0x718(%r14)
jmp 0x33a34
movq %rbx, %rdi
callq 0x2c794
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x3f, %esi
ja 0x3401e
leaq 0xa(%rsp), %rsi
movb %r14b, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x33eca
cmpl $-0x1, %eax
je 0x3404e
pushq $0x1
jmp 0x3408a
cmpl $0x3fff, %r14d          # imm = 0x3FFF
ja 0x34052
movl %r14d, %eax
shrl $0x8, %eax
orb $0x40, %al
leaq 0xa(%rsp), %rsi
movb %al, (%rsi)
movb %r14b, 0x1(%rsi)
pushq $0x2
popq %rdx
movq %rbx, %rdi
callq 0x33eca
cmpl $-0x1, %eax
je 0x3404e
pushq $0x2
jmp 0x3408a
pushq $-0x1
jmp 0x3408a
leaq 0xa(%rsp), %rsi
movb $-0x80, (%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x33eca
pushq $-0x1
popq %rbp
cmpl $-0x1, %eax
je 0x3408b
bswapl %r14d
leaq 0xc(%rsp), %rsi
movl %r14d, (%rsi)
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x33eca
cmpl $-0x1, %eax
je 0x3408b
pushq $0x5
popq %rbp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadLen
uint32_t rdbLoadLen(rio *rdb, int *isencoded) {
    unsigned char buf[2];
    uint32_t len;
    int type;

    if (isencoded) *isencoded = 0;

    // 读入 length ，这个值可能已经被编码，也可能没有
    if (rioRead(rdb,buf,1) == 0) return REDIS_RDB_LENERR;

    type = (buf[0]&0xC0)>>6;

    // 编码值，进行解码
    if (type == REDIS_RDB_ENCVAL) {
        /* Read a 6 bit encoding type. */
        if (isencoded) *isencoded = 1;
        return buf[0]&0x3F;

    // 6 位整数
    } else if (type == REDIS_RDB_6BITLEN) {
        /* Read a 6 bit len. */
        return buf[0]&0x3F;

    // 14 位整数
    } else if (type == REDIS_RDB_14BITLEN) {
        /* Read a 14 bit len. */
        if (rioRead(rdb,buf+1,1) == 0) return REDIS_RDB_LENERR;
        return ((buf[0]&0x3F)<<8)|buf[1];

    // 32 位整数
    } else {
        /* Read a 32 bit len. */
        if (rioRead(rdb,&len,4) == 0) return REDIS_RDB_LENERR;
        return ntohl(len);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testq %rsi, %rsi
je 0x340ad
andl $0x0, (%r14)
leaq 0xa(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x33f11
pushq $-0x1
popq %rbp
testq %rax, %rax
je 0x340e5
movzbl 0xa(%rsp), %eax
movl %eax, %ecx
shrl $0x6, %ecx
cmpl $0x3, %ecx
jne 0x340e9
testq %r14, %r14
je 0x340e0
movl $0x1, (%r14)
andl $0x3f, %eax
jmp 0x34140
movl %ebp, %eax
jmp 0x34140
cmpb $0x40, %al
jb 0x34140
cmpl $0x1, %ecx
jne 0x34120
leaq 0xb(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x33f11
movq %rax, %rcx
movl %ebp, %eax
testq %rcx, %rcx
je 0x34140
movzbl 0xa(%rsp), %ecx
andl $0x3f, %ecx
shll $0x8, %ecx
movzbl 0xb(%rsp), %eax
orl %ecx, %eax
jmp 0x34140
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x33f11
movq %rax, %rcx
movl %ebp, %eax
testq %rcx, %rcx
je 0x34140
movl 0xc(%rsp), %eax
bswapl %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x3415f
movb $-0x40, (%rsi)
pushq $0x2
popq %rax
pushq $0x1
jmp 0x3419d
movswq %cx, %rax
cmpq %rcx, %rax
jne 0x34179
movb $-0x3f, (%rsi)
movb %cl, 0x1(%rsi)
shrq $0x8, %rcx
pushq $0x3
popq %rax
pushq $0x2
jmp 0x3419d
movslq %ecx, %rdx
xorl %eax, %eax
cmpq %rcx, %rdx
jne 0x341a1
movb $-0x3e, (%rsi)
movb %cl, 0x1(%rsi)
movb %ch, 0x2(%rsi)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x3(%rsi)
shrq $0x18, %rcx
pushq $0x5
popq %rax
pushq $0x4
popq %rdx
movb %cl, (%rsi,%rdx)
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbLoadIntegerObject
robj *rdbLoadIntegerObject(rio *rdb, int enctype, int encode) {
    unsigned char enc[4];
    long long val;

    // 整数编码
    if (enctype == REDIS_RDB_ENC_INT8) {
        if (rioRead(rdb,enc,1) == 0) return NULL;
        val = (signed char)enc[0];
    } else if (enctype == REDIS_RDB_ENC_INT16) {
        uint16_t v;
        if (rioRead(rdb,enc,2) == 0) return NULL;
        v = enc[0]|(enc[1]<<8);
        val = (int16_t)v;
    } else if (enctype == REDIS_RDB_ENC_INT32) {
        uint32_t v;
        if (rioRead(rdb,enc,4) == 0) return NULL;
        v = enc[0]|(enc[1]<<8)|(enc[2]<<16)|(enc[3]<<24);
        val = (int32_t)v;
    } else {
        val = 0; /* anti-warning */
        redisPanic("Unknown RDB integer encoding type");
    }

    
    if (encode)
        // 整数编码的字符串
        return createStringObjectFromLongLong(val);
    else
        // 未编码
        return createObject(REDIS_STRING,sdsfromlonglong(val));
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebx
cmpl $0x2, %esi
je 0x341eb
cmpl $0x1, %esi
je 0x341d1
testl %esi, %esi
jne 0x34226
leaq 0xc(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x33f11
testq %rax, %rax
je 0x3420d
movsbq 0xc(%rsp), %rdi
jmp 0x34202
leaq 0xc(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x33f11
testq %rax, %rax
je 0x3420d
movswq 0xc(%rsp), %rdi
jmp 0x34202
leaq 0xc(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x33f11
testq %rax, %rax
je 0x3420d
movslq 0xc(%rsp), %rdi
testl %ebx, %ebx
je 0x34211
callq 0x2ea90
jmp 0x34220
xorl %eax, %eax
jmp 0x34220
callq 0x27535
xorl %edi, %edi
movq %rax, %rsi
callq 0x2e9b4
addq $0x10, %rsp
popq %rbx
retq
leaq 0x5a80b(%rip), %rdi     # 0x8ea38
leaq 0x5a828(%rip), %rsi     # 0x8ea5c
movl $0x101, %edx            # imm = 0x101
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x34395
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq -0x3(%rdx), %rdi
callq 0x2828d
testq %rax, %rax
je 0x34395
movq %rax, %rbx
leal -0x4(%r15), %ecx
movq %r12, %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x28674
testl %eax, %eax
je 0x34380
movl %eax, %r13d
leaq 0xf(%rsp), %rsi
movb $-0x3d, (%rsi)
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x33eca
cmpl $-0x1, %eax
je 0x3438a
movl %eax, %r12d
movl %r13d, %esi
movq %r14, %rdi
movq %rsi, 0x10(%rsp)
callq 0x33fef
cmpl $-0x1, %eax
je 0x3438a
movl %eax, %r13d
movq %r14, %rdi
movl %r15d, %esi
callq 0x33fef
cmpl $-0x1, %eax
je 0x3438a
movl %eax, %ebp
movq %r14, %rdi
movq %rbx, %rsi
movq 0x10(%rsp), %rdx
callq 0x33eca
cmpl $-0x1, %eax
je 0x3438a
addl %r12d, %r13d
addl %eax, %ebp
addl %r13d, %ebp
movq %rbx, %rdi
callq 0x283cd
jmp 0x34395
movq %rbx, %rdi
callq 0x283cd
pushq $-0x1
popq %rbp
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_O2/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
pushq %rax
movq %rdi, %r14
xorl %esi, %esi
callq 0x34096
cmpl $-0x1, %eax
je 0x34469
movl %eax, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0x34096
cmpl $-0x1, %eax
je 0x34469
movl %eax, %r15d
movl %ebp, %r13d
movq %r13, %rdi
callq 0x2828d
movq %rax, %rbx
testq %rax, %rax
je 0x34450
movl %r15d, %esi
xorl %r12d, %r12d
xorl %edi, %edi
callq 0x27158
movq %rax, (%rsp)
testq %rax, %rax
je 0x34459
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x33f11
testq %rax, %rax
je 0x34455
movq %rbx, %rdi
movl %ebp, %esi
movq (%rsp), %r12
movq %r12, %rdx
movl %r15d, %ecx
callq 0x28a9c
testl %eax, %eax
je 0x34459
movq %rbx, %rdi
callq 0x283cd
xorl %edi, %edi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2e9b4
xorl %r12d, %r12d
jmp 0x34459
movq (%rsp), %r12
movq %rbx, %rdi
callq 0x283cd
movq %r12, %rdi
callq 0x271f7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rdi, %r14
cmpq $0xb, %rdx
ja 0x344c2
leaq 0xb(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x34246
testl %eax, %eax
je 0x344c2
movl %eax, %ebp
movl %eax, %edx
leaq 0xb(%rsp), %rsi
movq %r14, %rdi
callq 0x33eca
cmpl $-0x1, %eax
cmovel %eax, %ebp
jmp 0x34528
pushq $-0x1
popq %rbp
cmpq $0x15, %rbx
jb 0x344f6
leaq 0x92ad6(%rip), %rax     # 0xc6fa8
cmpl $0x0, 0x590(%rax)
je 0x344f6
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x342cd
cmpl $-0x1, %eax
je 0x34528
testl %eax, %eax
jle 0x344f6
movl %eax, %ebp
jmp 0x34528
movq %r14, %rdi
movl %ebx, %esi
callq 0x33fef
cmpl $-0x1, %eax
je 0x34528
movl %eax, %r12d
testq %rbx, %rbx
je 0x34525
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x33eca
addl %ebx, %r12d
cmpl $-0x1, %eax
cmovel %eax, %r12d
movl %r12d, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rdi, %rbx
movq %rsp, %rsi
movq %r14, %rdi
callq 0x34149
testl %eax, %eax
je 0x34565
movl %eax, %edx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x33eca
movl %eax, %ebp
jmp 0x345a7
movq %rsp, %rdi
pushq $0x20
popq %rsi
movq %r14, %rdx
callq 0x2e511
cmpl $0x20, %eax
jge 0x345b2
movl %eax, %r14d
movq %rbx, %rdi
movl %eax, %esi
callq 0x33fef
cmpl $-0x1, %eax
je 0x345a4
movl %eax, %ebp
movslq %r14d, %rdx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x33eca
addl %eax, %ebp
cmpl $-0x1, %eax
cmovel %eax, %ebp
jmp 0x345a7
pushq $-0x1
popq %rbp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x5a4a9(%rip), %rdi     # 0x8ea62
leaq 0x5a49c(%rip), %rsi     # 0x8ea5c
movl $0x1e0, %edx            # imm = 0x1E0
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x345ef
cmpl $0x8, %eax
je 0x345ef
cmpl $0x1, %eax
jne 0x345fc
movq 0x8(%rsi), %rsi
jmp 0x34537
movq 0x8(%rsi), %rsi
movslq -0x8(%rsi), %rdx
jmp 0x3447a
pushq %rax
leaq 0x5a46a(%rip), %rdx     # 0x8ea6e
leaq 0x5a451(%rip), %rcx     # 0x8ea5c
xorl %edi, %edi
movl $0x1ff, %r8d            # imm = 0x1FF
callq 0x4980c
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
leaq 0x4(%rsp), %r15
movq %r15, %rsi
callq 0x34096
movl %eax, %ebp
cmpl $0x0, (%r15)
je 0x34656
cmpl $0x3, %ebp
jae 0x3468e
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x341a2
jmp 0x346a4
cmpl $-0x1, %ebp
je 0x346a2
movl %ebp, %r15d
xorl %edi, %edi
movq %r15, %rsi
callq 0x27158
movq %rax, %r14
testl %ebp, %ebp
je 0x34682
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x33f11
testq %rax, %rax
je 0x3469a
xorl %edi, %edi
movq %r14, %rsi
callq 0x2e9b4
jmp 0x346a4
jne 0x346af
movq %rbx, %rdi
callq 0x343a6
jmp 0x346a4
movq %r14, %rdi
callq 0x271f7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a3ce(%rip), %rdi     # 0x8ea84
leaq 0x5a39f(%rip), %rsi     # 0x8ea5c
movl $0x221, %edx            # imm = 0x221
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: rdbSaveObjectType
int rdbSaveObjectType(rio *rdb, robj *o) {

    switch (o->type) {

    case REDIS_STRING:
        return rdbSaveType(rdb,REDIS_RDB_TYPE_STRING);

    case REDIS_LIST:
        if (o->encoding == REDIS_ENCODING_ZIPLIST)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_LIST_ZIPLIST);
        else if (o->encoding == REDIS_ENCODING_LINKEDLIST)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_LIST);
        else
            redisPanic("Unknown list encoding");

    case REDIS_SET:
        if (o->encoding == REDIS_ENCODING_INTSET)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_SET_INTSET);
        else if (o->encoding == REDIS_ENCODING_HT)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_SET);
        else
            redisPanic("Unknown set encoding");

    case REDIS_ZSET:
        if (o->encoding == REDIS_ENCODING_ZIPLIST)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_ZSET_ZIPLIST);
        else if (o->encoding == REDIS_ENCODING_SKIPLIST)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_ZSET);
        else
            redisPanic("Unknown sorted set encoding");

    case REDIS_HASH:
        if (o->encoding == REDIS_ENCODING_ZIPLIST)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_HASH_ZIPLIST);
        else if (o->encoding == REDIS_ENCODING_HT)
            return rdbSaveType(rdb,REDIS_RDB_TYPE_HASH);
        else
            redisPanic("Unknown hash encoding");

    default:
        redisPanic("Unknown object type");
    }

    return -1; /* avoid warning */
}

// Assembly:
pushq %rax
movl (%rsi), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
ja 0x34890
leaq 0x5a18c(%rip), %rdx     # 0x8e9b0
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %ecx, %ecx
jmp 0x34887
shrl $0x4, %eax
andl $0xf, %eax
movb $0xd, %cl
cmpl $0x5, %eax
je 0x34887
cmpl $0x2, %eax
jne 0x348a5
movb $0x4, %cl
jmp 0x34887
shrl $0x4, %eax
andl $0xf, %eax
movb $0xb, %cl
cmpl $0x6, %eax
je 0x34887
cmpl $0x2, %eax
jne 0x348ba
movb $0x2, %cl
jmp 0x34887
shrl $0x4, %eax
andl $0xf, %eax
movb $0xc, %cl
cmpl $0x5, %eax
je 0x34887
cmpl $0x7, %eax
jne 0x348cf
movb $0x3, %cl
jmp 0x34887
shrl $0x4, %eax
andl $0xf, %eax
movb $0xa, %cl
cmpl $0x5, %eax
je 0x34887
cmpl $0x4, %eax
jne 0x348e4
movb $0x1, %cl
movzbl %cl, %esi
popq %rax
jmp 0x33eb4
leaq 0x58b70(%rip), %rdi     # 0x8d407
leaq 0x5a1be(%rip), %rsi     # 0x8ea5c
movl $0x2bb, %edx            # imm = 0x2BB
jmp 0x348f7
leaq 0x5a227(%rip), %rdi     # 0x8ead3
leaq 0x5a1a9(%rip), %rsi     # 0x8ea5c
movl $0x2b8, %edx            # imm = 0x2B8
jmp 0x348f7
leaq 0x5a1fb(%rip), %rdi     # 0x8eabc
leaq 0x5a194(%rip), %rsi     # 0x8ea5c
movl $0x2a8, %edx            # imm = 0x2A8
jmp 0x348f7
leaq 0x58ad1(%rip), %rdi     # 0x8d3a7
leaq 0x5a17f(%rip), %rsi     # 0x8ea5c
movl $0x2b0, %edx            # imm = 0x2B0
jmp 0x348f7
leaq 0x5a1b9(%rip), %rdi     # 0x8eaa4
leaq 0x5a16a(%rip), %rsi     # 0x8ea5c
movl $0x2a0, %edx            # imm = 0x2A0
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x9163a(%rip), %r14     # 0xc6fa8
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
cmpl $-0x1, %eax
je 0x359a7
movq 0x38(%rsp), %rax
jmp 0x359aa
pushq $0x1
popq %rax
movq %rax, 0x2f8(%r14)
addq $0x98, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x91594(%rip), %r15     # 0xc6fa8
cmpl $0x0, 0x594(%r15)
je 0x35a29
movq %rbx, %rdi
movq %r14, %rdx
callq 0x5423c
movq 0x310(%r15), %rdi
testq %rdi, %rdi
je 0x35a85
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 0x35a85
callq 0x22fd5
cmpq $0x0, 0x650(%r15)
je 0x35a72
cmpl $0x4, 0x674(%r15)
jne 0x35a72
callq 0x3264e
movq 0x28(%rbx), %rdi
callq 0x359bc
popq %rbx
popq %r14
popq %r15
jmp 0x2e0b2
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: backgroundSaveDoneHandler
void backgroundSaveDoneHandler(int exitcode, int bysignal) {

    // BGSAVE 成功
    if (!bysignal && exitcode == 0) {
        redisLog(REDIS_NOTICE,
            "Background saving terminated with success");
        server.dirty = server.dirty - server.dirty_before_bgsave;
        server.lastsave = time(NULL);
        server.lastbgsave_status = REDIS_OK;

    // BGSAVE 出错
    } else if (!bysignal && exitcode != 0) {
        redisLog(REDIS_WARNING, "Background saving error");
        server.lastbgsave_status = REDIS_ERR;

    // BGSAVE 被中断
    } else {
        redisLog(REDIS_WARNING,
            "Background saving terminated by signal %d", bysignal);
        // 移除临时文件
        rdbRemoveTempFile(server.rdb_child_pid);
        /* SIGUSR1 is whitelisted, so we have a way to kill a child without
         * tirggering an error conditon. */
        if (bysignal != SIGUSR1)
            server.lastbgsave_status = REDIS_ERR;
    }

    // 更新服务器状态
    server.rdb_child_pid = -1;
    server.rdb_save_time_last = time(NULL)-server.rdb_save_time_start;
    server.rdb_save_time_start = -1;

    /* Possibly there are slaves waiting for a BGSAVE in order to be served
     * (the first stage of SYNC is a bulk transfer of dump.rdb) */
    // 处理正在等待 BGSAVE 完成的那些 slave
    updateSlavesWaitingBgsave(exitcode == 0 ? REDIS_OK : REDIS_ERR);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl %esi, %eax
orl %edi, %eax
je 0x35dea
movl %esi, %ebp
testl %esi, %esi
setne %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
jne 0x35e23
leaq 0x5900f(%rip), %rsi     # 0x8eded
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x22613
jmp 0x35e4d
leaq 0x58fd2(%rip), %rsi     # 0x8edc3
xorl %r14d, %r14d
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x22613
leaq 0x911a3(%rip), %r15     # 0xc6fa8
movq 0x568(%r15), %rax
subq %rax, 0x560(%r15)
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0x598(%r15)
jmp 0x35e51
leaq 0x58fdb(%rip), %rsi     # 0x8ee05
pushq $0x3
popq %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x22613
leaq 0x9116b(%rip), %rax     # 0xc6fa8
movl 0x570(%rax), %edi
callq 0x351f9
cmpl $0xa, %ebp
je 0x35e5f
pushq $-0x1
popq %r14
leaq 0x91150(%rip), %rax     # 0xc6fa8
movl %r14d, 0x5b8(%rax)
leaq 0x91142(%rip), %r15     # 0xc6fa8
orl $-0x1, 0x570(%r15)
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1fc50
subq 0x5b0(%r15), %rax
movq %rax, 0x5a8(%r15)
orq $-0x1, 0x5b0(%r15)
negl %ebx
sbbl %r14d, %r14d
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x323ce
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: saveCommand
void saveCommand(redisClient *c) {

    // BGSAVE 已经在执行中，不能再执行 SAVE
    // 否则将产生竞争条件
    if (server.rdb_child_pid != -1) {
        addReplyError(c,"Background save already in progress");
        return;
    }

    // 执行 
    if (rdbSave(server.rdb_filename) == REDIS_OK) {
        addReply(c,shared.ok);
    } else {
        addReply(c,shared.err);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x910f8(%rip), %rax     # 0xc6fa8
cmpl $-0x1, 0x570(%rax)
je 0x35ec9
leaq 0x58f6f(%rip), %rsi     # 0x8ee2f
movq %rbx, %rdi
popq %rbx
jmp 0x2c2da
movq 0x588(%rax), %rdi
callq 0x34d06
testl %eax, %eax
je 0x35ee6
leaq 0x91920(%rip), %rax     # 0xc7800
movq 0x10(%rax), %rsi
jmp 0x35ef1
leaq 0x91913(%rip), %rax     # 0xc7800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2c10d
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/rdb.c
// Function: bgsaveCommand
void bgsaveCommand(redisClient *c) {

    // 不能重复执行 BGSAVE
    if (server.rdb_child_pid != -1) {
        addReplyError(c,"Background save already in progress");

    // 不能在 BGREWRITEAOF 正在运行时执行
    } else if (server.aof_child_pid != -1) {
        addReplyError(c,"Can't BGSAVE while AOF log rewriting is in progress");

    // 执行 BGSAVE
    } else if (rdbSaveBackground(server.rdb_filename) == REDIS_OK) {
        addReplyStatus(c,"Background saving started");

    } else {
        addReply(c,shared.err);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x910a3(%rip), %rax     # 0xc6fa8
cmpl $-0x1, 0x570(%rax)
je 0x35f17
leaq 0x58f1a(%rip), %rsi     # 0x8ee2f
jmp 0x35f27
cmpl $-0x1, 0x504(%rax)
je 0x35f30
leaq 0x58f2c(%rip), %rsi     # 0x8ee53
movq %rbx, %rdi
popq %rbx
jmp 0x2c2da
movq 0x588(%rax), %rdi
callq 0x350c8
testl %eax, %eax
je 0x35f54
leaq 0x918b9(%rip), %rax     # 0xc7800
movq 0x10(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2c10d
leaq 0x58f2c(%rip), %rsi     # 0x8ee87
movq %rbx, %rdi
popq %rbx
jmp 0x2c423
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: getGenericCommand
int getGenericCommand(redisClient *c) {
    robj *o;

    // 尝试从数据库中取出键 c->argv[1] 对应的值对象
    // 如果键不存在时，向客户端发送回复信息，并返回 NULL
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL)
        return REDIS_OK;

    // 值对象存在，检查它的类型
    if (o->type != REDIS_STRING) {
        // 类型错误
        addReply(c,shared.wrongtypeerr);
        return REDIS_ERR;
    } else {
        // 类型正确，向客户端返回对象的值
        addReplyBulk(c,o);
        return REDIS_OK;
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x914b7(%rip), %r14     # 0xc7800
movq 0x50(%r14), %rdx
callq 0x2f9a9
xorl %ebp, %ebp
testq %rax, %rax
je 0x3637a
testb $0xf, (%rax)
je 0x3636f
movq 0x70(%r14), %rsi
movq %rbx, %rdi
callq 0x2c10d
pushq $-0x1
popq %rbp
jmp 0x3637a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2c84a
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: getsetCommand
void getsetCommand(redisClient *c) {

    // 取出并返回键的值对象
    if (getGenericCommand(c) == REDIS_ERR) return;

    // 编码键的新值 c->argv[2]
    c->argv[2] = tryObjectEncoding(c->argv[2]);

    // 将数据库中关联键 c->argv[1] 和新值对象 c->argv[2]
    setKey(c->db,c->argv[1],c->argv[2]);

    // 发送事件通知
    notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"set",c->argv[1],c->db->id);

    // 将服务器设为脏
    server.dirty++;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x36333
cmpl $-0x1, %eax
je 0x363ea
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x2ef4c
movq 0x38(%rbx), %rcx
movq %rax, 0x10(%rcx)
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0x2fb11
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x5511a(%rip), %rsi     # 0x8b4ee
pushq $0x8
popq %rdi
callq 0x5b488
leaq 0x90bc5(%rip), %rax     # 0xc6fa8
incq 0x560(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: getrangeCommand
void getrangeCommand(redisClient *c) {
    robj *o;
    long start, end;
    char *str, llbuf[32];
    size_t strlen;

    // 取出 start 参数
    if (getLongFromObjectOrReply(c,c->argv[2],&start,NULL) != REDIS_OK)
        return;

    // 取出 end 参数
    if (getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != REDIS_OK)
        return;

    // 从数据库中查找键 c->argv[1] 
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptybulk)) == NULL ||
        checkType(c,o,REDIS_STRING)) return;

    // 根据编码，对对象的值进行处理
    if (o->encoding == REDIS_ENCODING_INT) {
        str = llbuf;
        strlen = ll2string(llbuf,sizeof(llbuf),(long)o->ptr);
    } else {
        str = o->ptr;
        strlen = sdslen(str);
    }

    /* Convert negative indexes */
    // 将负数索引转换为整数索引
    if (start < 0) start = strlen+start;
    if (end < 0) end = strlen+end;
    if (start < 0) start = 0;
    if (end < 0) end = 0;
    if ((unsigned)end >= strlen) end = strlen-1;

    /* Precondition: end >= 0 && end < strlen, so the only condition where
     * nothing can be returned is: start > end. */
    if (start > end) {
        // 处理索引范围为空的情况
        addReply(c,shared.emptybulk);
    } else {
        // 向客户端返回给定范围内的字符串内容
        addReplyBulkCBuffer(c,(char*)str+start,end-start+1);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rsi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x2f672
testl %eax, %eax
jne 0x365ed
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x2f672
testl %eax, %eax
je 0x365f7
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x911fa(%rip), %r15     # 0xc7800
movq 0x18(%r15), %rdx
movq %rbx, %rdi
callq 0x2f9a9
testq %rax, %rax
je 0x365ed
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2eec6
testl %eax, %eax
jne 0x365ed
movl $0xf0, %eax
andl (%r14), %eax
movq 0x8(%r14), %rdx
cmpl $0x10, %eax
jne 0x36651
leaq 0x10(%rsp), %r14
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x2e511
movq %r14, %rdx
jmp 0x36654
movl -0x8(%rdx), %eax
movslq %eax, %rsi
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jns 0x36669
addq %rsi, %rcx
movq %rcx, 0x8(%rsp)
movq (%rsp), %rax
testq %rax, %rax
jns 0x36679
addq %rsi, %rax
movq %rax, (%rsp)
testq %rcx, %rcx
jns 0x36686
andq $0x0, 0x8(%rsp)
xorl %ecx, %ecx
xorl %edi, %edi
testq %rax, %rax
cmovgq %rax, %rdi
setns %r8b
movl %edi, %r9d
leaq -0x1(%rsi), %rax
cmpq %rsi, %r9
setb %sil
cmovbq %rdi, %rax
testb %sil, %r8b
jne 0x366ae
movq %rax, (%rsp)
subq %rcx, %rax
jge 0x366c4
movq 0x18(%r15), %rsi
movq %rbx, %rdi
callq 0x2c10d
jmp 0x365ed
addq %rcx, %rdx
incq %rax
movq %rbx, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x2c87d
jmp 0x365ed
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: mgetCommand
void mgetCommand(redisClient *c) {
    int j;

    addReplyMultiBulkLen(c,c->argc-1);
    // 查找并返回所有输入键的值
    for (j = 1; j < c->argc; j++) {
        // 查找键 c->argc[j] 的值
        robj *o = lookupKeyRead(c->db,c->argv[j]);
        if (o == NULL) {
            // 值不存在，向客户端发送空回复
            addReply(c,shared.nullbulk);
        } else {
            if (o->type != REDIS_STRING) {
                // 值存在，但不是字符串类型
                addReply(c,shared.nullbulk);
            } else {
                // 值存在，并且是字符串
                addReplyBulk(c,o);
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movslq 0x30(%rdi), %rsi
decq %rsi
callq 0x2c7c7
pushq $0x1
popq %r14
leaq 0x91104(%rip), %r15     # 0xc7800
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jge 0x3673e
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
callq 0x2f89e
testq %rax, %rax
je 0x36720
testb $0xf, (%rax)
je 0x3672e
movq 0x50(%r15), %rsi
movq %rbx, %rdi
callq 0x2c10d
jmp 0x36739
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2c84a
incq %r14
jmp 0x366fc
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: msetGenericCommand
void msetGenericCommand(redisClient *c, int nx) {
    int j, busykeys = 0;

    // 键值参数不是成相成对出现的，格式不正确
    if ((c->argc % 2) == 0) {
        addReplyError(c,"wrong number of arguments for MSET");
        return;
    }
    /* Handle the NX flag. The MSETNX semantic is to return zero and don't
     * set nothing at all if at least one already key exists. */
    // 如果 nx 参数为真，那么检查所有输入键在数据库中是否存在
    // 只要有一个键是存在的，那么就向客户端发送空回复
    // 并放弃执行接下来的设置操作
    if (nx) {
        for (j = 1; j < c->argc; j += 2) {
            if (lookupKeyWrite(c->db,c->argv[j]) != NULL) {
                busykeys++;
            }
        }
        // 键存在
        // 发送空白回复，并放弃执行接下来的设置操作
        if (busykeys) {
            addReply(c, shared.czero);
            return;
        }
    }

    // 设置所有键值对
    for (j = 1; j < c->argc; j += 2) {

        // 对值对象进行解码
        c->argv[j+1] = tryObjectEncoding(c->argv[j+1]);

        // 将键值对关联到数据库
        // c->argc[j] 为键
        // c->argc[j+1] 为值
        setKey(c->db,c->argv[j],c->argv[j+1]);

        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"set",c->argv[j],c->db->id);
    }

    // 将服务器设为脏
    server.dirty += (c->argc-1)/2;

    // 设置成功
    // MSET 返回 OK ，而 MSETNX 返回 1
    addReply(c, nx ? shared.cone : shared.ok);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x30(%rdi), %eax
testb $0x1, %al
jne 0x3676d
leaq 0x58778(%rip), %rsi     # 0x8eed5
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2c2da
movl %esi, %ebp
testl %esi, %esi
je 0x367b9
pushq $0x1
popq %r15
xorl %r14d, %r14d
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x367a4
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x2f988
cmpq $0x1, %rax
sbbl $-0x1, %r14d
addq $0x2, %r15
movl 0x30(%rbx), %eax
jmp 0x3677a
testl %r14d, %r14d
je 0x367b9
leaq 0x91050(%rip), %rax     # 0xc7800
movq 0x20(%rax), %rsi
jmp 0x3684e
pushq $0x1
popq %r12
leaq 0x54d2a(%rip), %r14     # 0x8b4ee
pushq $0x8
popq %r15
movslq %eax, %rcx
cmpq %rcx, %r12
jge 0x36820
movq 0x38(%rbx), %rax
movq 0x8(%rax,%r12,8), %rdi
callq 0x2ef4c
movq 0x38(%rbx), %rcx
movq %rax, 0x8(%rcx,%r12,8)
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r12,8), %rsi
movq 0x8(%rax,%r12,8), %rdx
callq 0x2fb11
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r12,8), %rdx
movl 0x30(%rax), %ecx
movl %r15d, %edi
movq %r14, %rsi
callq 0x5b488
addq $0x2, %r12
movl 0x30(%rbx), %eax
jmp 0x367c8
xorl %ecx, %ecx
testl %ebp, %ebp
setne %cl
decl %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
cltq
leaq 0x90770(%rip), %rdx     # 0xc6fa8
addq %rax, 0x560(%rdx)
leaq 0x90fba(%rip), %rax     # 0xc7800
shll $0x5, %ecx
movq 0x8(%rax,%rcx), %rsi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2c10d