LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/config.c
// Function: rewriteConfigSyslogfacilityOption
void rewriteConfigSyslogfacilityOption(struct rewriteConfigState *state) {
    int value = server.syslog_facility, j;
    int force = value != LOG_LOCAL0;
    char *name = NULL, *option = "syslog-facility";
    sds line;

    for (j = 0; validSyslogFacilities[j].name; j++) {
        if (validSyslogFacilities[j].value == value) {
            name = (char*) validSyslogFacilities[j].name;
            break;
        }
    }
    line = sdscatprintf(sdsempty(),"%s %s",option,name);
    rewriteConfigRewriteLine(state,option,line,force);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x8208b(%rip), %rax     # 0xc9fa8
movl 0x5e8(%rax), %eax
cmpl $0x8, %eax
jne 0x47f31
leaq 0x52655(%rip), %r14     # 0x9a584
jmp 0x47f57
movl $0x18, %edx
leaq 0x7b3b3(%rip), %rcx     # 0xc32f0
movq %rdx, %rsi
addq $0x10, %rdx
cmpq $0xa8, %rdx
je 0x47f52
cmpl %eax, (%rsi,%rcx)
jne 0x47f3d
movq -0x8(%rsi,%rcx), %r14
xorl %ebp, %ebp
cmpl $0x80, %eax
setne %bpl
callq 0x2845e
leaq 0x57cfa(%rip), %rsi     # 0x9fc68
leaq 0x51979(%rip), %r15     # 0x998ee
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x28a5e
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl %ebp, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x47a6a
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/config.c
// Function: rewriteConfigClientoutputbufferlimitOption
void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state) {
    int j;
    char *option = "client-output-buffer-limit";

    for (j = 0; j < REDIS_CLIENT_LIMIT_NUM_CLASSES; j++) {
        int force = (server.client_obuf_limits[j].hard_limit_bytes !=
                    clientBufferLimitsDefaults[j].hard_limit_bytes) ||
                    (server.client_obuf_limits[j].soft_limit_bytes !=
                    clientBufferLimitsDefaults[j].soft_limit_bytes) ||
                    (server.client_obuf_limits[j].soft_limit_seconds !=
                    clientBufferLimitsDefaults[j].soft_limit_seconds);
        sds line;
        char hard[64], soft[64];

        rewriteConfigFormatMemory(hard,sizeof(hard),
                server.client_obuf_limits[j].hard_limit_bytes);
        rewriteConfigFormatMemory(soft,sizeof(soft),
                server.client_obuf_limits[j].soft_limit_bytes);

        line = sdscatprintf(sdsempty(),"%s %s %s %s %ld",
                option, getClientLimitClassName(j), hard, soft,
                (long) server.client_obuf_limits[j].soft_limit_seconds);
        rewriteConfigRewriteLine(state,option,line,force);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, 0x8(%rsp)
leaq 0x81e0e(%rip), %rbx     # 0xc9fa8
leaq 0x8191f(%rip), %rcx     # 0xc9ac0
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x488(%rbx,%r15), %rdx
movl $0x1, %r12d
cmpq (%r15,%rcx), %rdx
jne 0x481dd
movq 0x490(%rbx,%r15), %rax
cmpq 0x8(%r15,%rcx), %rax
jne 0x481dd
movq 0x498(%rbx,%r15), %rax
xorl %r12d, %r12d
cmpq 0x10(%r15,%rcx), %rax
setne %r12b
movl $0x40, %esi
leaq 0x10(%rsp), %rdi
callq 0x47b8c
movq 0x490(%rbx,%r15), %rdx
movl $0x40, %esi
leaq 0x50(%rsp), %r13
movq %r13, %rdi
callq 0x47b8c
callq 0x2845e
movq %rax, %r14
movl %ebp, %edi
callq 0x2fae5
movq 0x498(%rbx,%r15), %rcx
movq %rcx, (%rsp)
movq %r14, %rdi
leaq 0x5223a(%rip), %rsi     # 0x9a465
leaq 0x51d0f(%rip), %r14     # 0x99f41
movq %r14, %rdx
movq %rax, %rcx
leaq 0x10(%rsp), %r8
movq %r13, %r9
xorl %eax, %eax
callq 0x28a5e
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %r12d, %ecx
callq 0x47a6a
leaq 0x8185f(%rip), %rcx     # 0xc9ac0
incq %rbp
addq $0x18, %r15
cmpq $0x3, %rbp
jne 0x481a6
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/config.c
// Function: configCommand
void configCommand(redisClient *c) {
    if (!strcasecmp(c->argv[1]->ptr,"set")) {
        if (c->argc != 4) goto badarity;
        configSetCommand(c);
    } else if (!strcasecmp(c->argv[1]->ptr,"get")) {
        if (c->argc != 3) goto badarity;
        configGetCommand(c);
    } else if (!strcasecmp(c->argv[1]->ptr,"resetstat")) {
        if (c->argc != 2) goto badarity;
        resetServerStats();
        resetCommandTableStats();
        addReply(c,shared.ok);
    } else if (!strcasecmp(c->argv[1]->ptr,"rewrite")) {
        if (c->argc != 2) goto badarity;
        if (server.configfile == NULL) {
            addReplyError(c,"The server is running without a config file");
            return;
        }
        if (rewriteConfig(server.configfile) == -1) {
            redisLog(REDIS_WARNING,"CONFIG REWRITE failed: %s", strerror(errno));
            addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno));
        } else {
            redisLog(REDIS_WARNING,"CONFIG REWRITE executed with success.");
            addReply(c,shared.ok);
        }
    } else {
        addReplyError(c,
            "CONFIG subcommand must be one of GET, SET, RESETSTAT, REWRITE");
    }
    return;

badarity:
    addReplyErrorFormat(c,"Wrong number of arguments for CONFIG %s",
        (char*) c->argv[1]->ptr);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %r14
leaq 0x4c82e(%rip), %rsi     # 0x9552e
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x48d5b
leaq 0x4b7a4(%rip), %rsi     # 0x944b7
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x48d74
leaq 0x51768(%rip), %rsi     # 0x9a48e
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x48d89
leaq 0x50f65(%rip), %rsi     # 0x99c9e
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x48db3
leaq 0x517d2(%rip), %rsi     # 0x9a51e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2dc63
cmpl $0x4, 0x30(%rbx)
jne 0x48de7
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x44f73
cmpl $0x3, 0x30(%rbx)
jne 0x48de7
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x462d0
cmpl $0x2, 0x30(%rbx)
jne 0x48de7
callq 0x2543e
callq 0x25b23
leaq 0x81a60(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2d97c
cmpl $0x2, 0x30(%rbx)
jne 0x48de7
leaq 0x811e8(%rip), %rax     # 0xc9fa8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x48e02
callq 0x4856f
cmpl $-0x1, %eax
je 0x48e0e
leaq 0x5171f(%rip), %rsi     # 0x9a4f8
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
jmp 0x48d99
leaq 0x5176e(%rip), %rsi     # 0x9a55c
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2dc8a
leaq 0x5168f(%rip), %rsi     # 0x9a498
jmp 0x48d4c
callq 0x1f810
movq %rax, %r14
movl (%rax), %edi
callq 0x1f630
leaq 0x516a0(%rip), %rsi     # 0x9a4c4
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23223
movl (%r14), %edi
callq 0x1f630
leaq 0x5169c(%rip), %rsi     # 0x9a4de
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x48df4
nop
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: aofRewriteBufferSize
unsigned long aofRewriteBufferSize(void) {

    // 取出链表中最后的缓存块
    listNode *ln = listLast(server.aof_rewrite_buf_blocks);
    aofrwblock *block = ln ? ln->value : NULL;

    // 没有缓存被使用
    if (block == NULL) return 0;

    // 总缓存大小 = （缓存块数量-1） * AOF_RW_BUF_BLOCK_SIZE + 最后一个缓存块的大小
    unsigned long size =
        (listLength(server.aof_rewrite_buf_blocks)-1) * AOF_RW_BUF_BLOCK_SIZE;
    size += block->used;

    return size;
}

// Assembly:
leaq 0x81123(%rip), %rax     # 0xc9fa8
movq 0x508(%rax), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x48eb7
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
je 0x48eb7
movq 0x28(%rax), %rax
leaq (%rax,%rax,4), %rax
shlq $0x15, %rax
movq (%rcx), %rcx
addq %rcx, %rax
addq $-0xa00000, %rax        # imm = 0xFF600000
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: aofRewriteBufferWrite
ssize_t aofRewriteBufferWrite(int fd) {
    listNode *ln;
    listIter li;
    ssize_t count = 0;

    // 遍历所有缓存块
    listRewind(server.aof_rewrite_buf_blocks,&li);
    while((ln = listNext(&li))) {
        aofrwblock *block = listNodeValue(ln);
        ssize_t nwritten;

        if (block->used) {

            // 写入缓存块内容到 fd
            nwritten = write(fd,block->buf,block->used);
            if (nwritten != block->used) {
                if (nwritten == 0) errno = EIO;
                return -1;
            }

            // 积累写入字节
            count += nwritten;
        }
    }

    return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebp
leaq 0x80f9a(%rip), %rax     # 0xc9fa8
movq 0x508(%rax), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x20637
movq %rbx, %rdi
callq 0x20654
xorl %ebx, %ebx
testq %rax, %rax
je 0x4907b
leaq 0x8(%rsp), %r14
movq 0x10(%rax), %r15
movq (%r15), %rdx
testq %rdx, %rdx
je 0x49055
leaq 0x10(%r15), %rsi
movl %ebp, %edi
callq 0x1fb30
cmpq (%r15), %rax
jne 0x49064
addq %rax, %rbx
movq %r14, %rdi
callq 0x20654
testq %rax, %rax
jne 0x49036
jmp 0x4907b
movq $-0x1, %rbx
testq %rax, %rax
jne 0x4907b
callq 0x1f810
movl $0x5, (%rax)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: stopAppendOnly
void stopAppendOnly(void) {

    // AOF 必须正在启用，才能调用这个函数
    redisAssert(server.aof_state != REDIS_AOF_OFF);

    // 将 AOF 缓存的内容写入并冲洗到 AOF 文件中
    // 参数 1 表示强制模式
    flushAppendOnlyFile(1);

    // 冲洗 AOF 文件
    aof_fsync(server.aof_fd);

    // 关闭 AOF 文件
    close(server.aof_fd);

    // 清空 AOF 状态
    server.aof_fd = -1;
    server.aof_selected_db = -1;
    server.aof_state = REDIS_AOF_OFF;

    /* rewrite operation in progress? kill it, wait child exit 
    *
    * 如果 BGREWRITEAOF 正在执行，那么杀死它
    * 并等待子进程退出
    */
    if (server.aof_child_pid != -1) {
        int statloc;

        redisLog(REDIS_NOTICE,"Killing running AOF rewrite child: %ld",
            (long) server.aof_child_pid);

        // 杀死子进程
        if (kill(server.aof_child_pid,SIGUSR1) != -1)
            wait3(&statloc,0,NULL);

        /* reset the buffer accumulating changes while the child saves 
         * 清理未完成的 AOF 重写留下来的缓存和临时文件
         */
        aofRewriteBufferReset();
        aofRemoveTempFile(server.aof_child_pid);
        server.aof_child_pid = -1;
        server.aof_rewrite_time_start = -1;
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0x80efd(%rip), %r14     # 0xc9fa8
cmpl $0x0, 0x4d0(%r14)
je 0x49185
movl $0x1, %edi
callq 0x491a7
movl 0x518(%r14), %edi
callq 0x1f560
movl 0x518(%r14), %edi
callq 0x1f170
movq $-0x1, 0x518(%r14)
movl $0x0, 0x4d0(%r14)
movslq 0x504(%r14), %rdx
cmpq $-0x1, %rdx
je 0x4917a
leaq 0x51552(%rip), %rsi     # 0x9a657
movl $0x2, %edi
xorl %eax, %eax
callq 0x23223
movl 0x504(%r14), %edi
movl $0xa, %esi
callq 0x1f620
cmpl $-0x1, %eax
je 0x49135
leaq 0xc(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1f800
callq 0x48e4c
movl 0x504(%r14), %ecx
leaq 0x51b74(%rip), %rdx     # 0x9acbc
leaq 0x10(%rsp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1f120
movq %rbx, %rdi
callq 0x1f3a0
movl $0xffffffff, 0x504(%r14) # imm = 0xFFFFFFFF
movq $-0x1, 0x538(%r14)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
leaq 0x514a3(%rip), %rdi     # 0x9a62f
leaq 0x514be(%rip), %rsi     # 0x9a651
movl $0xed, %edx
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: startAppendOnly
int startAppendOnly(void) {

    // 将开始时间设为 AOF 最后一次 fsync 时间 
    server.aof_last_fsync = server.unixtime;

    // 打开 AOF 文件
    server.aof_fd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644);

    redisAssert(server.aof_state == REDIS_AOF_OFF);

    // 文件打开失败
    if (server.aof_fd == -1) {
        redisLog(REDIS_WARNING,"Redis needs to enable the AOF but can't open the append only file: %s",strerror(errno));
        return REDIS_ERR;
    }

    if (rewriteAppendOnlyFileBackground() == REDIS_ERR) {
        // AOF 后台重写失败，关闭 AOF 文件
        close(server.aof_fd);
        redisLog(REDIS_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error.");
        return REDIS_ERR;
    }

    /* We correctly switched on AOF, now wait for the rerwite to be complete
     * in order to append data on disk. 
     *
     * 等待重写执行完毕
     */
    server.aof_state = REDIS_AOF_WAIT_REWRITE;

    return REDIS_OK;
}

// Assembly:
pushq %rbx
leaq 0x80aa2(%rip), %rbx     # 0xc9fa8
movq 0x798(%rbx), %rax
movq %rax, 0x528(%rbx)
movq 0x4d8(%rbx), %rdi
movl $0x441, %esi            # imm = 0x441
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x1f640
movl %eax, 0x518(%rbx)
cmpl $0x0, 0x4d0(%rbx)
jne 0x495a1
cmpl $-0x1, %eax
je 0x49558
callq 0x495c3
cmpl $-0x1, %eax
je 0x4957c
movl $0x2, 0x4d0(%rbx)
xorl %eax, %eax
jmp 0x4959f
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x51135(%rip), %rsi     # 0x9a6a0
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23223
jmp 0x4959a
movl 0x518(%rbx), %edi
callq 0x1f170
leaq 0x51158(%rip), %rsi     # 0x9a6e6
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
retq
leaq 0x510d6(%rip), %rdi     # 0x9a67e
leaq 0x510a2(%rip), %rsi     # 0x9a651
movl $0x125, %edx            # imm = 0x125
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: catAppendOnlyGenericCommand
sds catAppendOnlyGenericCommand(sds dst, int argc, robj **argv) {
    char buf[32];
    int len, j;
    robj *o;

    // 重建命令的个数，格式为 *<count>\r\n
    // 例如 *3\r\n
    buf[0] = '*';
    len = 1+ll2string(buf+1,sizeof(buf)-1,argc);
    buf[len++] = '\r';
    buf[len++] = '\n';
    dst = sdscatlen(dst,buf,len);

    // 重建命令和命令参数，格式为 $<length>\r\n<content>\r\n
    // 例如 $3\r\nSET\r\n$3\r\nKEY\r\n$5\r\nVALUE\r\n
    for (j = 0; j < argc; j++) {
        o = getDecodedObject(argv[j]);

        // 组合 $<length>\r\n
        buf[0] = '$';
        len = 1+ll2string(buf+1,sizeof(buf)-1,sdslen(o->ptr));
        buf[len++] = '\r';
        buf[len++] = '\n';
        dst = sdscatlen(dst,buf,len);

        // 组合 <content>\r\n
        dst = sdscatlen(dst,o->ptr,sdslen(o->ptr));
        dst = sdscatlen(dst,"\r\n",2);

        decrRefCount(o);
    }

    // 返回重建后的协议内容
    return dst;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r13
leaq 0x1(%rsp), %rdi
movb $0x2a, -0x1(%rdi)
movslq %esi, %r12
movl $0x1f, %esi
movq %r12, %rdx
callq 0x300c7
cltq
movq %rsp, %r15
movw $0xa0d, 0x1(%rax,%r15)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x28689
movq %rax, %r13
testl %r12d, %r12d
jle 0x497e9
movl %ebp, %r14d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x30d93
movq %rax, %rbp
movb $0x24, (%rsp)
movq 0x8(%rax), %rax
movslq -0x8(%rax), %rdx
movl $0x1f, %esi
leaq 0x1(%rsp), %rdi
callq 0x300c7
cltq
movw $0xa0d, 0x1(%rax,%r15)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x28689
movq 0x8(%rbp), %rsi
movslq -0x8(%rsi), %rdx
movq %rax, %rdi
callq 0x28689
movl $0x2, %edx
movq %rax, %rdi
leaq 0x4ff3e(%rip), %rsi     # 0x9970f
callq 0x28689
movq %rax, %r13
movq %rbp, %rdi
callq 0x30b0c
incq %r12
cmpq %r12, %r14
jne 0x49770
movq %r13, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: catAppendOnlyExpireAtCommand
sds catAppendOnlyExpireAtCommand(sds buf, struct redisCommand *cmd, robj *key, robj *seconds) {
    long long when;
    robj *argv[3];

    /* Make sure we can use strtol 
     *
     * 取出过期值
     */
    seconds = getDecodedObject(seconds);
    when = strtoll(seconds->ptr,NULL,10);

    /* Convert argument into milliseconds for EXPIRE, SETEX, EXPIREAT 
     *
     * 如果过期值的格式为秒，那么将它转换为毫秒
     */
    if (cmd->proc == expireCommand || cmd->proc == setexCommand ||
        cmd->proc == expireatCommand)
    {
        when *= 1000;
    }

    /* Convert into absolute time for EXPIRE, PEXPIRE, SETEX, PSETEX 
     *
     * 如果过期值的格式为相对值，那么将它转换为绝对值
     */
    if (cmd->proc == expireCommand || cmd->proc == pexpireCommand ||
        cmd->proc == setexCommand || cmd->proc == psetexCommand)
    {
        when += mstime();
    }

    decrRefCount(seconds);

    // 构建 PEXPIREAT 命令
    argv[0] = createStringObject("PEXPIREAT",9);
    argv[1] = key;
    argv[2] = createStringObjectFromLongLong(when);

    // 追加到 AOF 缓存中
    buf = catAppendOnlyGenericCommand(buf, 3, argv);

    decrRefCount(argv[0]);
    decrRefCount(argv[2]);

    return buf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
movq %rcx, %rdi
callq 0x30d93
movq %rax, %r12
movq 0x8(%rax), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1fa70
movq %rax, %r15
movq 0x8(%r13), %rax
imulq $0x3e8, %r15, %rcx      # imm = 0x3E8
cmpq 0x7c797(%rip), %rax     # 0xc5fd8
leaq -0x10c6e(%rip), %rdx    # 0x38bda
cmoveq %rcx, %r15
cmpq %rdx, %rax
cmoveq %rcx, %r15
cmpq 0x7c6ae(%rip), %rax     # 0xc5f08
cmoveq %rcx, %r15
cmpq %rdx, %rax
je 0x4987e
cmpq 0x7c69e(%rip), %rax     # 0xc5f08
je 0x4987e
cmpq 0x7c73d(%rip), %rax     # 0xc5fb0
je 0x4987e
cmpq 0x7c704(%rip), %rax     # 0xc5f80
jne 0x49886
callq 0x23461
addq %rax, %r15
movq %r12, %rdi
callq 0x30b0c
leaq 0x510e4(%rip), %rdi     # 0x9a979
movl $0x9, %esi
callq 0x3068f
movq %rax, %r12
movq %rsp, %r13
movq %rax, (%r13)
movq %r14, 0x8(%r13)
movq %r15, %rdi
callq 0x3069e
movq %rax, %r14
movq %rax, 0x10(%r13)
movq %rbx, %rdi
movl $0x3, %esi
movq %r13, %rdx
callq 0x49715
movq %rax, %rbx
movq %r12, %rdi
callq 0x30b0c
movq %r14, %rdi
callq 0x30b0c
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: createFakeClient
struct redisClient *createFakeClient(void) {
    struct redisClient *c = zmalloc(sizeof(*c));

    selectDb(c,0);

    c->fd = -1;
    c->name = NULL;
    c->querybuf = sdsempty();
    c->querybuf_peak = 0;
    c->argc = 0;
    c->argv = NULL;
    c->bufpos = 0;
    c->flags = 0;
    c->btype = REDIS_BLOCKED_NONE;
    /* We set the fake client as a slave waiting for the synchronization
     * so that Redis will not try to send replies to this client. 
     *
     * 将客户端设置为正在等待同步的附属节点，这样客户端就不会发送回复了。
     */
    c->replstate = REDIS_REPL_WAIT_BGSAVE_START;
    c->reply = listCreate();
    c->reply_bytes = 0;
    c->obuf_soft_limit_reached_time = 0;
    c->watched_keys = listCreate();
    c->peerid = NULL;
    listSetFreeMethod(c->reply,decrRefCountVoid);
    listSetDupMethod(c->reply,dupClientReplyValue);
    initClientMultiState(c);

    return c;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x4178, %edi           # imm = 0x4178
callq 0x299b5
movq %rax, %rbx
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
callq 0x31c18
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq %r14, 0x18(%rbx)
callq 0x2845e
movq %rax, 0x20(%rbx)
movq %r14, 0x28(%rbx)
movl %r14d, 0x30(%rbx)
movq %r14, 0x38(%rbx)
movl %r14d, 0x170(%rbx)
movl %r14d, 0x90(%rbx)
movl %r14d, 0x118(%rbx)
movl $0x6, 0x98(%rbx)
callq 0x203fc
movq %rax, 0x60(%rbx)
movq %r14, 0x68(%rbx)
movq %r14, 0x88(%rbx)
callq 0x203fc
movq %rax, 0x150(%rbx)
movq %r14, 0x168(%rbx)
movq 0x60(%rbx), %rax
leaq -0x1928c(%rip), %rcx    # 0x30864
movq %rcx, 0x18(%rax)
leaq -0x1cb27(%rip), %rcx    # 0x2cfd4
movq %rcx, 0x10(%rax)
movq %rbx, %rdi
callq 0x4bbd8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: aofUpdateCurrentSize
void aofUpdateCurrentSize(void) {
    struct redis_stat sb;

    // 读取文件状态
    if (redis_fstat(server.aof_fd,&sb) == -1) {
        redisLog(REDIS_WARNING,"Unable to obtain the AOF file length. stat: %s",
            strerror(errno));
    } else {
        // 设置到服务器
        server.aof_current_size = sb.st_size;
    }
}

// Assembly:
pushq %rbx
subq $0x90, %rsp
leaq 0x800c0(%rip), %rbx     # 0xc9fa8
movl 0x518(%rbx), %edi
movq %rsp, %rsi
callq 0x1f690
cmpl $-0x1, %eax
je 0x49f10
movq 0x30(%rsp), %rax
movq %rax, 0x4f8(%rbx)
addq $0x90, %rsp
popq %rbx
retq
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x50eee(%rip), %rsi     # 0x9ae11
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
jmp 0x23223
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: rioWriteBulkObject
int rioWriteBulkObject(rio *r, robj *obj) {
    /* Avoid using getDecodedObject to help copy-on-write (we are often
     * in a child process when this function is called). */
    if (obj->encoding == REDIS_ENCODING_INT) {
        return rioWriteBulkLongLong(r,(long)obj->ptr);
    } else if (sdsEncodedObject(obj)) {
        return rioWriteBulkString(r,obj->ptr,sdslen(obj->ptr));
    } else {
        redisPanic("Unknown string encoding");
    }
}

// Assembly:
pushq %rax
movl (%rsi), %eax
shrl $0x4, %eax
andl $0xf, %eax
je 0x49f5a
cmpl $0x8, %eax
je 0x49f5a
cmpl $0x1, %eax
jne 0x49f69
movq 0x8(%rsi), %rsi
callq 0x58ab3
jmp 0x49f67
movq 0x8(%rsi), %rsi
movslq -0x8(%rsi), %rdx
callq 0x589bc
popq %rcx
retq
leaq 0x4d504(%rip), %rdi     # 0x97474
leaq 0x506da(%rip), %rsi     # 0x9a651
movl $0x3fe, %edx            # imm = 0x3FE
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: rewriteHashObject
int rewriteHashObject(rio *r, robj *key, robj *o) {
    hashTypeIterator *hi;
    long long count = 0, items = hashTypeLength(o);

    hi = hashTypeInitIterator(o);
    while (hashTypeNext(hi) != REDIS_ERR) {
        if (count == 0) {
            int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ?
                REDIS_AOF_REWRITE_ITEMS_PER_CMD : items;

            if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
            if (rioWriteBulkString(r,"HMSET",5) == 0) return 0;
            if (rioWriteBulkObject(r,key) == 0) return 0;
        }

        if (rioWriteHashIteratorCursor(r, hi, REDIS_HASH_KEY) == 0) return 0;
        if (rioWriteHashIteratorCursor(r, hi, REDIS_HASH_VALUE) == 0) return 0;
        if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
        items--;
    }

    hashTypeReleaseIterator(hi);

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x4261c
movq %rax, %r15
movq %r12, %rdi
callq 0x4275d
movq %rax, %r12
movq %rax, %rdi
callq 0x427e9
cmpl $-0x1, %eax
je 0x4a776
xorl %r13d, %r13d
testq %r13, %r13
jne 0x4a728
cmpq $0x40, %r15
movl $0x40, %eax
cmovlq %r15, %rax
leal 0x2(,%rax,2), %edx
movq %r14, %rdi
movl $0x2a, %esi
callq 0x5891c
xorl %ebp, %ebp
testq %rax, %rax
je 0x4a783
movl $0x5, %edx
movq %r14, %rdi
leaq 0x4efa2(%rip), %rsi     # 0x996b1
callq 0x589bc
testq %rax, %rax
je 0x4a783
movq %r14, %rdi
movq %rbx, %rsi
callq 0x49f3a
testl %eax, %eax
je 0x4a783
movq %r14, %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x4a794
xorl %ebp, %ebp
testl %eax, %eax
je 0x4a783
movq %r14, %rdi
movq %r12, %rsi
movl $0x2, %edx
callq 0x4a794
testl %eax, %eax
je 0x4a783
incq %r13
cmpq $0x40, %r13
movl $0x0, %eax
cmoveq %rax, %r13
decq %r15
movq %r12, %rdi
callq 0x427e9
cmpl $-0x1, %eax
jne 0x4a6cf
movq %r12, %rdi
callq 0x427cd
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: rioWriteHashIteratorCursor
static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {

    if (hi->encoding == REDIS_ENCODING_ZIPLIST) {
        unsigned char *vstr = NULL;
        unsigned int vlen = UINT_MAX;
        long long vll = LLONG_MAX;

        hashTypeCurrentFromZiplist(hi, what, &vstr, &vlen, &vll);
        if (vstr) {
            return rioWriteBulkString(r, (char*)vstr, vlen);
        } else {
            return rioWriteBulkLongLong(r, vll);
        }

    } else if (hi->encoding == REDIS_ENCODING_HT) {
        robj *value;

        hashTypeCurrentFromHashTable(hi, what, &value);
        return rioWriteBulkObject(r, value);
    }

    redisPanic("Unknown hash encoding");
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x8(%rsi), %eax
cmpl $0x2, %eax
je 0x4a7fb
cmpl $0x5, %eax
jne 0x4a82f
leaq 0x10(%rsp), %r14
movq $0x0, (%r14)
leaq 0x4(%rsp), %rcx
movl $0xffffffff, (%rcx)     # imm = 0xFFFFFFFF
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x428d7
movq (%r14), %rsi
testq %rsi, %rsi
je 0x4a81a
movl 0x4(%rsp), %edx
movq %rbx, %rdi
callq 0x589bc
jmp 0x4a827
leaq 0x10(%rsp), %r14
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x4295e
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x49f3a
jmp 0x4a827
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x58ab3
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x4e2d9(%rip), %rdi     # 0x98b0f
leaq 0x4fe14(%rip), %rsi     # 0x9a651
movl $0x4f7, %edx            # imm = 0x4F7
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/aof.c
// Function: bgrewriteaofCommand
void bgrewriteaofCommand(redisClient *c) {

    // 不能重复运行 BGREWRITEAOF
    if (server.aof_child_pid != -1) {
        addReplyError(c,"Background append only file rewriting already in progress");

    // 如果正在执行 BGSAVE ，那么预定 BGREWRITEAOF
    // 等 BGSAVE 完成之后， BGREWRITEAOF 就会开始执行
    } else if (server.rdb_child_pid != -1) {
        server.aof_rewrite_scheduled = 1;
        addReplyStatus(c,"Background append only file rewriting scheduled");

    // 执行 BGREWRITEAOF
    } else if (rewriteAppendOnlyFileBackground() == REDIS_OK) {
        addReplyStatus(c,"Background append only file rewriting started");

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

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x7f1ea(%rip), %rax     # 0xc9fa8
cmpl $-0x1, 0x504(%rax)
je 0x4add7
leaq 0x4ffab(%rip), %rsi     # 0x9ad79
movq %rbx, %rdi
popq %rbx
jmp 0x2dc63
cmpl $-0x1, 0x570(%rax)
je 0x4adfa
movl $0x1, 0x500(%rax)
leaq 0x4ffc2(%rip), %rsi     # 0x9adb3
movq %rbx, %rdi
popq %rbx
jmp 0x2ddb7
callq 0x495c3
testl %eax, %eax
je 0x4ae17
leaq 0x7f9f6(%rip), %rax     # 0xca800
movq 0x10(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d97c
leaq 0x4ffc5(%rip), %rsi     # 0x9ade3
jmp 0x4adf1
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: pubsubSubscribeChannel
int pubsubSubscribeChannel(redisClient *c, robj *channel) {
    dictEntry *de;
    list *clients = NULL;
    int retval = 0;

    /* Add the channel to the client -> channels hash table */
    // 将 channels 填接到 c->pubsub_channels 的集合中（值为 NULL 的字典视为集合）
    if (dictAdd(c->pubsub_channels,channel,NULL) == DICT_OK) {
        retval = 1;
        incrRefCount(channel);

        // 关联示意图
        // {
        //  频道名        订阅频道的客户端
        //  'channel-a' : [c1, c2, c3],
        //  'channel-b' : [c5, c2, c1],
        //  'channel-c' : [c10, c2, c1]
        // }
        /* Add the client to the channel -> list of clients hash table */
        // 从 pubsub_channels 字典中取出保存着所有订阅了 channel 的客户端的链表
        // 如果 channel 不存在于字典，那么添加进去
        de = dictFind(server.pubsub_channels,channel);
        if (de == NULL) {
            clients = listCreate();
            dictAdd(server.pubsub_channels,channel,clients);
            incrRefCount(channel);
        } else {
            clients = dictGetVal(de);
        }

        // before:
        // 'channel' : [c1, c2]
        // after:
        // 'channel' : [c1, c2, c3]
        // 将客户端添加到链表的末尾
        listAddNodeTail(clients,c);
    }

    /* Notify the client */
    // 回复客户端。
    // 示例：
    // redis 127.0.0.1:6379> SUBSCRIBE xxx
    // Reading messages... (press Ctrl-C to quit)
    // 1) "subscribe"
    // 2) "xxx"
    // 3) (integer) 1
    addReply(c,shared.mbulkhdr[3]);
    // "subscribe\n" 字符串
    addReply(c,shared.subscribebulk);
    // 被订阅的客户端
    addReplyBulk(c,channel);
    // 客户端订阅的频道和模式总数
    addReplyLongLong(c,dictSize(c->pubsub_channels)+listLength(c->pubsub_patterns));

    return retval;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x158(%rdi), %rdi
xorl %r15d, %r15d
xorl %edx, %edx
callq 0x2249c
testl %eax, %eax
jne 0x4b232
movq %r14, %rdi
callq 0x306f3
leaq 0x7edc5(%rip), %r12     # 0xc9fa8
movq 0x7a8(%r12), %rdi
movq %r14, %rsi
callq 0x226ac
testq %rax, %rax
je 0x4b1fe
movq 0x8(%rax), %r15
jmp 0x4b221
callq 0x203fc
movq %rax, %r15
movq 0x7a8(%r12), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2249c
movq %r14, %rdi
callq 0x306f3
movq %r15, %rdi
movq %rbx, %rsi
callq 0x204cb
movl $0x1, %r15d
leaq 0x7f5c7(%rip), %r12     # 0xca800
movq 0x13a48(%r12), %rsi
movq %rbx, %rdi
callq 0x2d97c
movq 0x108(%r12), %rsi
movq %rbx, %rdi
callq 0x2d97c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e204
movq 0x158(%rbx), %rax
movq 0x160(%rbx), %rcx
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
addq 0x28(%rcx), %rsi
movq %rbx, %rdi
callq 0x2e133
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: pubsubSubscribePattern
int pubsubSubscribePattern(redisClient *c, robj *pattern) {
    int retval = 0;

    // 在链表中查找模式，看客户端是否已经订阅了这个模式
    // 这里为什么不像 channel 那样，用字典来进行检测呢？
    // 虽然 pattern 的数量一般来说并不多
    if (listSearchKey(c->pubsub_patterns,pattern) == NULL) {
        
        // 如果没有的话，执行以下代码

        retval = 1;

        pubsubPattern *pat;

        // 将 pattern 添加到 c->pubsub_patterns 链表中
        listAddNodeTail(c->pubsub_patterns,pattern);

        incrRefCount(pattern);

        // 创建并设置新的 pubsubPattern 结构
        pat = zmalloc(sizeof(*pat));
        pat->pattern = getDecodedObject(pattern);
        pat->client = c;

        // 添加到末尾
        listAddNodeTail(server.pubsub_patterns,pat);
    }

    /* Notify the client */
    // 回复客户端。
    // 示例：
    // redis 127.0.0.1:6379> PSUBSCRIBE xxx*
    // Reading messages... (press Ctrl-C to quit)
    // 1) "psubscribe"
    // 2) "xxx*"
    // 3) (integer) 1
    addReply(c,shared.mbulkhdr[3]);
    // 回复 "psubscribe" 字符串
    addReply(c,shared.psubscribebulk);
    // 回复被订阅的模式
    addReplyBulk(c,pattern);
    // 回复客户端订阅的频道和模式的总数
    addReplyLongLong(c,dictSize(c->pubsub_channels)+listLength(c->pubsub_patterns));

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x160(%rdi), %rdi
callq 0x20729
xorl %ebp, %ebp
testq %rax, %rax
jne 0x4b448
movq 0x160(%rbx), %rdi
movq %r14, %rsi
callq 0x204cb
movq %r14, %rdi
callq 0x306f3
movl $0x10, %edi
callq 0x299b5
movq %rax, %r15
movq %r14, %rdi
callq 0x30d93
movq %rax, 0x8(%r15)
movq %rbx, (%r15)
leaq 0x7eb74(%rip), %rax     # 0xc9fa8
movq 0x7b0(%rax), %rdi
movq %r15, %rsi
callq 0x204cb
movl $0x1, %ebp
leaq 0x7f3b1(%rip), %r15     # 0xca800
movq 0x13a48(%r15), %rsi
movq %rbx, %rdi
callq 0x2d97c
movq 0x118(%r15), %rsi
movq %rbx, %rdi
callq 0x2d97c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2e204
movq 0x158(%rbx), %rax
movq 0x160(%rbx), %rcx
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
addq 0x28(%rcx), %rsi
movq %rbx, %rdi
callq 0x2e133
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: pubsubUnsubscribePattern
int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) {
    listNode *ln;
    pubsubPattern pat;
    int retval = 0;

    incrRefCount(pattern); /* Protect the object. May be the same we remove */

    // 先确认一下，客户端是否订阅了这个模式
    if ((ln = listSearchKey(c->pubsub_patterns,pattern)) != NULL) {

        retval = 1;

        // 将模式从客户端的订阅列表中删除
        listDelNode(c->pubsub_patterns,ln);

        // 设置 pubsubPattern 结构
        pat.client = c;
        pat.pattern = pattern;

        // 在服务器中查找
        ln = listSearchKey(server.pubsub_patterns,&pat);
        listDelNode(server.pubsub_patterns,ln);
    }

    /* Notify the client */
    // 回复客户端
    if (notify) {
        addReply(c,shared.mbulkhdr[3]);
        // "punsubscribe" 字符串
        addReply(c,shared.punsubscribebulk);
        // 被退订的模式
        addReplyBulk(c,pattern);
        // 退订频道之后客户端仍在订阅的频道和模式的总数
        addReplyLongLong(c,dictSize(c->pubsub_channels)+
                       listLength(c->pubsub_patterns));
    }

    decrRefCount(pattern);

    return retval;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x306f3
movq 0x160(%r14), %rdi
movq %rbx, %rsi
callq 0x20729
testq %rax, %rax
je 0x4b51a
movq 0x160(%r14), %rdi
movq %rax, %rsi
callq 0x205b1
movq %rsp, %rsi
movq %r14, (%rsi)
movq %rbx, 0x8(%rsi)
leaq 0x7eab1(%rip), %r15     # 0xc9fa8
movq 0x7b0(%r15), %rdi
callq 0x20729
movq 0x7b0(%r15), %rdi
movq %rax, %rsi
callq 0x205b1
movl $0x1, %r15d
jmp 0x4b51d
xorl %r15d, %r15d
testl %ebp, %ebp
je 0x4b575
leaq 0x7f2d8(%rip), %r12     # 0xca800
movq 0x13a48(%r12), %rsi
movq %r14, %rdi
callq 0x2d97c
movq 0x120(%r12), %rsi
movq %r14, %rdi
callq 0x2d97c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e204
movq 0x158(%r14), %rax
movq 0x160(%r14), %rcx
movq 0x48(%rax), %rsi
addq 0x28(%rax), %rsi
addq 0x28(%rcx), %rsi
movq %r14, %rdi
callq 0x2e133
movq %rbx, %rdi
callq 0x30b0c
movl %r15d, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: unsubscribeCommand
void unsubscribeCommand(redisClient *c) {
    if (c->argc == 1) {
        pubsubUnsubscribeAllChannels(c,1);
    } else {
        int j;

        for (j = 1; j < c->argc; j++)
            pubsubUnsubscribeChannel(c,c->argv[j],1);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x30(%rdi), %eax
cmpl $0x1, %eax
jne 0x4b8e1
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4b58d
jle 0x4b90a
movl $0x1, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x4b295
incq %r14
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jl 0x4b8e9
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: punsubscribeCommand
void punsubscribeCommand(redisClient *c) {
    if (c->argc == 1) {
        pubsubUnsubscribeAllPatterns(c,1);
    } else {
        int j;

        for (j = 1; j < c->argc; j++)
            pubsubUnsubscribePattern(c,c->argv[j],1);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x30(%rdi), %eax
cmpl $0x1, %eax
jne 0x4b96c
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4b643
jle 0x4b995
movl $0x1, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x4b4a7
incq %r14
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jl 0x4b974
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/pubsub.c
// Function: publishCommand
void publishCommand(redisClient *c) {

    int receivers = pubsubPublishMessage(c->argv[1],c->argv[2]);
    if (server.cluster_enabled)
        clusterPropagatePublish(c->argv[1],c->argv[2]);
    else
        forceCommandPropagation(c,REDIS_PROPAGATE_REPL);
    addReplyLongLong(c,receivers);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
callq 0x4b702
movl %eax, %ebp
leaq 0x7e5eb(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x7bc(%rax)
je 0x4b9d9
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
callq 0x52e94
jmp 0x4b9e6
movq %rbx, %rdi
movl $0x2, %esi
callq 0x25d1e
movslq %ebp, %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x2e133
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: freeClientMultiState
void freeClientMultiState(redisClient *c) {
    int j;

    // 遍历事务队列
    for (j = 0; j < c->mstate.count; j++) {
        int i;
        multiCmd *mc = c->mstate.commands+j;

        // 释放所有命令参数
        for (i = 0; i < mc->argc; i++)
            decrRefCount(mc->argv[i]);

        // 释放参数数组本身
        zfree(mc->argv);
    }

    // 释放事务队列
    zfree(c->mstate.commands);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x108(%rdi)
jle 0x4bc4d
xorl %r14d, %r14d
movq 0x100(%rbx), %rax
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %r15
cmpl $0x0, 0x8(%r15)
jle 0x4bc36
xorl %r12d, %r12d
movq (%r15), %rax
movq (%rax,%r12,8), %rdi
callq 0x30b0c
incq %r12
movslq 0x8(%r15), %rax
cmpq %rax, %r12
jl 0x4bc1e
movq (%r15), %rdi
callq 0x29af7
incq %r14
movslq 0x108(%rbx), %rax
cmpq %rax, %r14
jl 0x4bc05
movq 0x100(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x29af7
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: discardCommand
void discardCommand(redisClient *c) {

    // 不能在客户端未进行事务状态之前使用
    if (!(c->flags & REDIS_MULTI)) {
        addReplyError(c,"DISCARD without MULTI");
        return;
    }

    discardTransaction(c);

    addReply(c,shared.ok);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testb $0x8, 0x90(%rdi)
jne 0x4be8e
leaq 0x4f24d(%rip), %rsi     # 0x9b0d2
movq %rbx, %rdi
popq %rbx
jmp 0x2dc63
movq %rbx, %rdi
callq 0x4bbee
movq $0x0, 0x100(%rbx)
movl $0x0, 0x108(%rbx)
andl $0xffffefd7, 0x90(%rbx) # imm = 0xFFFFEFD7
movq %rbx, %rdi
callq 0x4bd35
leaq 0x7e93c(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d97c
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: execCommandPropagateMulti
void execCommandPropagateMulti(redisClient *c) {
    robj *multistring = createStringObject("MULTI",5);

    propagate(server.multiCommand,c->db->id,&multistring,1,
              REDIS_PROPAGATE_AOF|REDIS_PROPAGATE_REPL);

    decrRefCount(multistring);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4f216(%rip), %rdi     # 0x9b0f5
movl $0x5, %esi
callq 0x3068f
movq %rsp, %r14
movq %rax, (%r14)
leaq 0x7e0b2(%rip), %rax     # 0xc9fa8
movq 0x320(%rax), %rdi
movq 0x8(%rbx), %rax
movl 0x30(%rax), %esi
movq %r14, %rdx
movl $0x1, %ecx
movl $0x3, %r8d
callq 0x25c59
movq (%r14), %rdi
callq 0x30b0c
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: touchWatchedKey
void touchWatchedKey(redisDb *db, robj *key) {
    list *clients;
    listIter li;
    listNode *ln;

    // 字典为空，没有任何键被监视
    if (dictSize(db->watched_keys) == 0) return;

    // 获取所有监视这个键的客户端
    clients = dictFetchValue(db->watched_keys, key);
    if (!clients) return;

    /* Mark all the clients watching this key as REDIS_DIRTY_CAS */
    /* Check if we are already watching for this key */
    // 遍历所有客户端，打开他们的 REDIS_DIRTY_CAS 标识
    listRewind(clients,&li);
    while((ln = listNext(&li))) {
        redisClient *c = listNodeValue(ln);

        c->flags |= REDIS_DIRTY_CAS;
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq 0x20(%rdi), %rdi
movq 0x28(%rdi), %rax
addq 0x48(%rdi), %rax
je 0x4c274
callq 0x229cf
testq %rax, %rax
je 0x4c274
movq %rsp, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x20637
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
je 0x4c274
movq %rsp, %rbx
movq 0x10(%rax), %rax
orl $0x20, 0x90(%rax)
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
jne 0x4c25c
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: touchWatchedKeysOnFlush
void touchWatchedKeysOnFlush(int dbid) {
    listIter li1, li2;
    listNode *ln;

    // 这里的思路挺有趣的，不是遍历数据库的所有 key 来让客户端变为 DIRTY
    // 而是遍历所有客户端，然后遍历客户端监视的键，再让相应的客户端变为 DIRTY
    // 后者要比前者高效很多

    /* For every client, check all the waited keys */
    // 遍历所有客户端
    listRewind(server.clients,&li1);
    while((ln = listNext(&li1))) {

        redisClient *c = listNodeValue(ln);

        // 遍历客户端监视的键
        listRewind(c->watched_keys,&li2);
        while((ln = listNext(&li2))) {

            // 取出监视的键和键的数据库
            watchedKey *wk = listNodeValue(ln);

            /* For every watched key matching the specified DB, if the
             * key exists, mark the client as dirty, as the key will be
             * removed. */
            // 如果数据库号码相同，或者执行的命令为 FLUSHALL
            // 那么将客户端设置为 REDIS_DIRTY_CAS
            if (dbid == -1 || wk->db->id == dbid) {
                if (dictFind(wk->db->dict, wk->key->ptr) != NULL)
                    c->flags |= REDIS_DIRTY_CAS;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %ebx
leaq 0x7dd1a(%rip), %rax     # 0xc9fa8
movq 0x1b0(%rax), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x20637
movq %r14, %rdi
callq 0x20654
testq %rax, %rax
je 0x4c318
leaq 0x18(%rsp), %r14
leaq 0x8(%rsp), %r15
movq 0x10(%rax), %r12
movq 0x150(%r12), %rdi
movq %r14, %rsi
callq 0x20637
movq %r14, %rdi
callq 0x20654
testq %rax, %rax
je 0x4c30b
movq 0x10(%rax), %rax
movq 0x8(%rax), %rcx
cmpl $-0x1, %ebx
je 0x4c2ec
cmpl %ebx, 0x30(%rcx)
jne 0x4c2cd
movq (%rcx), %rdi
movq (%rax), %rax
movq 0x8(%rax), %rsi
callq 0x226ac
testq %rax, %rax
je 0x4c2cd
orb $0x20, 0x90(%r12)
jmp 0x4c2cd
movq %r15, %rdi
callq 0x20654
testq %rax, %rax
jne 0x4c2b9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: watchCommand
void watchCommand(redisClient *c) {
    int j;

    // 不能在事务开始后执行
    if (c->flags & REDIS_MULTI) {
        addReplyError(c,"WATCH inside MULTI is not allowed");
        return;
    }

    // 监视输入的任意个键
    for (j = 1; j < c->argc; j++)
        watchForKey(c,c->argv[j]);

    addReply(c,shared.ok);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testb $0x8, 0x90(%rdi)
jne 0x4c376
cmpl $0x2, 0x30(%rbx)
jl 0x4c35c
movl $0x1, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq %rbx, %rdi
callq 0x4c143
incq %r14
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jl 0x4c340
leaq 0x7e49d(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2d97c
leaq 0x4ed96(%rip), %rsi     # 0x9b113
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2dc63
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/multi.c
// Function: unwatchCommand
void unwatchCommand(redisClient *c) {

    // 取消客户端对所有键的监视
    unwatchAllKeys(c);
    
    // 重置状态
    c->flags &= (~REDIS_DIRTY_CAS);

    addReply(c,shared.ok);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x4bd35
andb $-0x21, 0x90(%rbx)
leaq 0x7e45d(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d97c
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: redisAssert
void _redisAssert(char *estr, char *file, int line) {
    bugReportStart();
    redisLog(REDIS_WARNING,"=== ASSERTION FAILED ===");
    redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true",file,line,estr);
#ifdef HAVE_BACKTRACE
    server.assert_failed = estr;
    server.assert_file = file;
    server.assert_line = line;
    redisLog(REDIS_WARNING,"(forcing SIGSEGV to print the bug report.)");
#endif
    *((char*)-1) = 'x';
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x7d55f(%rip), %r12     # 0xc9fa8
cmpl $0x0, 0x834(%r12)
jne 0x4ca73
leaq 0x4ebee(%rip), %rsi     # 0x9b649
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movl $0x1, 0x834(%r12)
leaq 0x4e929(%rip), %rsi     # 0x9b3a3
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
leaq 0x4e92f(%rip), %rsi     # 0x9b3bc
movl $0x3, %edi
movq %r14, %rdx
movl %ebx, %ecx
movq %r15, %r8
xorl %eax, %eax
callq 0x23223
movq %r15, 0x820(%r12)
movq %r14, 0x828(%r12)
movl %ebx, 0x830(%r12)
leaq 0x4e917(%rip), %rsi     # 0x9b3d7
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movb $0x78, -0x1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: redisPanic
void _redisPanic(char *msg, char *file, int line) {
    bugReportStart();
    redisLog(REDIS_WARNING,"------------------------------------------------");
    redisLog(REDIS_WARNING,"!!! Software Failure. Press left mouse button to continue");
    redisLog(REDIS_WARNING,"Guru Meditation: %s #%s:%d",msg,file,line);
#ifdef HAVE_BACKTRACE
    redisLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)");
#endif
    redisLog(REDIS_WARNING,"------------------------------------------------");
    *((char*)-1) = 'x';
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x7d4b1(%rip), %r12     # 0xc9fa8
cmpl $0x0, 0x834(%r12)
jne 0x4cb21
leaq 0x4eb40(%rip), %rsi     # 0x9b649
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movl $0x1, 0x834(%r12)
leaq 0x4ea67(%rip), %r12     # 0x9b58f
movl $0x3, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x23223
leaq 0x4ea82(%rip), %rsi     # 0x9b5c0
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
leaq 0x4eaa9(%rip), %rsi     # 0x9b5fa
movl $0x3, %edi
movq %r15, %rdx
movq %r14, %rcx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x23223
leaq 0x4eaa8(%rip), %rsi     # 0x9b615
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movl $0x3, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x23223
movb $0x78, -0x1
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: bugReportStart
void bugReportStart(void) {
    if (server.bug_report_start == 0) {
        redisLog(REDIS_WARNING,
            "\n\n=== REDIS BUG REPORT START: Cut & paste starting from here ===");
        server.bug_report_start = 1;
    }
}

// Assembly:
pushq %rbx
leaq 0x7cce6(%rip), %rbx     # 0xc9fa8
cmpl $0x0, 0x834(%rbx)
jne 0x4d2e8
leaq 0x4e377(%rip), %rsi     # 0x9b649
movl $0x3, %edi
xorl %eax, %eax
callq 0x23223
movl $0x1, 0x834(%rbx)
popq %rbx
retq