LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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
subq $0x108, %rsp            # imm = 0x108
movl %edi, %ebx
movl %esi, %eax
orl %edi, %eax
je 0x385c4
movl %esi, %ebp
testl %esi, %esi
setne %al
testl %ebx, %ebx
sete %cl
orb %al, %cl
jne 0x385ff
leaq 0x60833(%rip), %rsi     # 0x98de0
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x3864d
leaq 0x607eb(%rip), %rsi     # 0x98db6
xorl %r14d, %r14d
movl $0x2, %edi
xorl %eax, %eax
callq 0x23064
leaq 0x919c7(%rip), %r15     # 0xc9fa8
movq 0x568(%r15), %rax
subq %rax, 0x560(%r15)
xorl %edi, %edi
callq 0x1fc50
movq %rax, 0x598(%r15)
jmp 0x3864d
leaq 0x607f2(%rip), %rsi     # 0x98df8
movl $0x3, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x23064
leaq 0x9198d(%rip), %rax     # 0xc9fa8
movl 0x570(%rax), %ecx
leaq 0x604ad(%rip), %rdx     # 0x98ad5
movq %rsp, %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
xorl %eax, %eax
callq 0x1f120
movq %r14, %rdi
callq 0x1f3a0
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0xa, %ebp
je 0x3865b
leaq 0x91954(%rip), %rax     # 0xc9fa8
movl %r14d, 0x5b8(%rax)
leaq 0x91946(%rip), %r15     # 0xc9fa8
movl $0xffffffff, 0x570(%r15) # imm = 0xFFFFFFFF
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1fc50
subq 0x5b0(%r15), %rax
movq %rax, 0x5a8(%r15)
movq $-0x1, 0x5b0(%r15)
negl %ebx
sbbl %r14d, %r14d
movl %r14d, %edi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x34160
// File: /workspace/github_c_makefile_star2_O1/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 0x918f3(%rip), %rax     # 0xc9fa8
cmpl $-0x1, 0x570(%rax)
je 0x386ce
leaq 0x6075d(%rip), %rsi     # 0x98e22
movq %rbx, %rdi
popq %rbx
jmp 0x2d9d7
movq 0x588(%rax), %rdi
callq 0x3725a
testl %eax, %eax
je 0x386eb
leaq 0x9211b(%rip), %rax     # 0xca800
movq 0x10(%rax), %rsi
jmp 0x386f6
leaq 0x9210e(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d6f0
// File: /workspace/github_c_makefile_star2_O1/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 0x9189e(%rip), %rax     # 0xc9fa8
cmpl $-0x1, 0x570(%rax)
je 0x3871c
leaq 0x60708(%rip), %rsi     # 0x98e22
jmp 0x3872c
cmpl $-0x1, 0x504(%rax)
je 0x38735
leaq 0x6071a(%rip), %rsi     # 0x98e46
movq %rbx, %rdi
popq %rbx
jmp 0x2d9d7
movq 0x588(%rax), %rdi
callq 0x37660
testl %eax, %eax
je 0x38759
leaq 0x920b4(%rip), %rax     # 0xca800
movq 0x10(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d6f0
leaq 0x6071a(%rip), %rsi     # 0x98e7a
movq %rbx, %rdi
popq %rbx
jmp 0x2db27
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/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 0x91c2d(%rip), %r14     # 0xca800
movq 0x50(%r14), %rdx
callq 0x31475
xorl %ebp, %ebp
testq %rax, %rax
je 0x38c06
testb $0xf, (%rax)
je 0x38bfb
movq 0x70(%r14), %rsi
movq %rbx, %rdi
callq 0x2d6f0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x38c06
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2df74
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x38bbd
cmpl $-0x1, %eax
je 0x38c78
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x30971
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 0x315fb
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x5c87e(%rip), %rsi     # 0x954de
movl $0x8, %edi
callq 0x608b5
leaq 0x91337(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x310df
testl %eax, %eax
jne 0x38e7b
movq 0x38(%rbx), %rax
movq 0x18(%rax), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x310df
testl %eax, %eax
je 0x38e85
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x9196c(%rip), %r15     # 0xca800
movq 0x18(%r15), %rdx
movq %rbx, %rdi
callq 0x31475
testq %rax, %rax
je 0x38e7b
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x308e7
testl %eax, %eax
jne 0x38e7b
movl $0xf0, %eax
andl (%r14), %eax
movq 0x8(%r14), %rdx
cmpl $0x10, %eax
jne 0x38ee1
leaq 0x10(%rsp), %r14
movl $0x20, %esi
movq %r14, %rdi
callq 0x2fe12
movq %r14, %rdx
jmp 0x38ee4
movl -0x8(%rdx), %eax
cltq
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
jns 0x38ef8
addq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq (%rsp), %rcx
testq %rcx, %rcx
jns 0x38f08
addq %rax, %rcx
movq %rcx, (%rsp)
cmpq $0x0, 0x8(%rsp)
jns 0x38f19
movq $0x0, 0x8(%rsp)
cmpq $0x0, (%rsp)
jns 0x38f28
movq $0x0, (%rsp)
movl (%rsp), %ecx
cmpq %rax, %rcx
jb 0x38f37
decq %rax
movq %rax, (%rsp)
movq 0x8(%rsp), %rcx
movq (%rsp), %rax
subq %rcx, %rax
jge 0x38f56
movq 0x18(%r15), %rsi
movq %rbx, %rdi
callq 0x2d6f0
jmp 0x38e7b
addq %rcx, %rdx
incq %rax
movq %rbx, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x2dfa7
jmp 0x38e7b
// File: /workspace/github_c_makefile_star2_O1/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 0x2ded8
cmpl $0x2, 0x30(%rbx)
jl 0x38fd6
movl $0x1, %r14d
leaq 0x9186a(%rip), %r15     # 0xca800
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rsi
callq 0x3136a
testq %rax, %rax
je 0x38fb1
testb $0xf, (%rax)
je 0x38fbf
movq 0x50(%r15), %rsi
movq %rbx, %rdi
callq 0x2d6f0
jmp 0x38fca
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2df74
incq %r14
movslq 0x30(%rbx), %rax
cmpq %rax, %r14
jl 0x38f96
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
pushq %rax
movq %rdi, %rbx
testb $0x1, 0x30(%rdi)
jne 0x39005
leaq 0x5fed5(%rip), %rsi     # 0x98ec8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2d9d7
movl %esi, %ebp
testl %esi, %esi
je 0x39052
cmpl $0x2, 0x30(%rbx)
jl 0x39052
xorl %r14d, %r14d
movl $0x1, %r15d
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rsi
callq 0x31454
cmpq $0x1, %rax
sbbl $-0x1, %r14d
addq $0x2, %r15
cmpl %r15d, 0x30(%rbx)
jg 0x3901a
testl %r14d, %r14d
je 0x39052
leaq 0x917b7(%rip), %rax     # 0xca800
movq 0x20(%rax), %rsi
jmp 0x390ef
movl 0x30(%rbx), %eax
cmpl $0x2, %eax
jl 0x390bc
movl $0x1, %r15d
leaq 0x5c477(%rip), %r14     # 0x954de
movq 0x38(%rbx), %rax
movq 0x8(%rax,%r15,8), %rdi
callq 0x30971
movq 0x38(%rbx), %rcx
movq %rax, 0x8(%rcx,%r15,8)
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq 0x8(%rax,%r15,8), %rdx
callq 0x315fb
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r15,8), %rdx
movl 0x30(%rax), %ecx
movl $0x8, %edi
movq %r14, %rsi
callq 0x608b5
addq $0x2, %r15
movl 0x30(%rbx), %eax
cmpl %r15d, %eax
jg 0x39067
xorl %ecx, %ecx
testl %ebp, %ebp
setne %cl
movl %eax, %edx
decl %edx
shrl $0x1f, %edx
addl %edx, %eax
decl %eax
sarl %eax
cltq
leaq 0x90ecf(%rip), %rdx     # 0xc9fa8
addq %rax, 0x560(%rdx)
leaq 0x91719(%rip), %rax     # 0xca800
shll $0x5, %ecx
movq 0x8(%rax,%rcx), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2d6f0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: incrDecrCommand
void incrDecrCommand(redisClient *c, long long incr) {
    long long value, oldvalue;
    robj *o, *new;

    // 取出值对象
    o = lookupKeyWrite(c->db,c->argv[1]);

    // 检查对象是否存在，以及类型是否正确
    if (o != NULL && checkType(c,o,REDIS_STRING)) return;

    // 取出对象的整数值，并保存到 value 参数中
    if (getLongLongFromObjectOrReply(c,o,&value,NULL) != REDIS_OK) return;

    // 检查加法操作执行之后值释放会溢出
    // 如果是的话，就向客户端发送一个出错回复，并放弃设置操作
    oldvalue = value;
    if ((incr < 0 && oldvalue < 0 && incr < (LLONG_MIN-oldvalue)) ||
        (incr > 0 && oldvalue > 0 && incr > (LLONG_MAX-oldvalue))) {
        addReplyError(c,"increment or decrement would overflow");
        return;
    }

    // 进行加法计算，并将值保存到新的值对象中
    // 然后用新的值对象替换原来的值对象
    value += incr;
    new = createStringObjectFromLongLong(value);
    if (o)
        dbOverwrite(c->db,c->argv[1],new);
    else
        dbAdd(c->db,c->argv[1],new);

    // 向数据库发送键被修改的信号
    signalModifiedKey(c->db,c->argv[1]);

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

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

    // 返回回复
    addReply(c,shared.colon);
    addReply(c,new);
    addReply(c,shared.crlf);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31454
movq %rax, %r14
testq %rax, %rax
je 0x3914f
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x308e7
testl %eax, %eax
jne 0x39254
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x31082
testl %eax, %eax
jne 0x39254
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
movq 0x8(%rsp), %rdi
subq %rdi, %rax
testq %r15, %r15
jns 0x3918e
testq %rdi, %rdi
jns 0x3918e
leaq 0x1(%rax), %rcx
cmpq %r15, %rcx
jg 0x391a8
testq %r15, %r15
setg %cl
testq %rdi, %rdi
setg %dl
andb %cl, %dl
cmpq %r15, %rax
setl %al
andb %dl, %al
cmpb $0x1, %al
jne 0x391bc
leaq 0x5fd3c(%rip), %rsi     # 0x98eeb
movq %rbx, %rdi
callq 0x2d9d7
jmp 0x39254
addq %r15, %rdi
movq %rdi, 0x8(%rsp)
callq 0x303c6
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
testq %r14, %r14
je 0x391e7
callq 0x315a0
jmp 0x391ec
callq 0x314ef
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x316b7
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x5b265(%rip), %rsi     # 0x94478
movl $0x8, %edi
callq 0x608b5
leaq 0x90d84(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
leaq 0x915ce(%rip), %r14     # 0xca800
movq 0x48(%r14), %rsi
movq %rbx, %rdi
callq 0x2d6f0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2d6f0
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x2d6f0
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: appendCommand
void appendCommand(redisClient *c) {
    size_t totlen;
    robj *o, *append;

    // 取出键相应的值对象
    o = lookupKeyWrite(c->db,c->argv[1]);
    if (o == NULL) {

        // 键值对不存在。。。

        /* Create the key */
        // 键值对不存在，创建一个新的
        c->argv[2] = tryObjectEncoding(c->argv[2]);
        dbAdd(c->db,c->argv[1],c->argv[2]);
        incrRefCount(c->argv[2]);
        totlen = stringObjectLen(c->argv[2]);
    } else {

        // 键值对存在。。。

        /* Key exists, check type */
        // 检查类型
        if (checkType(c,o,REDIS_STRING))
            return;

        /* "append" is an argument, so always an sds */
        // 检查追加操作之后，字符串的长度是否符合 Redis 的限制
        append = c->argv[2];
        totlen = stringObjectLen(o)+sdslen(append->ptr);
        if (checkStringLength(c,totlen) != REDIS_OK)
            return;

        /* Append the value */
        // 执行追加操作
        o = dbUnshareStringValue(c->db,c->argv[1],o);
        o->ptr = sdscatlen(o->ptr,append->ptr,sdslen(append->ptr));
        totlen = sdslen(o->ptr);
    }

    // 向数据库发送键被修改的信号
    signalModifiedKey(c->db,c->argv[1]);

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

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

    // 发送回复
    addReplyLongLong(c,totlen);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31454
testq %rax, %rax
je 0x39499
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x308e7
testl %eax, %eax
je 0x394e2
popq %rbx
popq %r14
popq %r15
retq
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x30971
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 0x314ef
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x3041b
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x30c6f
movq %rax, %r14
jmp 0x39536
movq 0x38(%rbx), %rax
movq 0x10(%rax), %r15
movq %r14, %rdi
callq 0x30c6f
movq 0x8(%r15), %rcx
movslq -0x8(%rcx), %rcx
addq %rax, %rcx
cmpq $0x20000001, %rcx       # imm = 0x20000001
jge 0x39585
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdx
callq 0x317d7
movq %rax, %r14
movq 0x8(%rax), %rdi
movq 0x8(%r15), %rsi
movslq -0x8(%rsi), %rdx
callq 0x28380
movq %rax, 0x8(%r14)
movslq -0x8(%rax), %r14
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x316b7
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x5ad16(%rip), %rsi     # 0x94273
movl $0x8, %edi
callq 0x608b5
leaq 0x90a3a(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x2dea3
leaq 0x5f9ad(%rip), %rsi     # 0x98f39
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2d9d7
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_string.c
// Function: strlenCommand
void strlenCommand(redisClient *c) {
    robj *o;

    // 取出值对象，并进行类型检查
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_STRING)) return;

    // 返回字符串值的长度
    addReplyLongLong(c,stringObjectLen(o));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x91251(%rip), %rax     # 0xca800
movq 0x20(%rax), %rdx
callq 0x31475
testq %rax, %rax
je 0x395d1
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x308e7
testl %eax, %eax
je 0x395d9
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
callq 0x30c6f
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2dea3
nop
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeTryConversion
void listTypeTryConversion(robj *subject, robj *value) {

    // 确保 subject 为 ZIPLIST 编码
    if (subject->encoding != REDIS_ENCODING_ZIPLIST) return;

    if (sdsEncodedObject(value) &&
        // 看字符串是否过长
        sdslen(value->ptr) > server.list_max_ziplist_value)
            // 将编码转换为双端链表
            listTypeConvert(subject,REDIS_ENCODING_LINKEDLIST);
}

// Assembly:
movl $0xf0, %eax
andl (%rdi), %eax
cmpl $0x50, %eax
jne 0x3962b
movl (%rsi), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x3962b
movq 0x8(%rsi), %rax
movslq -0x8(%rax), %rax
leaq 0x90990(%rip), %rcx     # 0xc9fa8
cmpq %rax, 0x770(%rcx)
jae 0x3962b
movl $0x4, %esi
jmp 0x3962c
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeConvert
void listTypeConvert(robj *subject, int enc) {

    listTypeIterator *li;

    listTypeEntry entry;

    redisAssertWithInfo(NULL,subject,subject->type == REDIS_LIST);

    // 转换成双端链表
    if (enc == REDIS_ENCODING_LINKEDLIST) {

        list *l = listCreate();

        listSetFreeMethod(l,decrRefCountVoid);

        /* listTypeGet returns a robj with incremented refcount */
        // 遍历 ziplist ，并将里面的值全部添加到双端链表中
        li = listTypeInitIterator(subject,0,REDIS_TAIL);
        while (listTypeNext(li,&entry)) listAddNodeTail(l,listTypeGet(&entry));
        listTypeReleaseIterator(li);

        // 更新编码
        subject->encoding = REDIS_ENCODING_LINKEDLIST;

        // 释放原来的 ziplist
        zfree(subject->ptr);

        // 更新对象值指针
        subject->ptr = l;

    } else {
        redisPanic("Unsupported list conversion");
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl (%rdi), %eax
andl $0xf, %eax
cmpl $0x1, %eax
jne 0x396d7
cmpl $0x4, %esi
jne 0x396f7
callq 0x2038c
movq %rax, %r14
leaq -0x90d4(%rip), %rax     # 0x3058c
movq %rax, 0x18(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x39935
movq %rax, %r15
movq %rsp, %rsi
movq %rax, %rdi
callq 0x399ca
testl %eax, %eax
je 0x396aa
movq %rsp, %r12
movq %r12, %rdi
callq 0x39a7f
movq %r14, %rdi
movq %rax, %rsi
callq 0x2045f
movq %r15, %rdi
movq %r12, %rsi
callq 0x399ca
testl %eax, %eax
jne 0x39688
movq %r15, %rdi
callq 0x2984b
movl $0xffffff0f, %eax       # imm = 0xFFFFFF0F
andl (%rbx), %eax
orl $0x40, %eax
movl %eax, (%rbx)
movq 0x8(%rbx), %rdi
callq 0x2984b
movq %r14, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x5f8ee(%rip), %rdx     # 0x98fcc
leaq 0x5f880(%rip), %rcx     # 0x98f65
xorl %edi, %edi
movq %rbx, %rsi
movl $0x1c8, %r8d            # imm = 0x1C8
callq 0x4d872
jmp 0x3970f
leaq 0x5f8ea(%rip), %rdi     # 0x98fe8
leaq 0x5f860(%rip), %rsi     # 0x98f65
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypePush
void listTypePush(robj *subject, robj *value, int where) {

    /* Check if we need to convert the ziplist */
    // 是否需要转换编码？
    listTypeTryConversion(subject,value);

    if (subject->encoding == REDIS_ENCODING_ZIPLIST &&
        ziplistLen(subject->ptr) >= server.list_max_ziplist_entries)
            listTypeConvert(subject,REDIS_ENCODING_LINKEDLIST);

    // ZIPLIST
    if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
        int pos = (where == REDIS_HEAD) ? ZIPLIST_HEAD : ZIPLIST_TAIL;
        // 取出对象的值，因为 ZIPLIST 只能保存字符串或整数
        value = getDecodedObject(value);
        subject->ptr = ziplistPush(subject->ptr,value->ptr,sdslen(value->ptr),pos);
        decrRefCount(value);

    // 双端链表
    } else if (subject->encoding == REDIS_ENCODING_LINKEDLIST) {
        if (where == REDIS_HEAD) {
            listAddNodeHead(subject->ptr,value);
        } else {
            listAddNodeTail(subject->ptr,value);
        }
        incrRefCount(value);

    // 未知编码
    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x395f4
movl $0xf0, %eax
andl (%r14), %eax
cmpl $0x50, %eax
jne 0x39762
movq 0x8(%r14), %rdi
callq 0x2c9a8
movl %eax, %eax
leaq 0x9085c(%rip), %rcx     # 0xc9fa8
cmpq %rax, 0x768(%rcx)
ja 0x39762
movq %r14, %rdi
movl $0x4, %esi
callq 0x3962c
movl (%r14), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x397b2
cmpl $0x5, %eax
jne 0x397db
xorl %r15d, %r15d
testl %ebp, %ebp
setne %r15b
movq %rbx, %rdi
callq 0x30ac3
movq %rax, %rbx
movq 0x8(%r14), %rdi
movq 0x8(%rax), %rsi
movl -0x8(%rsi), %edx
movl %r15d, %ecx
callq 0x2bc04
movq %rax, 0x8(%r14)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x30834
movq 0x8(%r14), %rdi
movq %rbx, %rsi
testl %ebp, %ebp
je 0x397c4
callq 0x2045f
jmp 0x397c9
callq 0x20400
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3041b
leaq 0x5f2a2(%rip), %rdi     # 0x98a84
leaq 0x5f77c(%rip), %rsi     # 0x98f65
movl $0x69, %edx
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypePop
robj *listTypePop(robj *subject, int where) {

    robj *value = NULL;

    // ZIPLIST
    if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
        unsigned char *p;
        unsigned char *vstr;
        unsigned int vlen;
        long long vlong;

        // 决定弹出元素的位置
        int pos = (where == REDIS_HEAD) ? 0 : -1;

        p = ziplistIndex(subject->ptr,pos);
        if (ziplistGet(p,&vstr,&vlen,&vlong)) {
            // 为被弹出元素创建对象
            if (vstr) {
                value = createStringObject((char*)vstr,vlen);
            } else {
                value = createStringObjectFromLongLong(vlong);
            }
            /* We only need to delete an element when it exists */
            // 从 ziplist 中删除被弹出元素
            subject->ptr = ziplistDelete(subject->ptr,&p);
        }

    // 双端链表
    } else if (subject->encoding == REDIS_ENCODING_LINKEDLIST) {

        list *list = subject->ptr;

        listNode *ln;

        if (where == REDIS_HEAD) {
            ln = listFirst(list);
        } else {
            ln = listLast(list);
        }

        // 删除被弹出节点
        if (ln != NULL) {
            value = listNodeValue(ln);
            incrRefCount(value);
            listDelNode(list,ln);
        }

    // 未知编码
    } else {
        redisPanic("Unknown list encoding");
    }

    // 返回节点对象
    return value;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x39869
cmpl $0x5, %eax
jne 0x398c7
xorl %r14d, %r14d
negl %esi
movl $0x0, %esi
sbbl %esi, %esi
movq 0x8(%rbx), %rdi
callq 0x2bff5
movq %rax, 0x18(%rsp)
leaq 0x10(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rax, %rdi
callq 0x2c351
testl %eax, %eax
je 0x398ba
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3989b
movl 0x4(%rsp), %esi
callq 0x303b7
jmp 0x398a5
movq 0x8(%rbx), %rbx
xorl %eax, %eax
testl %esi, %esi
setne %al
movq (%rbx,%rax,8), %r15
testq %r15, %r15
je 0x39896
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x3041b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20544
jmp 0x398ba
xorl %r14d, %r14d
jmp 0x398ba
movq 0x8(%rsp), %rdi
callq 0x303c6
movq %rax, %r14
movq 0x8(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2c46e
movq %rax, 0x8(%rbx)
movq %r14, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x5f1b6(%rip), %rdi     # 0x98a84
leaq 0x5f690(%rip), %rsi     # 0x98f65
movl $0xa7, %edx
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeLength
unsigned long listTypeLength(robj *subject) {

    // ZIPLIST
    if (subject->encoding == REDIS_ENCODING_ZIPLIST) {
        return ziplistLen(subject->ptr);

    // 双端链表
    } else if (subject->encoding == REDIS_ENCODING_LINKEDLIST) {
        return listLength((list*)subject->ptr);

    // 未知编码
    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %rax
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x4, %eax
je 0x39909
cmpl $0x5, %eax
jne 0x39913
movq 0x8(%rdi), %rdi
callq 0x2c9a8
movl %eax, %eax
jmp 0x39911
movq 0x8(%rdi), %rax
movq 0x28(%rax), %rax
popq %rcx
retq
leaq 0x5f16a(%rip), %rdi     # 0x98a84
leaq 0x5f644(%rip), %rsi     # 0x98f65
movl $0xbd, %edx
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeInitIterator
listTypeIterator *listTypeInitIterator(robj *subject, long index, unsigned char direction) {

    listTypeIterator *li = zmalloc(sizeof(listTypeIterator));

    li->subject = subject;

    li->encoding = subject->encoding;

    li->direction = direction;

    // ZIPLIST
    if (li->encoding == REDIS_ENCODING_ZIPLIST) {
        li->zi = ziplistIndex(subject->ptr,index);

    // 双端链表
    } else if (li->encoding == REDIS_ENCODING_LINKEDLIST) {
        li->ln = listIndex(subject->ptr,index);

    // 未知编码
    } else {
        redisPanic("Unknown list encoding");
    }

    return li;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movl $0x20, %edi
callq 0x29709
movq %rax, %rbx
movq %r15, (%rax)
movb (%r15), %al
shrb $0x4, %al
movb %al, 0x8(%rbx)
movb %bpl, 0x9(%rbx)
cmpb $0x4, %al
je 0x39980
movzbl %al, %eax
cmpl $0x5, %eax
jne 0x399a3
movq 0x8(%r15), %rdi
movl %r14d, %esi
callq 0x2bff5
movl $0x10, %ecx
jmp 0x39991
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x20750
movl $0x18, %ecx
movq %rax, (%rbx,%rcx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5f0da(%rip), %rdi     # 0x98a84
leaq 0x5f5b4(%rip), %rsi     # 0x98f65
movl $0xdf, %edx
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeNext
int listTypeNext(listTypeIterator *li, listTypeEntry *entry) {
    /* Protect from converting when iterating */
    redisAssert(li->subject->encoding == li->encoding);

    entry->li = li;

    // 迭代 ZIPLIST
    if (li->encoding == REDIS_ENCODING_ZIPLIST) {

        // 记录当前节点到 entry
        entry->zi = li->zi;

        // 移动迭代器的指针
        if (entry->zi != NULL) {
            if (li->direction == REDIS_TAIL)
                li->zi = ziplistNext(li->subject->ptr,li->zi);
            else
                li->zi = ziplistPrev(li->subject->ptr,li->zi);
            return 1;
        }

    // 迭代双端链表
    } else if (li->encoding == REDIS_ENCODING_LINKEDLIST) {

        // 记录当前节点到 entry
        entry->ln = li->ln;

        // 移动迭代器的指针
        if (entry->ln != NULL) {
            if (li->direction == REDIS_TAIL)
                li->ln = li->ln->next;
            else
                li->ln = li->ln->prev;
            return 1;
        }

    // 未知编码
    } else {
        redisPanic("Unknown list encoding");
    }

    // 列表元素已经全部迭代完
    return 0;
}

// Assembly:
pushq %rbx
movq (%rdi), %rcx
movl (%rcx), %edx
shrl $0x4, %edx
andl $0xf, %edx
movzbl 0x8(%rdi), %eax
cmpl %eax, %edx
jne 0x39a43
movq %rdi, %rbx
movq %rdi, (%rsi)
cmpl $0x4, %eax
je 0x39a0f
cmpl $0x5, %eax
jne 0x39a5d
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rsi)
testq %rax, %rax
je 0x39a2f
cmpb $0x1, 0x9(%rbx)
movq 0x8(%rcx), %rdi
movq %rax, %rsi
jne 0x39a33
callq 0x2c2b3
jmp 0x39a38
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rsi)
testq %rax, %rax
je 0x39a2f
xorl %ecx, %ecx
cmpb $0x1, 0x9(%rbx)
sete %cl
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rbx)
jmp 0x39a3c
xorl %eax, %eax
jmp 0x39a41
callq 0x2c2d9
movq %rax, 0x10(%rbx)
movl $0x1, %eax
popq %rbx
retq
leaq 0x5f524(%rip), %rdi     # 0x98f6e
leaq 0x5f514(%rip), %rsi     # 0x98f65
movl $0xf7, %edx
callq 0x4d037
jmp 0x39a75
leaq 0x5f020(%rip), %rdi     # 0x98a84
leaq 0x5f4fa(%rip), %rsi     # 0x98f65
movl $0x11b, %edx            # imm = 0x11B
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeGet
robj *listTypeGet(listTypeEntry *entry) {

    listTypeIterator *li = entry->li;

    robj *value = NULL;

    // 根据索引，从 ZIPLIST 中取出节点的值
    if (li->encoding == REDIS_ENCODING_ZIPLIST) {
        unsigned char *vstr;
        unsigned int vlen;
        long long vlong;
        redisAssert(entry->zi != NULL);
        if (ziplistGet(entry->zi,&vstr,&vlen,&vlong)) {
            if (vstr) {
                value = createStringObject((char*)vstr,vlen);
            } else {
                value = createStringObjectFromLongLong(vlong);
            }
        }

    // 从双端链表中取出节点的值
    } else if (li->encoding == REDIS_ENCODING_LINKEDLIST) {
        redisAssert(entry->ln != NULL);
        value = listNodeValue(entry->ln);
        incrRefCount(value);

    } else {
        redisPanic("Unknown list encoding");
    }

    return value;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq (%rdi), %rax
movzbl 0x8(%rax), %eax
cmpl $0x4, %eax
je 0x39acf
cmpl $0x5, %eax
jne 0x39b00
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x39b2f
leaq 0x18(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x2c351
testl %eax, %eax
je 0x39ae6
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x39aea
movl 0xc(%rsp), %esi
callq 0x303b7
jmp 0x39af4
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x39b1a
movq 0x10(%rax), %rbx
movq %rbx, %rdi
callq 0x3041b
jmp 0x39af7
xorl %ebx, %ebx
jmp 0x39af7
movq 0x10(%rsp), %rdi
callq 0x303c6
movq %rax, %rbx
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
retq
leaq 0x5ef7d(%rip), %rdi     # 0x98a84
leaq 0x5f457(%rip), %rsi     # 0x98f65
movl $0x143, %edx            # imm = 0x143
callq 0x4d0e5
jmp 0x39b47
leaq 0x5f485(%rip), %rdi     # 0x98fa6
leaq 0x5f43d(%rip), %rsi     # 0x98f65
movl $0x13e, %edx            # imm = 0x13E
jmp 0x39b42
leaq 0x5f45e(%rip), %rdi     # 0x98f94
leaq 0x5f428(%rip), %rsi     # 0x98f65
movl $0x133, %edx            # imm = 0x133
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeInsert
void listTypeInsert(listTypeEntry *entry, robj *value, int where) {

    robj *subject = entry->li->subject;

    // 插入到 ZIPLIST
    if (entry->li->encoding == REDIS_ENCODING_ZIPLIST) {

        // 返回对象未编码的值
        value = getDecodedObject(value);

        if (where == REDIS_TAIL) {
            unsigned char *next = ziplistNext(subject->ptr,entry->zi);

            /* When we insert after the current element, but the current element
             * is the tail of the list, we need to do a push. */
            if (next == NULL) {
                // next 是表尾节点，push 新节点到表尾
                subject->ptr = ziplistPush(subject->ptr,value->ptr,sdslen(value->ptr),REDIS_TAIL);
            } else {
                // 插入到到节点之后
                subject->ptr = ziplistInsert(subject->ptr,next,value->ptr,sdslen(value->ptr));
            }
        } else {
            subject->ptr = ziplistInsert(subject->ptr,entry->zi,value->ptr,sdslen(value->ptr));
        }
        decrRefCount(value);

    // 插入到双端链表
    } else if (entry->li->encoding == REDIS_ENCODING_LINKEDLIST) {

        if (where == REDIS_TAIL) {
            listInsertNode(subject->ptr,entry->ln,value,AL_START_TAIL);
        } else {
            listInsertNode(subject->ptr,entry->ln,value,AL_START_HEAD);
        }

        incrRefCount(value);

    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax), %r15
movzbl 0x8(%rax), %eax
cmpl $0x4, %eax
je 0x39baa
cmpl $0x5, %eax
jne 0x39c07
movq %rbx, %rdi
callq 0x30ac3
movq %rax, %rbx
movq 0x8(%r15), %rdi
movq 0x8(%r14), %rsi
cmpl $0x1, %ebp
jne 0x39bd4
callq 0x2c2b3
movq 0x8(%r15), %rdi
movq 0x8(%rbx), %rdx
movl -0x8(%rdx), %ecx
testq %rax, %rax
je 0x39bf6
movq %rax, %rsi
jmp 0x39bdb
xorl %ecx, %ecx
cmpl $0x1, %ebp
sete %cl
movq 0x8(%r15), %rdi
movq 0x10(%r14), %rsi
movq %rbx, %rdx
callq 0x204c1
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3041b
movq 0x8(%rbx), %rdx
movl -0x8(%rdx), %ecx
callq 0x2c469
movq %rax, 0x8(%r15)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x30834
movq %rdx, %rsi
movl %ecx, %edx
movl $0x1, %ecx
callq 0x2bc04
jmp 0x39be0
leaq 0x5ee76(%rip), %rdi     # 0x98a84
leaq 0x5f350(%rip), %rsi     # 0x98f65
movl $0x179, %edx            # imm = 0x179
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeEqual
int listTypeEqual(listTypeEntry *entry, robj *o) {

    listTypeIterator *li = entry->li;

    if (li->encoding == REDIS_ENCODING_ZIPLIST) {
        redisAssertWithInfo(NULL,o,sdsEncodedObject(o));
        return ziplistCompare(entry->zi,o->ptr,sdslen(o->ptr));

    } else if (li->encoding == REDIS_ENCODING_LINKEDLIST) {
        return equalStringObjects(o,listNodeValue(entry->ln));

    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %rax
movq (%rdi), %rax
movzbl 0x8(%rax), %eax
cmpl $0x4, %eax
je 0x39c55
cmpl $0x5, %eax
jne 0x39c69
movl (%rsi), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x39c83
movq 0x8(%rdi), %rdi
movq 0x8(%rsi), %rsi
movl -0x8(%rsi), %edx
popq %rax
jmp 0x2c64f
movq 0x10(%rdi), %rax
movq 0x10(%rax), %rax
movq %rsi, %rdi
movq %rax, %rsi
popq %rax
jmp 0x30c35
leaq 0x5ee14(%rip), %rdi     # 0x98a84
leaq 0x5f2ee(%rip), %rsi     # 0x98f65
movl $0x18f, %edx            # imm = 0x18F
callq 0x4d0e5
jmp 0x39c9e
leaq 0x5f32e(%rip), %rdx     # 0x98fb8
leaq 0x5f2d4(%rip), %rcx     # 0x98f65
xorl %edi, %edi
movl $0x188, %r8d            # imm = 0x188
callq 0x4d872
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: listTypeDelete
void listTypeDelete(listTypeEntry *entry) {

    listTypeIterator *li = entry->li;

    // ZIPLIST
    if (li->encoding == REDIS_ENCODING_ZIPLIST) {

        unsigned char *p = entry->zi;

        li->subject->ptr = ziplistDelete(li->subject->ptr,&p);

        /* Update position of the iterator depending on the direction */
        // 删除节点之后，更新迭代器的指针
        if (li->direction == REDIS_TAIL)
            li->zi = p;
        else
            li->zi = ziplistPrev(li->subject->ptr,p);

    // 双端链表
    } else if (entry->li->encoding == REDIS_ENCODING_LINKEDLIST) {

        // 记录后置节点
        listNode *next;

        if (li->direction == REDIS_TAIL)
            next = entry->ln->next;
        else
            next = entry->ln->prev;

        // 删除当前节点
        listDelNode(li->subject->ptr,entry->ln);

        // 删除节点之后，更新迭代器的指针
        li->ln = next;

    } else {
        redisPanic("Unknown list encoding");
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %r14
movzbl 0x8(%r14), %eax
cmpl $0x4, %eax
je 0x39cf9
cmpl $0x5, %eax
jne 0x39d23
movq 0x8(%rdi), %rax
movq %rsp, %rbx
movq %rax, (%rbx)
movq (%r14), %rax
movq 0x8(%rax), %rdi
movq %rbx, %rsi
callq 0x2c46e
movq %rax, %rdi
movq (%r14), %rax
movq %rdi, 0x8(%rax)
cmpb $0x1, 0x9(%r14)
movq (%rbx), %rax
je 0x39cf3
movq %rax, %rsi
callq 0x2c2d9
movq %rax, 0x10(%r14)
jmp 0x39d1b
xorl %eax, %eax
cmpb $0x1, 0x9(%r14)
sete %al
movq 0x10(%rdi), %rsi
movq (%rsi,%rax,8), %rbx
movq (%r14), %rax
movq 0x8(%rax), %rdi
callq 0x20544
movq %rbx, 0x18(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x5ed5a(%rip), %rdi     # 0x98a84
leaq 0x5f234(%rip), %rsi     # 0x98f65
movl $0x1bb, %edx            # imm = 0x1BB
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: pushGenericCommand
void pushGenericCommand(redisClient *c, int where) {

    int j, waiting = 0, pushed = 0;

    // 取出列表对象
    robj *lobj = lookupKeyWrite(c->db,c->argv[1]);

    // 如果列表对象不存在，那么可能有客户端在等待这个键的出现
    int may_have_waiting_clients = (lobj == NULL);

    if (lobj && lobj->type != REDIS_LIST) {
        addReply(c,shared.wrongtypeerr);
        return;
    }

    // 将列表状态设置为就绪
    if (may_have_waiting_clients) signalListAsReady(c,c->argv[1]);

    // 遍历所有输入值，并将它们添加到列表中
    for (j = 2; j < c->argc; j++) {

        // 编码值
        c->argv[j] = tryObjectEncoding(c->argv[j]);

        // 如果列表对象不存在，那么创建一个，并关联到数据库
        if (!lobj) {
            lobj = createZiplistObject();
            dbAdd(c->db,c->argv[1],lobj);
        }

        // 将值推入到列表
        listTypePush(lobj,c->argv[j],where);

        pushed++;
    }

    // 返回添加的节点数量
    addReplyLongLong(c, waiting + (lobj ? listTypeLength(lobj) : 0));

    // 如果至少有一个元素被成功推入，那么执行以下代码
    if (pushed) {
        char *event = (where == REDIS_HEAD) ? "lpush" : "rpush";

        // 发送键修改信号
        signalModifiedKey(c->db,c->argv[1]);

        // 发送事件通知
        notifyKeyspaceEvent(REDIS_NOTIFY_LIST,event,c->argv[1],c->db->id);
    }

    server.dirty += pushed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31454
movq %rax, %r14
testq %rax, %rax
je 0x39d7e
movl (%r14), %eax
andl $0xf, %eax
cmpl $0x1, %eax
jne 0x39e07
testq %r14, %r14
jne 0x39d8e
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x39e90
xorl %r15d, %r15d
cmpl $0x3, 0x30(%rbx)
jl 0x39df5
movl $0x2, %r15d
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x30971
movq 0x38(%rbx), %rcx
movq %rax, (%rcx,%r15,8)
testq %r14, %r14
jne 0x39dd3
callq 0x30591
movq %rax, %r14
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r14, %rdx
callq 0x314ef
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x39719
incq %r15
movslq 0x30(%rbx), %rax
cmpq %rax, %r15
jl 0x39d9d
addl $-0x2, %r15d
testq %r14, %r14
je 0x39e24
movq %r14, %rdi
callq 0x398e9
movq %rax, %rsi
jmp 0x39e26
leaq 0x909f2(%rip), %rax     # 0xca800
movq 0x70(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2d6f0
xorl %esi, %esi
movq %rbx, %rdi
callq 0x2dea3
testl %r15d, %r15d
je 0x39e74
testl %ebp, %ebp
leaq 0x5a49b(%rip), %rax     # 0x942d7
leaq 0x5a46a(%rip), %r14     # 0x942ad
cmoveq %rax, %r14
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x316b7
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
movl $0x10, %edi
movq %r14, %rsi
callq 0x608b5
movl %r15d, %eax
leaq 0x9012a(%rip), %rcx     # 0xc9fa8
addq %rax, 0x560(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: signalListAsReady
void signalListAsReady(redisClient *c, robj *key) {
    readyList *rl;

    /* No clients blocking for this key? No need to queue it. */
    // 没有客户端被这个键阻塞，直接返回
    if (dictFind(c->db->blocking_keys,key) == NULL) return;

    /* Key was already signaled? No need to queue it again. */
    // 这个键已经被添加到 ready_keys 中了，直接返回
    if (dictFind(c->db->ready_keys,key) != NULL) return;

    /* Ok, we need to queue this key into server.ready_keys. */
    // 创建一个 readyList 结构，保存键和数据库
    // 然后将 readyList 添加到 server.ready_keys 中
    rl = zmalloc(sizeof(*rl));
    rl->key = key;
    rl->db = c->db;
    incrRefCount(key);
    listAddNodeTail(server.ready_keys,rl);

    /* We also add the key in the db->ready_keys dictionary in order
     * to avoid adding it multiple times into a list with a simple O(1)
     * check. 
     *
     * 将 key 添加到 c->db->ready_keys 集合中，防止重复添加
     */
    incrRefCount(key);
    redisAssert(dictAdd(c->db->ready_keys,key,NULL) == DICT_OK);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x10(%rax), %rdi
callq 0x224dc
testq %rax, %rax
je 0x39f16
movq 0x8(%r14), %rax
movq 0x18(%rax), %rdi
movq %rbx, %rsi
callq 0x224dc
testq %rax, %rax
jne 0x39f16
movl $0x10, %edi
callq 0x29709
movq %rax, %r15
movq %rbx, 0x8(%rax)
movq 0x8(%r14), %rax
movq %rax, (%r15)
movq %rbx, %rdi
callq 0x3041b
leaq 0x900bf(%rip), %rax     # 0xc9fa8
movq 0x740(%rax), %rdi
movq %r15, %rsi
callq 0x2045f
movq %rbx, %rdi
callq 0x3041b
movq 0x8(%r14), %rax
movq 0x18(%rax), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x222b6
testl %eax, %eax
jne 0x39f1c
popq %rbx
popq %r14
popq %r15
retq
leaq 0x5f145(%rip), %rdi     # 0x99068
leaq 0x5f03b(%rip), %rsi     # 0x98f65
movl $0x4f5, %edx            # imm = 0x4F5
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/t_list.c
// Function: linsertCommand
void linsertCommand(redisClient *c) {

    // 编码 refval 对象
    c->argv[4] = tryObjectEncoding(c->argv[4]);

    if (strcasecmp(c->argv[2]->ptr,"after") == 0) {
        pushxGenericCommand(c,c->argv[3],c->argv[4],REDIS_TAIL);

    } else if (strcasecmp(c->argv[2]->ptr,"before") == 0) {
        pushxGenericCommand(c,c->argv[3],c->argv[4],REDIS_HEAD);

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

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x20(%rax), %rdi
callq 0x30971
movq 0x38(%rbx), %rcx
movq %rax, 0x20(%rcx)
movq 0x38(%rbx), %r15
movq 0x10(%r15), %rax
movq 0x8(%rax), %r14
leaq 0x5ee7e(%rip), %rsi     # 0x99006
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x3a1c2
leaq 0x5ee71(%rip), %rsi     # 0x9900c
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x3a1d4
leaq 0x90652(%rip), %rax     # 0xca800
movq 0x80(%rax), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2d6f0
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
jmp 0x3a1e1
movq 0x18(%r15), %rsi
movq 0x20(%r15), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
popq %rbx
popq %r14
popq %r15
jmp 0x39f4f