LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hmsetCommand
void hmsetCommand(redisClient *c) {
    int i;
    robj *o;

    // field-value 参数必须成对出现
    if ((c->argc % 2) == 1) {
        addReplyError(c,"wrong number of arguments for HMSET");
        return;
    }

    // 取出或新创建哈希对象
    if ((o = hashTypeLookupWriteOrCreate(c,c->argv[1])) == NULL) return;

    // 如果需要的话，转换哈希对象的编码
    hashTypeTryConversion(o,c->argv,2,c->argc-1);

    // 遍历并设置所有 field-value 对
    for (i = 2; i < c->argc; i += 2) {
        // 编码 field-value 对，以节约空间
        hashTypeTryObjectEncoding(o,&c->argv[i], &c->argv[i+1]);
        // 设置
        hashTypeSet(o,c->argv[i],c->argv[i+1]);
    }

    // 向客户端发送回复
    addReply(c, shared.ok);

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

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

    // 将数据库设为脏
    server.dirty++;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x80000001, %eax       # imm = 0x80000001
andl 0x30(%rdi), %eax
cmpl $0x1, %eax
jne 0x3fbf5
leaq 0x4fa75(%rip), %rsi     # 0x8f657
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2c2da
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x3f894
testq %rax, %rax
je 0x3fcbc
movq %rax, %r14
movq 0x38(%rbx), %rsi
movl 0x30(%rbx), %ecx
decl %ecx
pushq $0x2
popq %rdx
movq %rax, %rdi
callq 0x3efc0
pushq $0x2
popq %r15
pushq $0x18
popq %r12
movslq 0x30(%rbx), %rax
cmpq %rax, %r15
jge 0x3fc6c
movq 0x38(%rbx), %rdx
leaq (%rdx,%r12), %rsi
addq $-0x8, %rsi
addq %r12, %rdx
movq %r14, %rdi
callq 0x3f05f
movq 0x38(%rbx), %rax
movq -0x8(%rax,%r12), %rsi
movq (%rax,%r12), %rdx
movq %r14, %rdi
callq 0x3f300
addq $0x2, %r15
addq $0x10, %r12
jmp 0x3fc2d
leaq 0x87b8d(%rip), %rax     # 0xc7800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x2c10d
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fbc0
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x4a7c4(%rip), %rsi     # 0x8a46a
pushq $0x40
popq %rdi
callq 0x5b488
leaq 0x872f3(%rip), %rax     # 0xc6fa8
incq 0x560(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hgetCommand
void hgetCommand(redisClient *c) {
    robj *o;

    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.nullbulk)) == NULL ||
        checkType(c,o,REDIS_HASH)) return;

    // 取出并返回域的值
    addHashFieldToReply(c, o, c->argv[2]);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x87858(%rip), %rax     # 0xc7800
movq 0x50(%rax), %rdx
callq 0x2f9a9
testq %rax, %rax
je 0x3ffcb
movq %rax, %r14
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
je 0x3ffd3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3ffea
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: addHashFieldToReply
static void addHashFieldToReply(redisClient *c, robj *o, robj *field) {
    int ret;

    // 对象不存在
    if (o == NULL) {
        addReply(c, shared.nullbulk);
        return;
    }

    // ziplist 编码
    if (o->encoding == REDIS_ENCODING_ZIPLIST) {
        unsigned char *vstr = NULL;
        unsigned int vlen = UINT_MAX;
        long long vll = LLONG_MAX;

        // 取出值
        ret = hashTypeGetFromZiplist(o, field, &vstr, &vlen, &vll);
        if (ret < 0) {
            addReply(c, shared.nullbulk);
        } else {
            if (vstr) {
                addReplyBulkCBuffer(c, vstr, vlen);
            } else {
                addReplyBulkLongLong(c, vll);
            }
        }

    // 字典
    } else if (o->encoding == REDIS_ENCODING_HT) {
        robj *value;

        // 取出值
        ret = hashTypeGetFromHashTable(o, field, &value);
        if (ret < 0) {
            addReply(c, shared.nullbulk);
        } else {
            addReplyBulk(c, value);
        }

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

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
je 0x4005a
movl (%rsi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
je 0x40072
cmpl $0x5, %eax
jne 0x400c0
leaq 0x8(%rsp), %rax
andq $0x0, (%rax)
leaq 0x14(%rsp), %rcx
orl $-0x1, (%rcx)
movabsq $0x7fffffffffffffff, %rdi # imm = 0x7FFFFFFFFFFFFFFF
leaq 0x18(%rsp), %r8
movq %rdi, (%r8)
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x3f09d
testl %eax, %eax
js 0x40098
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x400ad
movl 0x14(%rsp), %edx
movq %rbx, %rdi
callq 0x2c87d
jmp 0x400ba
leaq 0x8779f(%rip), %rax     # 0xc7800
movq 0x50(%rax), %rsi
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
jmp 0x2c10d
leaq 0x8(%rsp), %rax
movq %rsi, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x3f18d
testl %eax, %eax
js 0x40098
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2c84a
jmp 0x400ba
leaq 0x87761(%rip), %rax     # 0xc7800
movq 0x50(%rax), %rsi
movq %rbx, %rdi
callq 0x2c10d
jmp 0x400ba
movq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x2c8bb
addq $0x20, %rsp
popq %rbx
retq
leaq 0x4ea0c(%rip), %rdi     # 0x8ead3
leaq 0x4f4b8(%rip), %rsi     # 0x8f586
movl $0x3c1, %edx            # imm = 0x3C1
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hdelCommand
void hdelCommand(redisClient *c) {
    robj *o;
    int j, deleted = 0, keyremoved = 0;

    // 取出对象
    if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_HASH)) return;

    // 删除指定域值对
    for (j = 2; j < c->argc; j++) {
        if (hashTypeDelete(o,c->argv[j])) {

            // 成功删除一个域值对时进行计数
            deleted++;

            // 如果哈希已经为空，那么删除这个对象
            if (hashTypeLength(o) == 0) {
                dbDelete(c->db,c->argv[1]);
                keyremoved = 1;
                break;
            }
        }
    }

    // 只要有至少一个域值对被修改了，那么执行以下代码
    if (deleted) {
        // 发送键修改信号
        signalModifiedKey(c->db,c->argv[1]);

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

        // 发送事件通知
        if (keyremoved)
            notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",c->argv[1],
                                c->db->id);

        // 将数据库设为脏
        server.dirty += deleted;
    }

    // 将成功删除的域值对数量作为结果返回给客户端
    addReplyLongLong(c,deleted);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x87687(%rip), %rax     # 0xc7800
movq 0x20(%rax), %rdx
callq 0x2f9d9
testq %rax, %rax
je 0x4019c
movq %rax, %r14
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
je 0x401a5
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
pushq $0x2
popq %r15
movslq 0x30(%rbx), %r12
cmpq %r12, %r15
jge 0x401ed
movq 0x38(%rbx), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0x3f4d6
testl %eax, %eax
je 0x401d7
incl %ebp
movq %r14, %rdi
callq 0x3f488
testq %rax, %rax
je 0x401dc
incq %r15
jmp 0x401ab
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fc3b
testl %ebp, %ebp
je 0x40256
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x2fbc0
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x4a284(%rip), %rsi     # 0x8a49c
pushq $0x40
popq %rdi
callq 0x5b488
cmpq %r12, %r15
jge 0x40243
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x4a262(%rip), %rsi     # 0x8a49d
pushq $0x4
popq %rdi
callq 0x5b488
movslq %ebp, %rsi
leaq 0x86d5b(%rip), %rax     # 0xc6fa8
addq %rsi, 0x560(%rax)
jmp 0x40258
xorl %esi, %esi
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2c794
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hlenCommand
void hlenCommand(redisClient *c) {
    robj *o;

    // 取出哈希对象
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_HASH)) return;

    // 回复
    addReplyLongLong(c,hashTypeLength(o));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x87582(%rip), %rax     # 0xc7800
movq 0x20(%rax), %rdx
callq 0x2f9a9
testq %rax, %rax
je 0x402a1
movq %rax, %r14
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
je 0x402a9
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
callq 0x3f488
movq %rbx, %rdi
movq %rax, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2c794
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: genericHgetallCommand
void genericHgetallCommand(redisClient *c, int flags) {
    robj *o;
    hashTypeIterator *hi;
    int multiplier = 0;
    int length, count = 0;

    // 取出哈希对象
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptymultibulk)) == NULL
        || checkType(c,o,REDIS_HASH)) return;

    // 计算要取出的元素数量
    if (flags & REDIS_HASH_KEY) multiplier++;
    if (flags & REDIS_HASH_VALUE) multiplier++;

    length = hashTypeLength(o) * multiplier;

    addReplyMultiBulkLen(c, length);

    // 迭代节点，并取出元素
    hi = hashTypeInitIterator(o);
    while (hashTypeNext(hi) != REDIS_ERR) {
        // 取出键
        if (flags & REDIS_HASH_KEY) {
            addHashIteratorCursorToReply(c, hi, REDIS_HASH_KEY);
            count++;
        }
        // 取出值
        if (flags & REDIS_HASH_VALUE) {
            addHashIteratorCursorToReply(c, hi, REDIS_HASH_VALUE);
            count++;
        }
    }

    // 释放迭代器
    hashTypeReleaseIterator(hi);
    redisAssert(count == length);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x8751d(%rip), %rax     # 0xc7800
movq 0x68(%rax), %rdx
callq 0x2f9a9
testq %rax, %rax
je 0x4038f
movq %rax, %r12
pushq $0x4
popq %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
jne 0x4038f
movl %r15d, %ebx
andl $0x1, %ebx
andl $0x2, %r15d
movl %r15d, %ebp
shrl %ebp
addl %ebx, %ebp
movq %r12, %rdi
callq 0x3f488
imull %ebp, %eax
movq %rax, (%rsp)
movslq %eax, %rsi
movq %r14, %rdi
callq 0x2c7c7
movq %r12, %rdi
callq 0x3f5c0
movq %rax, %r12
xorl %ebp, %ebp
pushq $0x1
popq %r13
movq %r12, %rdi
callq 0x3f648
cmpl $-0x1, %eax
je 0x40382
testl %ebx, %ebx
je 0x4036b
movq %r14, %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x403be
incl %ebp
testl %r15d, %r15d
je 0x4034a
movq %r14, %rdi
movq %r12, %rsi
pushq $0x2
popq %rdx
callq 0x403be
incl %ebp
jmp 0x4034a
movq %r12, %rdi
callq 0x3f62c
cmpl (%rsp), %ebp
jne 0x4039e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4f318(%rip), %rdi     # 0x8f6bd
leaq 0x4f1da(%rip), %rsi     # 0x8f586
movl $0x45e, %edx            # imm = 0x45E
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: addHashIteratorCursorToReply
static void addHashIteratorCursorToReply(redisClient *c, hashTypeIterator *hi, int what) {

    // 处理 ZIPLIST
    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) {
            addReplyBulkCBuffer(c, vstr, vlen);
        } else {
            addReplyBulkLongLong(c, vll);
        }

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

        hashTypeCurrentFromHashTable(hi, what, &value);
        addReplyBulk(c, value);

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

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x8(%rsi), %eax
cmpl $0x2, %eax
je 0x4041b
cmpl $0x5, %eax
jne 0x4044f
leaq 0x10(%rsp), %r14
andq $0x0, (%r14)
leaq 0x4(%rsp), %rcx
orl $-0x1, (%rcx)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x3f732
movq (%r14), %rsi
testq %rsi, %rsi
je 0x4043a
movl 0x4(%rsp), %edx
movq %rbx, %rdi
callq 0x2c87d
jmp 0x40447
leaq 0x10(%rsp), %r14
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x3f7b7
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x2c84a
jmp 0x40447
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x2c8bb
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x4e67d(%rip), %rdi     # 0x8ead3
leaq 0x4f129(%rip), %rsi     # 0x8f586
movl $0x437, %edx            # imm = 0x437
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hexistsCommand
void hexistsCommand(redisClient *c) {
    robj *o;

    // 取出哈希对象
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_HASH)) return;

    // 检查给定域是否存在
    addReply(c, hashTypeExists(o,c->argv[2]) ? shared.cone : shared.czero);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x87362(%rip), %r15     # 0xc7800
movq 0x20(%r15), %rdx
callq 0x2f9a9
testq %rax, %rax
je 0x404c1
movq %rax, %r14
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
je 0x404c7
popq %rbx
popq %r14
popq %r15
retq
movq 0x38(%rbx), %rax
movq 0x10(%rax), %rsi
movq %r14, %rdi
callq 0x3f28a
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movq 0x20(%r15,%rcx,8), %rsi
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2c10d
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/t_hash.c
// Function: hscanCommand
void hscanCommand(redisClient *c) {
    robj *o;
    unsigned long cursor;

    if (parseScanCursorOrReply(c,c->argv[2],&cursor) == REDIS_ERR) return;
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.emptyscan)) == NULL ||
        checkType(c,o,REDIS_HASH)) return;
    scanGenericCommand(c,o,cursor);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rsi
movq %rsp, %rdx
callq 0x302a1
cmpl $-0x1, %eax
je 0x40553
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x872e5(%rip), %rax     # 0xc7800
movq 0x148(%rax), %rdx
movq %rbx, %rdi
callq 0x2f9a9
testq %rax, %rax
je 0x40553
movq %rax, %r14
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2eec6
testl %eax, %eax
jne 0x40553
movq (%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30317
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/config.c
// Function: loadServerConfig
void loadServerConfig(char *filename, char *options) {
    sds config = sdsempty();
    char buf[REDIS_CONFIGLINE_MAX+1];

    /* Load the file content */
    // 载入文件内容
    if (filename) {
        FILE *fp;

        if (filename[0] == '-' && filename[1] == '\0') {
            fp = stdin;
        } else {
            if ((fp = fopen(filename,"r")) == NULL) {
                redisLog(REDIS_WARNING,
                    "Fatal error, can't open config file '%s'", filename);
                exit(1);
            }
        }
        while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL)
            config = sdscat(config,buf);
        if (fp != stdin) fclose(fp);
    }

    /* Append the additional options */
    // 追加 options 字符串到内容的末尾
    if (options) {
        config = sdscat(config,"\n");
        config = sdscat(config,options);
    }

    // 根据字符串内容，设置服务器配置
    loadServerConfigFromString(config);

    sdsfree(config);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movq %rdi, %r12
callq 0x271bf
movq %rax, %r14
testq %r12, %r12
je 0x41c31
cmpb $0x2d, (%r12)
jne 0x41bda
cmpb $0x0, 0x1(%r12)
je 0x41c72
leaq 0x4aff2(%rip), %rsi     # 0x8cbd3
movq %r12, %rdi
callq 0x1fa60
movq %rax, %r15
testq %rax, %rax
je 0x41c81
movq %rsp, %r12
movq %r12, %rdi
movl $0x401, %esi            # imm = 0x401
movq %r15, %rdx
callq 0x1f430
testq %rax, %rax
je 0x41c1d
movq %r14, %rdi
movq %r12, %rsi
callq 0x273bf
movq %rax, %r14
jmp 0x41bf8
movq 0x8134c(%rip), %rax     # 0xc2f70
cmpq (%rax), %r15
je 0x41c31
movq %r15, %rdi
callq 0x1f9a0
testq %rbx, %rbx
je 0x41c53
leaq 0x4ab14(%rip), %rsi     # 0x8c751
movq %r14, %rdi
callq 0x273bf
movq %rax, %rdi
movq %rbx, %rsi
callq 0x273bf
movq %rax, %r14
movq %r14, %rdi
callq 0x40609
movq %r14, %rdi
callq 0x271f7
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x812f7(%rip), %rax     # 0xc2f70
movq (%rax), %r15
jmp 0x41bf5
leaq 0x4e4b1(%rip), %rsi     # 0x90139
pushq $0x3
popq %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x22613
pushq $0x1
popq %rdi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/config.c
// Function: rewriteConfigStringOption
void rewriteConfigStringOption(struct rewriteConfigState *state, char *option, char *value, char *defvalue) {
    int force = 1;
    sds line;

    /* String options set to NULL need to be not present at all in the
     * configuration file to be set to NULL again at the next reboot. */
    if (value == NULL) {
        rewriteConfigMarkAsProcessed(state,option);
        return;
    }

    /* Compare the strings as sds strings to have a binary safe comparison. */
    if (defvalue && strcmp(value,defvalue) == 0) force = 0;

    line = sdsnew(option);
    line = sdscatlen(line, " ", 1);
    line = sdscatrepr(line, value, strlen(value));

    rewriteConfigRewriteLine(state,option,line,force);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
je 0x448e1
movq %rdx, %r15
testq %rcx, %rcx
je 0x448f4
movq %r15, %rdi
movq %rcx, %rsi
callq 0x1f880
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
jmp 0x448f7
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x444d1
pushq $0x1
popq %rbp
movq %rbx, %rdi
callq 0x271cd
leaq 0x4bacd(%rip), %rsi     # 0x903d3
pushq $0x1
popq %rdx
movq %rax, %rdi
callq 0x2736d
movq %rax, %r12
movq %r15, %rdi
callq 0x1f4f0
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x27d51
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl %ebp, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x446a9
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/config.c
// Function: rewriteConfigEnumOption
void rewriteConfigEnumOption(struct rewriteConfigState *state, char *option, int value, ...) {
    va_list ap;
    char *enum_name, *matching_name = NULL;
    int enum_val, def_val, force;
    sds line;
    
    va_start(ap, value);
    while(1) {
        enum_name = va_arg(ap,char*);
        enum_val = va_arg(ap,int);
        if (enum_name == NULL) {
            def_val = enum_val;
            break;
        }
        if (value == enum_val) matching_name = enum_name;
    }
    va_end(ap);
    
    force = value != def_val;
    line = sdscatprintf(sdsempty(),"%s %s",option,matching_name);
    rewriteConfigRewriteLine(state,option,line,force);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsp), %rsi
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x44a3c
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsi, 0x10(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000018, %rcx     # imm = 0x3000000018
movq %rcx, (%rsp)
pushq $0x18
popq %rcx
xorl %r15d, %r15d
cmpl $0x29, %ecx
jae 0x44a88
movl %ecx, %edi
leal 0x8(%rcx), %r8d
movl %r8d, (%rsp)
movq (%rsi,%rdi), %rdi
cmpl $0x20, %ecx
ja 0x44a99
movl %r8d, %r8d
addq %rsi, %r8
addl $0x10, %ecx
movl %ecx, (%rsp)
jmp 0x44aa8
leaq 0x8(%rax), %r8
movq %r8, 0x8(%rsp)
movq (%rax), %rdi
movq %r8, %rax
jmp 0x44a9c
movl %r8d, %ecx
movq %rax, %r8
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl (%r8), %r8d
testq %rdi, %rdi
je 0x44ab9
cmpl %edx, %r8d
cmoveq %rdi, %r15
jmp 0x44a62
xorl %ebp, %ebp
cmpl %edx, %r8d
setne %bpl
callq 0x271bf
leaq 0x5110e(%rip), %rsi     # 0x95bdc
movq %rax, %rdi
movq %rbx, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2763d
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movl %ebp, %ecx
callq 0x446a9
addq $0xd8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x8249b(%rip), %rax     # 0xc6fa8
movl 0x5e8(%rax), %eax
pushq $0x8
popq %rdx
leaq 0x7b813(%rip), %rcx     # 0xc0330
movq %rdx, %rsi
addq $0x10, %rdx
cmpq $0xa8, %rdx
je 0x44b32
cmpl %eax, (%rsi,%rcx)
jne 0x44b1d
movq -0x8(%rsi,%rcx), %r14
xorl %ebp, %ebp
cmpl $0x80, %eax
setne %bpl
callq 0x271bf
leaq 0x5108e(%rip), %rsi     # 0x95bdc
leaq 0x4ad5d(%rip), %r15     # 0x8f8b2
movq %rax, %rdi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2763d
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
movl %ebp, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x446a9
// File: /workspace/github_c_makefile_star2_O2/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 0x81d59(%rip), %rbp     # 0xc6ac0
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq $0x3, %r13
je 0x44e3b
leaq 0x8222a(%rip), %r14     # 0xc6fa8
movq 0x488(%r14,%r12), %rdx
pushq $0x1
popq %rbx
cmpq (%r12,%rbp), %rdx
jne 0x44db0
movq 0x490(%r14,%r12), %rax
cmpq 0x8(%r12,%rbp), %rax
jne 0x44db0
movq 0x498(%r14,%r12), %rax
xorl %ebx, %ebx
cmpq 0x10(%r12,%rbp), %rax
setne %bl
leaq 0x50(%rsp), %rdi
pushq $0x40
popq %r15
movq %r15, %rsi
callq 0x44785
movq 0x490(%r14,%r12), %rdx
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x44785
callq 0x271bf
movq %r14, %r15
movq %rax, %r14
movl %r13d, %edi
callq 0x2df9a
movq 0x498(%r15,%r12), %rcx
movq %rcx, (%rsp)
movq %r14, %rdi
leaq 0x4b62a(%rip), %rsi     # 0x90429
leaq 0x4b0ff(%rip), %r14     # 0x8ff05
movq %r14, %rdx
movq %rax, %rcx
leaq 0x50(%rsp), %r8
leaq 0x10(%rsp), %r9
xorl %eax, %eax
callq 0x2763d
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
movl %ebx, %ecx
callq 0x446a9
incq %r13
addq $0x18, %r12
jmp 0x44d6d
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/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 0x45c82(%rip), %rsi     # 0x8b4ee
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x458c7
leaq 0x44bf8(%rip), %rsi     # 0x8a477
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x458e0
leaq 0x4abc0(%rip), %rsi     # 0x90452
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x458f5
leaq 0x4a3bd(%rip), %rsi     # 0x8fc62
movq %r14, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x4591f
leaq 0x4ac2a(%rip), %rsi     # 0x904e2
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2c2da
cmpl $0x4, 0x30(%rbx)
jne 0x45951
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x41c9d
cmpl $0x3, 0x30(%rbx)
jne 0x45951
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x42fc5
cmpl $0x2, 0x30(%rbx)
jne 0x45951
callq 0x2450d
callq 0x24ae9
leaq 0x81ef4(%rip), %rax     # 0xc7800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2c10d
cmpl $0x2, 0x30(%rbx)
jne 0x45951
leaq 0x8167c(%rip), %rax     # 0xc6fa8
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4596c
callq 0x45127
cmpl $-0x1, %eax
je 0x45978
leaq 0x4ab77(%rip), %rsi     # 0x904bc
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x22613
jmp 0x45905
leaq 0x4abc8(%rip), %rsi     # 0x90520
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2c301
leaq 0x4aae9(%rip), %rsi     # 0x9045c
jmp 0x458b8
callq 0x1f810
movq %rax, %r14
movl (%rax), %edi
callq 0x1f630
leaq 0x4aafa(%rip), %rsi     # 0x90488
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x22613
movl (%r14), %edi
callq 0x1f630
leaq 0x4aaf8(%rip), %rsi     # 0x904a2
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x4595e
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x815bb(%rip), %rax     # 0xc6fa8
movq 0x508(%rax), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x45a1b
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
je 0x45a1b
imulq $0xa00000, 0x28(%rax), %rax # imm = 0xA00000
movq (%rcx), %rcx
addq %rcx, %rax
addq $-0xa00000, %rax        # imm = 0xFF600000
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x81466(%rip), %rax     # 0xc6fa8
movq 0x508(%rax), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x1ffac
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x1ffc6
testq %rax, %rax
je 0x45b99
movq 0x10(%rax), %r15
movq (%r15), %rdx
testq %rdx, %rdx
je 0x45b58
leaq 0x10(%r15), %rsi
movl %ebp, %edi
callq 0x1fb30
cmpq (%r15), %rax
jne 0x45b86
addq %rax, %rbx
jmp 0x45b58
pushq $-0x1
popq %rbx
testq %rax, %rax
jne 0x45b99
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_O2/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 %rbx
subq $0x10, %rsp
leaq 0x813e6(%rip), %rbx     # 0xc6fa8
cmpl $0x0, 0x4d0(%rbx)
je 0x45c60
pushq $0x1
popq %rdi
callq 0x45c80
movl 0x518(%rbx), %edi
callq 0x1f560
movl 0x518(%rbx), %edi
callq 0x1f170
orq $-0x1, 0x518(%rbx)
andl $0x0, 0x4d0(%rbx)
movslq 0x504(%rbx), %rdx
cmpq $-0x1, %rdx
je 0x45c5a
leaq 0x4aa0b(%rip), %rsi     # 0x9061b
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x22613
movl 0x504(%rbx), %edi
pushq $0xa
popq %rsi
callq 0x1f620
cmpl $-0x1, %eax
je 0x45c3b
leaq 0xc(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1f800
callq 0x459b4
movl 0x504(%rbx), %edi
callq 0x45f6e
orl $-0x1, 0x504(%rbx)
orq $-0x1, 0x538(%rbx)
addq $0x10, %rsp
popq %rbx
retq
leaq 0x4a98c(%rip), %rdi     # 0x905f3
leaq 0x4a9a7(%rip), %rsi     # 0x90615
movl $0xed, %edx
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x80ffe(%rip), %rbx     # 0xc6fa8
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 0x4603f
cmpl $-0x1, %eax
je 0x45ffc
callq 0x4605f
cmpl $-0x1, %eax
je 0x4601e
movl $0x2, 0x4d0(%rbx)
xorl %eax, %eax
jmp 0x4603d
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x4a655(%rip), %rsi     # 0x90664
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x22613
jmp 0x4603a
movl 0x518(%rbx), %edi
callq 0x1f170
leaq 0x4a67a(%rip), %rsi     # 0x906aa
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0x22613
pushq $-0x1
popq %rax
popq %rbx
retq
leaq 0x4a5fc(%rip), %rdi     # 0x90642
leaq 0x4a5c8(%rip), %rsi     # 0x90615
movl $0x125, %edx            # imm = 0x125
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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
movq %rdi, %r14
leaq 0x1(%rsp), %rdi
movb $0x2a, -0x1(%rdi)
movslq %esi, %r15
pushq $0x1f
popq %rsi
movq %r15, %rdx
callq 0x2e511
cltq
movq %rsp, %r13
movw $0xa0d, 0x1(%rax,%r13)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2736d
movq %rax, %r12
xorl %r14d, %r14d
testl %r15d, %r15d
cmovlel %r14d, %r15d
cmpq %r14, %r15
je 0x46270
movq (%rbx,%r14,8), %rdi
callq 0x2f087
movq %rax, %rbp
movb $0x24, (%rsp)
movq 0x8(%rax), %rax
movslq -0x8(%rax), %rdx
leaq 0x1(%rsp), %rdi
pushq $0x1f
popq %rsi
callq 0x2e511
cltq
movw $0xa0d, 0x1(%rax,%r13)  # imm = 0xA0D
addl $0x3, %eax
movslq %eax, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2736d
movq 0x8(%rbp), %rsi
movslq -0x8(%rsi), %rdx
movq %rax, %rdi
callq 0x2736d
movq %rax, %rdi
leaq 0x4947b(%rip), %rsi     # 0x8f6d3
pushq $0x2
popq %rdx
callq 0x2736d
movq %rax, %r12
movq %rbp, %rdi
callq 0x2ee1f
incq %r14
jmp 0x461f9
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/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 0x2f087
movq %rax, %r12
movq 0x8(%rax), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x1fa70
movq %rax, %r15
movq 0x8(%r13), %rax
imulq $0x3e8, %r15, %rcx      # imm = 0x3E8
cmpq 0x7cd12(%rip), %rax     # 0xc2fd8
leaq -0x10029(%rip), %rdx    # 0x362a4
cmoveq %rcx, %r15
cmpq %rdx, %rax
cmoveq %rcx, %r15
cmpq 0x7cc29(%rip), %rax     # 0xc2f08
cmoveq %rcx, %r15
cmpq %rdx, %rax
je 0x46303
cmpq 0x7cc19(%rip), %rax     # 0xc2f08
je 0x46303
cmpq 0x7ccb8(%rip), %rax     # 0xc2fb0
je 0x46303
cmpq 0x7cc7f(%rip), %rax     # 0xc2f80
jne 0x4630b
callq 0x22843
addq %rax, %r15
movq %r12, %rdi
callq 0x2ee1f
leaq 0x4a623(%rip), %rdi     # 0x9093d
pushq $0x9
popq %rsi
callq 0x2ea81
movq %rax, %r12
movq %rsp, %r13
movq %rax, (%r13)
movq %r14, 0x8(%r13)
movq %r15, %rdi
callq 0x2ea90
movq %rax, %r14
movq %rax, 0x10(%r13)
pushq $0x3
popq %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x461a3
movq %rax, %rbx
movq %r12, %rdi
callq 0x2ee1f
movq %r14, %rdi
callq 0x2ee1f
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
movl $0x4178, %edi           # imm = 0x4178
callq 0x2828d
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0x2fdf0
orl $-0x1, (%rbx)
andq $0x0, 0x18(%rbx)
callq 0x271bf
movq %rax, 0x20(%rbx)
andq $0x0, 0x28(%rbx)
andl $0x0, 0x30(%rbx)
andq $0x0, 0x38(%rbx)
andl $0x0, 0x170(%rbx)
andl $0x0, 0x90(%rbx)
andl $0x0, 0x118(%rbx)
movl $0x6, 0x98(%rbx)
callq 0x1fd8c
movq %rax, 0x60(%rbx)
andq $0x0, 0x68(%rbx)
andq $0x0, 0x88(%rbx)
callq 0x1fd8c
movq %rax, 0x150(%rbx)
andq $0x0, 0x168(%rbx)
movq 0x60(%rbx), %rax
leaq -0x17966(%rip), %rcx    # 0x2ec02
movq %rcx, 0x18(%rax)
leaq -0x1adb3(%rip), %rcx    # 0x2b7c0
movq %rcx, 0x10(%rax)
movq %rbx, %rdi
callq 0x48388
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x8067f(%rip), %rbx     # 0xc6fa8
movl 0x518(%rbx), %edi
movq %rsp, %rsi
callq 0x1f690
cmpl $-0x1, %eax
je 0x46951
movq 0x30(%rsp), %rax
movq %rax, 0x4f8(%rbx)
addq $0x90, %rsp
popq %rbx
retq
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x4a471(%rip), %rsi     # 0x90dd5
pushq $0x3
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
jmp 0x22613
// File: /workspace/github_c_makefile_star2_O2/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 0x46999
cmpl $0x8, %eax
je 0x46999
cmpl $0x1, %eax
jne 0x469a8
movq 0x8(%rsi), %rsi
callq 0x543ad
jmp 0x469a6
movq 0x8(%rsi), %rsi
movslq -0x8(%rsi), %rdx
callq 0x54345
popq %rcx
retq
leaq 0x46ab9(%rip), %rdi     # 0x8d468
leaq 0x49c5f(%rip), %rsi     # 0x90615
movl $0x3fe, %edx            # imm = 0x3FE
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rsi, (%rsp)
movq %rdi, %r14
movq %rdx, %rdi
callq 0x3f488
movq %rax, %r15
movq %rbx, %rdi
callq 0x3f5c0
movq %rax, %r12
xorl %r13d, %r13d
pushq $0x1
popq %rbx
movq %r12, %rdi
callq 0x3f648
cmpl $-0x1, %eax
je 0x470fc
testq %r13, %r13
jne 0x470bf
cmpq $0x40, %r15
pushq $0x40
popq %rax
cmovlq %r15, %rax
leal 0x2(,%rax,2), %edx
movq %r14, %rdi
pushq $0x2a
popq %rsi
callq 0x54281
xorl %ebp, %ebp
testq %rax, %rax
je 0x47106
movq %r14, %rdi
leaq 0x485d3(%rip), %rsi     # 0x8f675
pushq $0x5
popq %rdx
callq 0x54345
testq %rax, %rax
je 0x47106
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x46979
testl %eax, %eax
je 0x47106
movq %r14, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x47117
xorl %ebp, %ebp
testl %eax, %eax
je 0x47106
movq %r14, %rdi
movq %r12, %rsi
pushq $0x2
popq %rdx
callq 0x47117
testl %eax, %eax
je 0x47106
incq %r13
cmpq $0x40, %r13
movl $0x0, %eax
cmoveq %rax, %r13
decq %r15
jmp 0x4705e
movq %r12, %rdi
callq 0x3f62c
movl %ebx, %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_O2/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 0x47174
cmpl $0x5, %eax
jne 0x471a8
leaq 0x10(%rsp), %r14
andq $0x0, (%r14)
leaq 0x4(%rsp), %rcx
orl $-0x1, (%rcx)
movabsq $0x7fffffffffffffff, %rax # imm = 0x7FFFFFFFFFFFFFFF
leaq 0x8(%rsp), %r8
movq %rax, (%r8)
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x3f732
movq (%r14), %rsi
testq %rsi, %rsi
je 0x47193
movl 0x4(%rsp), %edx
movq %rbx, %rdi
callq 0x54345
jmp 0x471a0
leaq 0x10(%rsp), %r14
movq %rsi, %rdi
movl %edx, %esi
movq %r14, %rdx
callq 0x3f7b7
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x46979
jmp 0x471a0
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x543ad
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x47924(%rip), %rdi     # 0x8ead3
leaq 0x4945f(%rip), %rsi     # 0x90615
movl $0x4f7, %edx            # imm = 0x4F7
callq 0x490e8
pushq $0x1
popq %rdi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O2/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 0x7f939(%rip), %rax     # 0xc6fa8
cmpl $-0x1, 0x504(%rax)
je 0x47688
leaq 0x496be(%rip), %rsi     # 0x90d3d
movq %rbx, %rdi
popq %rbx
jmp 0x2c2da
cmpl $-0x1, 0x570(%rax)
je 0x476ab
movl $0x1, 0x500(%rax)
leaq 0x496d5(%rip), %rsi     # 0x90d77
movq %rbx, %rdi
popq %rbx
jmp 0x2c423
callq 0x4605f
testl %eax, %eax
je 0x476c8
leaq 0x80145(%rip), %rax     # 0xc7800
movq 0x10(%rax), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2c10d
leaq 0x496d8(%rip), %rsi     # 0x90da7
jmp 0x476a2