LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: clientsCronHandleTimeout
int clientsCronHandleTimeout(redisClient *c) {

    // 获取当前时间
    time_t now = server.unixtime;

    // 服务器设置了 maxidletime 时间
    if (server.maxidletime &&
        // 不检查作为从服务器的客户端
        !(c->flags & REDIS_SLAVE) &&    /* no timeout for slaves */
        // 不检查作为主服务器的客户端
        !(c->flags & REDIS_MASTER) &&   /* no timeout for masters */
        // 不检查被阻塞的客户端
        !(c->flags & REDIS_BLOCKED) &&  /* no timeout for BLPOP */
        // 不检查订阅了频道的客户端
        dictSize(c->pubsub_channels) == 0 && /* no timeout for pubsub */
        // 不检查订阅了模式的客户端
        listLength(c->pubsub_patterns) == 0 &&
        // 客户端最后一次与服务器通讯的时间已经超过了 maxidletime 时间
        (now - c->lastinteraction > server.maxidletime))
    {
        redisLog(REDIS_VERBOSE,"Closing idle client");
        // 关闭超时客户端
        freeClient(c);
        return 1;
    } else if (c->flags & REDIS_BLOCKED) {

        /* Blocked OPS timeout is handled with milliseconds resolution.
         * However note that the actual resolution is limited by
         * server.hz. */
        // 获取最新的系统时间
        mstime_t now_ms = mstime();

        // 检查被 BLPOP 等命令阻塞的客户端的阻塞时间是否已经到达
        // 如果是的话，取消客户端的阻塞
        if (c->bpop.timeout != 0 && c->bpop.timeout < now_ms) {
            // 向客户端返回空回复
            replyToBlockedClientTimedOut(c);
            // 取消客户端的阻塞状态
            unblockClient(c);
        }
    }

    // 客户度没有被关闭
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movslq 0xa69de(%rip), %rax     # 0xca410
testq %rax, %rax
je 0x23a95
testb $0x13, 0x90(%rbx)
jne 0x23a95
movq 0x158(%rbx), %rcx
movq 0x28(%rcx), %rdx
addq 0x48(%rcx), %rdx
jne 0x23a95
movq 0x160(%rbx), %rcx
cmpq $0x0, 0x28(%rcx)
jne 0x23a95
movq 0xa6cda(%rip), %rcx     # 0xca740
subq 0x80(%rbx), %rcx
cmpq %rax, %rcx
jle 0x23a95
leaq 0x70c46(%rip), %rsi     # 0x946bf
movl $0x1, %r14d
movl $0x1, %edi
xorl %eax, %eax
callq 0x23064
movq %rbx, %rdi
callq 0x2e287
jmp 0x23af8
xorl %r14d, %r14d
testb $0x10, 0x90(%rbx)
je 0x23af8
xorl %r14d, %r14d
movq %rsp, %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x1f2f0
imulq $0xf4240, (%r15), %rax  # imm = 0xF4240
addq 0x8(%r15), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq 0x120(%rbx), %rax
testq %rax, %rax
je 0x23af8
movq %rdx, %rcx
shrq $0x3f, %rcx
sarq $0x7, %rdx
addq %rcx, %rdx
cmpq %rdx, %rax
jge 0x23af8
movq %rbx, %rdi
callq 0x60f1c
movq %rbx, %rdi
callq 0x60e97
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: databasesCron
void databasesCron(void) {

    // 函数先从数据库中删除过期键，然后再对数据库的大小进行修改

    /* Expire keys by random sampling. Not required for slaves
     * as master will synthesize DELs for us. */
    // 如果服务器不是从服务器，那么执行主动过期键清除
    if (server.active_expire_enabled && server.masterhost == NULL)
        // 清除模式为 CYCLE_SLOW ，这个模式会尽量多清除过期键
        activeExpireCycle(ACTIVE_EXPIRE_CYCLE_SLOW);

    /* Perform hash tables rehashing if needed, but only if there are no
     * other processes saving the DB on disk. Otherwise rehashing is bad
     * as will cause a lot of copy-on-write of memory pages. */
    // 在没有 BGSAVE 或者 BGREWRITEAOF 执行时，对哈希表进行 rehash
    if (server.rdb_child_pid == -1 && server.aof_child_pid == -1) {
        /* We use global counters so if we stop the computation at a given
         * DB we'll be able to start from the successive in the next
         * cron loop iteration. */
        static unsigned int resize_db = 0;
        static unsigned int rehash_db = 0;
        unsigned int dbs_per_call = REDIS_DBCRON_DBS_PER_CALL;
        unsigned int j;

        /* Don't test more DBs than we have. */
        // 设定要测试的数据库数量
        if (dbs_per_call > server.dbnum) dbs_per_call = server.dbnum;

        /* Resize */
        // 调整字典的大小
        for (j = 0; j < dbs_per_call; j++) {
            tryResizeHashTables(resize_db % server.dbnum);
            resize_db++;
        }

        /* Rehash */
        // 对字典进行渐进式 rehash
        if (server.activerehashing) {
            for (j = 0; j < dbs_per_call; j++) {
                int work_done = incrementallyRehash(rehash_db % server.dbnum);
                rehash_db++;
                if (work_done) {
                    /* If the function did some work, stop here, we'll do
                     * more at the next cron loop. */
                    break;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
cmpl $0x0, 0xa681e(%rip)     # 0xca418
je 0x23c0d
cmpq $0x0, 0xa69f4(%rip)     # 0xca5f8
jne 0x23c0d
xorl %edi, %edi
callq 0x2360f
cmpl $-0x1, 0xa6904(%rip)    # 0xca518
jne 0x23c95
cmpl $-0x1, 0xa688f(%rip)    # 0xca4ac
jne 0x23c95
movl 0xa6803(%rip), %ebp     # 0xca428
cmpl $0x10, %ebp
movl $0x10, %ebx
cmovbl %ebp, %ebx
testl %ebp, %ebp
je 0x23c57
movl %ebx, %r14d
movl 0xa6bbb(%rip), %eax     # 0xca7f8
xorl %edx, %edx
divl 0xa67e3(%rip)           # 0xca428
movl %edx, %edi
callq 0x234ba
incl 0xa6ba6(%rip)           # 0xca7f8
decl %r14d
jne 0x23c37
cmpl $0x0, 0xa6382(%rip)     # 0xc9fe0
sete %al
testl %ebp, %ebp
sete %cl
orb %al, %cl
jne 0x23c95
decl %ebx
movl 0xa6b8a(%rip), %eax     # 0xca7fc
xorl %edx, %edx
divl 0xa67ae(%rip)           # 0xca428
movl %edx, %edi
callq 0x2354c
incl 0xa6b75(%rip)           # 0xca7fc
subl $0x1, %ebx
setb %cl
testl %eax, %eax
jne 0x23c95
testb %cl, %cl
je 0x23c6c
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: beforeSleep
void beforeSleep(struct aeEventLoop *eventLoop) {
    REDIS_NOTUSED(eventLoop);

    /* Run a fast expire cycle (the called function will return
     * ASAP if a fast cycle is not needed). */
    // 执行一次快速的主动过期检查
    if (server.active_expire_enabled && server.masterhost == NULL)
        activeExpireCycle(ACTIVE_EXPIRE_CYCLE_FAST);

    /* Send all the slaves an ACK request if at least one client blocked
     * during the previous event loop iteration. */
    if (server.get_ack_from_slaves) {
        robj *argv[3];

        argv[0] = createStringObject("REPLCONF",8);
        argv[1] = createStringObject("GETACK",6);
        argv[2] = createStringObject("*",1); /* Not used argument. */
        replicationFeedSlaves(server.slaves, server.slaveseldb, argv, 3);
        decrRefCount(argv[0]);
        decrRefCount(argv[1]);
        decrRefCount(argv[2]);
        server.get_ack_from_slaves = 0;
    }

    /* Unblock all the clients blocked for synchronous replication
     * in WAIT. */
    if (listLength(server.clients_waiting_acks))
        processClientsWaitingReplicas();

    /* Try to process pending commands for clients that were just unblocked. */
    if (listLength(server.unblocked_clients))
        processUnblockedClients();

    /* Write the AOF buffer on disk */
    // 将 AOF 缓冲区的内容写入到 AOF 文件
    flushAppendOnlyFile(0);

    /* Call the Redis Cluster before sleep function. */
    // 在进入下个事件循环前，执行一些集群收尾工作
    if (server.cluster_enabled) clusterBeforeSleep();
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
cmpl $0x0, 0xa61f7(%rip)     # 0xca418
je 0x24237
cmpq $0x0, 0xa63cd(%rip)     # 0xca5f8
jne 0x24237
movl $0x1, %edi
callq 0x2360f
cmpl $0x0, 0xa6482(%rip)     # 0xca6c0
je 0x242bf
leaq 0x705dd(%rip), %rdi     # 0x94824
movl $0x8, %esi
callq 0x303b7
movq %rsp, %rbx
movq %rax, (%rbx)
leaq 0x705cf(%rip), %rdi     # 0x9482d
movl $0x6, %esi
callq 0x303b7
movq %rax, 0x8(%rbx)
leaq 0x705c1(%rip), %rdi     # 0x94834
movl $0x1, %esi
callq 0x303b7
movq %rax, 0x10(%rbx)
movq 0xa5ee0(%rip), %rdi     # 0xca168
movl 0xa6306(%rip), %esi     # 0xca594
movq %rbx, %rdx
movl $0x3, %ecx
callq 0x332f9
movq (%rbx), %rdi
callq 0x30834
movq 0x8(%rbx), %rdi
callq 0x30834
movq 0x10(%rbx), %rdi
callq 0x30834
movl $0x0, 0xa6401(%rip)     # 0xca6c0
movq 0xa63f2(%rip), %rax     # 0xca6b8
cmpq $0x0, 0x28(%rax)
je 0x242d2
callq 0x3591d
movq 0xa6407(%rip), %rax     # 0xca6e0
cmpq $0x0, 0x28(%rax)
je 0x242e5
callq 0x60e07
xorl %edi, %edi
callq 0x496c4
cmpl $0x0, 0xa6471(%rip)     # 0xca764
je 0x242fa
callq 0x542e7
addq $0x20, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: lookupCommandByCString
struct redisCommand *lookupCommandByCString(char *s) {
    struct redisCommand *cmd;
    sds name = sdsnew(s);

    cmd = dictFetchValue(server.commands, name);
    sdsfree(name);
    return cmd;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x281da
movq %rax, %rbx
movq 0xa5074(%rip), %rdi     # 0xc9fc0
movq %rax, %rsi
callq 0x22813
movq %rax, %r14
movq %rbx, %rdi
callq 0x28204
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: resetServerStats
void resetServerStats(void) {
    server.stat_numcommands = 0;
    server.stat_numconnections = 0;
    server.stat_expiredkeys = 0;
    server.stat_evictedkeys = 0;
    server.stat_keyspace_misses = 0;
    server.stat_keyspace_hits = 0;
    server.stat_fork_time = 0;
    server.stat_rejected_conn = 0;
    server.stat_sync_full = 0;
    server.stat_sync_partial_ok = 0;
    server.stat_sync_partial_err = 0;
    memset(server.ops_sec_samples,0,sizeof(server.ops_sec_samples));
    server.ops_sec_idx = 0;
    server.ops_sec_last_sample_time = mstime();
    server.ops_sec_last_sample_ops = 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0xa50c3(%rip)    # 0xca310
movups %xmm0, 0xa50ac(%rip)    # 0xca300
movups %xmm0, 0xa5095(%rip)    # 0xca2f0
movups %xmm0, 0xa50c6(%rip)    # 0xca328
movups %xmm0, 0xa50cf(%rip)    # 0xca338
xorl %r14d, %r14d
movq %r14, 0xa50d5(%rip)     # 0xca348
leaq 0xa510e(%rip), %rdi     # 0xca388
movl $0x84, %edx
xorl %esi, %esi
callq 0x1f110
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f2f0
imulq $0xf4240, (%rbx), %rax  # imm = 0xF4240
addq 0x8(%rbx), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
movq %rdx, 0xa50b6(%rip)     # 0xca378
movq %r14, 0xa50b7(%rip)     # 0xca380
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisOpArrayAppend
int redisOpArrayAppend(redisOpArray *oa, struct redisCommand *cmd, int dbid,
                       robj **argv, int argc, int target)
{
    redisOp *op;

    oa->ops = zrealloc(oa->ops,sizeof(redisOp)*(oa->numops+1));
    op = oa->ops+oa->numops;
    op->cmd = cmd;
    op->dbid = dbid;
    op->argv = argv;
    op->argc = argc;
    op->target = target;
    oa->numops++;
    return oa->numops;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %ebx
movl %r8d, %ebp
movq %rcx, %r15
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %r14
movq (%rdi), %rdi
movslq 0x8(%r14), %rsi
shlq $0x5, %rsi
addq $0x20, %rsi
callq 0x297b5
movq %rax, (%r14)
movslq 0x8(%r14), %rdx
leal 0x1(%rdx), %ecx
shlq $0x5, %rdx
movq %r13, 0x18(%rax,%rdx)
movl %r12d, 0xc(%rax,%rdx)
movq %r15, (%rax,%rdx)
movl %ebp, 0x8(%rax,%rdx)
movl %ebx, 0x10(%rax,%rdx)
movl %ecx, 0x8(%r14)
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisOpArrayFree
void redisOpArrayFree(redisOpArray *oa) {
    while(oa->numops) {
        int j;
        redisOp *op;

        oa->numops--;
        op = oa->ops+oa->numops;
        for (j = 0; j < op->argc; j++)
            decrRefCount(op->argv[j]);
        zfree(op->argv);
    }
    zfree(oa->ops);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %eax
testl %eax, %eax
je 0x25a11
cltq
movq %rax, %rcx
shlq $0x5, %rcx
decl %eax
movl %eax, 0x8(%rbx)
movq (%rbx), %rax
leaq (%rcx,%rax), %r14
addq $-0x20, %r14
cmpl $0x0, 0x8(%r14)
jle 0x25a04
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x30834
incq %r15
movslq 0x8(%r14), %rax
cmpq %rax, %r15
jl 0x259ec
movq (%r14), %rdi
callq 0x2984b
movl 0x8(%rbx), %eax
jmp 0x259c5
movq (%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x2984b
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: lookupCommandOrOriginal
struct redisCommand *lookupCommandOrOriginal(sds name) {

    // 查找当前表
    struct redisCommand *cmd = dictFetchValue(server.commands, name);

    // 如果有需要的话，查找原始表
    if (!cmd) cmd = dictFetchValue(server.orig_commands,name);

    return cmd;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0xa4588(%rip), %rdi     # 0xc9fc0
movq %rbx, %rsi
callq 0x22813
testq %rax, %rax
je 0x25a47
popq %rbx
retq
movq 0xa457a(%rip), %rdi     # 0xc9fc8
movq %rbx, %rsi
popq %rbx
jmp 0x22813
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: propagate
void propagate(struct redisCommand *cmd, int dbid, robj **argv, int argc,
               int flags)
{
    // 传播到 AOF
    if (server.aof_state != REDIS_AOF_OFF && flags & REDIS_PROPAGATE_AOF)
        feedAppendOnlyFile(cmd,dbid,argv,argc);

    // 传播到 slave
    if (flags & REDIS_PROPAGATE_REPL)
        replicationFeedSlaves(server.slaves,dbid,argv,argc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %r15d
movl %ecx, %ebx
movq %rdx, %r14
movl %esi, %ebp
testb $0x1, %r15b
je 0x25a83
cmpl $0x0, 0xa4a03(%rip)     # 0xca478
je 0x25a83
movl %ebp, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x49e0e
testb $0x2, %r15b
jne 0x25a94
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0xa46cd(%rip), %rdi     # 0xca168
movl %ebp, %esi
movq %r14, %rdx
movl %ebx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x332f9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: closeListeningSockets
void closeListeningSockets(int unlink_unix_socket) {
    int j;

    for (j = 0; j < server.ipfd_count; j++) close(server.ipfd[j]);

    if (server.sofd != -1) close(server.sofd);

    if (server.cluster_enabled)
        for (j = 0; j < server.cfd_count; j++) close(server.cfd[j]);

    if (unlink_unix_socket && server.unixsocket) {
        redisLog(REDIS_NOTICE,"Removing the unix socket file.");
        unlink(server.unixsocket); /* don't care if this fails */
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edi, %ebx
cmpl $0x0, 0xa3b49(%rip)     # 0xca10c
leaq 0xa39de(%rip), %r14     # 0xc9fa8
jle 0x265eb
xorl %r15d, %r15d
movl 0x124(%r14,%r15,4), %edi
callq 0x1f170
incq %r15
movslq 0xa3b26(%rip), %rax     # 0xca10c
cmpq %rax, %r15
jl 0x265cf
movl 0xa3b1f(%rip), %edi     # 0xca110
cmpl $-0x1, %edi
je 0x265fb
callq 0x1f170
cmpl $0x0, 0xa4162(%rip)     # 0xca764
je 0x2662c
cmpl $0x0, 0xa3b49(%rip)     # 0xca154
jle 0x2662c
xorl %r15d, %r15d
movl 0x16c(%r14,%r15,4), %edi
callq 0x1f170
incq %r15
movslq 0xa3b2d(%rip), %rax     # 0xca154
cmpq %rax, %r15
jl 0x26610
testl %ebx, %ebx
je 0x2665e
cmpq $0x0, 0xa3a88(%rip)     # 0xca0c0
je 0x2665e
leaq 0x6ed1f(%rip), %rsi     # 0x95360
movl $0x2, %edi
xorl %eax, %eax
callq 0x23064
movq 0xa3a6c(%rip), %rdi     # 0xca0c0
popq %rbx
popq %r14
popq %r15
jmp 0x1f3a0
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: time_independent_strcmp
int time_independent_strcmp(char *a, char *b) {
    char bufa[REDIS_AUTHPASS_MAX_LEN], bufb[REDIS_AUTHPASS_MAX_LEN];
    /* The above two strlen perform len(a) + len(b) operations where either
     * a or b are fixed (our password) length, and the difference is only
     * relative to the length of the user provided string, so no information
     * leak is possible in the following two lines of code. */
    int alen = strlen(a);
    int blen = strlen(b);
    int j;
    int diff = 0;

    /* We can't compare strings longer than our static buffers.
     * Note that this will never pass the first test in practical circumstances
     * so there is no info leak. */
    if (alen > sizeof(bufa) || blen > sizeof(bufb)) return 1;

    memset(bufa,0,sizeof(bufa));        /* Constant time. */
    memset(bufb,0,sizeof(bufb));        /* Constant time. */
    /* Again the time of the following two copies is proportional to
     * len(a) + len(b) so no info is leaked. */
    memcpy(bufa,a,alen);
    memcpy(bufb,b,blen);

    /* Always compare all the chars in the two buffers without
     * conditional expressions. */
    for (j = 0; j < sizeof(bufa); j++) {
        diff |= (bufa[j] ^ bufb[j]);
    }
    /* Length must be equal as well. */
    diff |= alen ^ blen;
    return diff; /* If zero strings are the same. */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rsi, %r15
movq %rdi, %r12
callq 0x1f4f0
movq %rax, %rbx
movq %r15, %rdi
callq 0x1f4f0
movq %rax, %r14
movslq %ebx, %rbp
movl $0x201, %eax            # imm = 0x201
cmpq %rax, %rbp
setae %cl
movslq %r14d, %r13
cmpq %rax, %r13
setae %al
orb %cl, %al
movl $0x1, %eax
jne 0x2687d
movq %rbx, 0x8(%rsp)
leaq 0x210(%rsp), %rdi
xorl %ebx, %ebx
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x1f110
leaq 0x10(%rsp), %rdi
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x1f110
leaq 0x210(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x1fbd0
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x1fbd0
xorl %eax, %eax
movb 0x10(%rsp,%rbx), %cl
xorb 0x210(%rsp,%rbx), %cl
movsbl %cl, %ecx
orl %ecx, %eax
incq %rbx
cmpq $0x200, %rbx            # imm = 0x200
jne 0x26859
xorl 0x8(%rsp), %r14d
orl %r14d, %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: bytesToHuman
void bytesToHuman(char *s, unsigned long long n) {
    double d;

    if (n < 1024) {
        /* Bytes */
        sprintf(s,"%lluB",n);
        return;
    } else if (n < (1024*1024)) {
        d = (double)n/(1024);
        sprintf(s,"%.2fK",d);
    } else if (n < (1024LL*1024*1024)) {
        d = (double)n/(1024*1024);
        sprintf(s,"%.2fM",d);
    } else if (n < (1024LL*1024*1024*1024)) {
        d = (double)n/(1024LL*1024*1024);
        sprintf(s,"%.2fG",d);
    }
}

// Assembly:
movq %rsi, %rdx
cmpq $0x3ff, %rsi            # imm = 0x3FF
ja 0x268a9
leaq 0x6ec51(%rip), %rsi     # 0x954f3
xorl %eax, %eax
jmp 0x1f570
cmpq $0xfffff, %rdx          # imm = 0xFFFFF
ja 0x268c8
cvtsi2sd %rdx, %xmm0
mulsd 0x6d999(%rip), %xmm0    # 0x94258
leaq 0x6ec33(%rip), %rsi     # 0x954f9
jmp 0x26904
cmpq $0x3fffffff, %rdx       # imm = 0x3FFFFFFF
ja 0x268e7
cvtsi2sd %rdx, %xmm0
mulsd 0x6d972(%rip), %xmm0    # 0x94250
leaq 0x6ec1a(%rip), %rsi     # 0x954ff
jmp 0x26904
movq %rdx, %rax
shrq $0x28, %rax
jne 0x2690b
cvtsi2sd %rdx, %xmm0
mulsd 0x6d94b(%rip), %xmm0    # 0x94248
leaq 0x6ec01(%rip), %rsi     # 0x95505
movb $0x1, %al
jmp 0x1f570
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: version
void version() {
    printf("Redis server v=%s sha=%s:%d malloc=%s bits=%d build=%llx\n",
        REDIS_VERSION,
        redisGitSHA1(),
        atoi(redisGitDirty()) > 0,
        ZMALLOC_LIB,
        sizeof(long) == 4 ? 32 : 64,
        (unsigned long long) redisBuildId());
    exit(0);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
callq 0x2ccb0
movq %rax, %rbx
callq 0x2ccb8
movq %rax, %rdi
callq 0x1f710
xorl %ebp, %ebp
testl %eax, %eax
setg %bpl
callq 0x2ccc0
movq %rax, (%rsp)
leaq 0x6e731(%rip), %rdi     # 0x96064
leaq 0x6f036(%rip), %rsi     # 0x96970
leaq 0x6de37(%rip), %r8      # 0x95778
movq %rbx, %rdx
movl %ebp, %ecx
movl $0x40, %r9d
xorl %eax, %eax
callq 0x1f0a0
xorl %edi, %edi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: usage
void usage() {
    fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf] [options]\n");
    fprintf(stderr,"       ./redis-server - (read config from stdin)\n");
    fprintf(stderr,"       ./redis-server -v or --version\n");
    fprintf(stderr,"       ./redis-server -h or --help\n");
    fprintf(stderr,"       ./redis-server --test-memory <megabytes>\n\n");
    fprintf(stderr,"Examples:\n");
    fprintf(stderr,"       ./redis-server (run the server with default conf)\n");
    fprintf(stderr,"       ./redis-server /etc/redis/6379.conf\n");
    fprintf(stderr,"       ./redis-server --port 7777\n");
    fprintf(stderr,"       ./redis-server --port 7777 --slaveof 127.0.0.1 8888\n");
    fprintf(stderr,"       ./redis-server /etc/myredis.conf --loglevel verbose\n\n");
    fprintf(stderr,"Sentinel mode:\n");
    fprintf(stderr,"       ./redis-server /etc/sentinel.conf --sentinel\n");
    exit(1);
}

// Assembly:
pushq %rbx
movq 0x9e666(%rip), %rbx     # 0xc5fc8
movq (%rbx), %rcx
leaq 0x6e732(%rip), %rdi     # 0x9609e
movl $0x36, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e750(%rip), %rdi     # 0x960d5
movl $0x31, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e769(%rip), %rdi     # 0x96107
movl $0x26, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e777(%rip), %rdi     # 0x9612e
movl $0x23, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e782(%rip), %rdi     # 0x96152
movl $0x31, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e79b(%rip), %rdi     # 0x96184
movl $0xa, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e78d(%rip), %rdi     # 0x9618f
movl $0x39, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e7ae(%rip), %rdi     # 0x961c9
movl $0x2b, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e7c1(%rip), %rdi     # 0x961f5
movl $0x22, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e7cb(%rip), %rdi     # 0x96218
movl $0x3b, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e7ee(%rip), %rdi     # 0x96254
movl $0x3c, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e812(%rip), %rdi     # 0x96291
movl $0xf, %esi
movl $0x1, %edx
callq 0x1fa90
movq (%rbx), %rcx
leaq 0x6e809(%rip), %rdi     # 0x962a1
movl $0x34, %esi
movl $0x1, %edx
callq 0x1fa90
movl $0x1, %edi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisAsciiArt
void redisAsciiArt(void) {
#include "asciilogo.h"
    char *buf = zmalloc(1024*16);
    char *mode = "stand alone";

    if (server.cluster_enabled) mode = "cluster";
    else if (server.sentinel_mode) mode = "sentinel";

    snprintf(buf,1024*16,ascii_logo,
        REDIS_VERSION,
        redisGitSHA1(),
        strtol(redisGitDirty(),NULL,10) > 0,
        (sizeof(long) == 8) ? "64" : "32",
        mode, server.port,
        (long) getpid()
    );
    redisLogRaw(REDIS_NOTICE|REDIS_LOG_RAW,buf);
    zfree(buf);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0x4000, %edi           # imm = 0x4000
callq 0x29709
cmpl $0x0, 0xa2562(%rip)     # 0xca02c
leaq 0x6ec72(%rip), %rcx     # 0x96743
leaq 0x77b92(%rip), %rdx     # 0x9f66a
cmoveq %rcx, %rdx
cmpl $0x0, 0xa2c81(%rip)     # 0xca764
movq %rax, %rbx
leaq 0x6caea(%rip), %r15     # 0x945d7
cmoveq %rdx, %r15
callq 0x2ccb0
movq %rax, %r14
callq 0x2ccb8
movq %rax, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1f6d0
xorl %ebp, %ebp
testq %rax, %rax
setg %bpl
movl 0xa2513(%rip), %r12d    # 0xca030
callq 0x1f410
movslq %eax, %r10
leaq 0x6ec23(%rip), %r11     # 0x9674f
leaq 0x6e7a3(%rip), %rdx     # 0x962d6
leaq 0x6ee36(%rip), %rcx     # 0x96970
movl $0x4000, %esi           # imm = 0x4000
movq %rbx, %rdi
movq %r14, %r8
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq %r12
pushq %r15
pushq %r11
callq 0x1f120
addq $0x20, %rsp
movl $0x402, %edi            # imm = 0x402
movq %rbx, %rsi
callq 0x22f15
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2984b
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: checkForSentinelMode
int checkForSentinelMode(int argc, char **argv) {
    int j;

    if (strstr(argv[0],"redis-sentinel") != NULL) return 1;
    for (j = 1; j < argc; j++)
        if (!strcmp(argv[j],"--sentinel")) return 1;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebp
movq (%rsi), %rdi
leaq 0x6eba2(%rip), %rsi     # 0x96752
callq 0x1f660
movl $0x1, %ebx
testq %rax, %rax
jne 0x27bee
cmpl $0x2, %ebp
jl 0x27bec
movl %ebp, %r12d
movl $0x1, %r13d
leaq 0x6eb8d(%rip), %r15     # 0x96761
movq (%r14,%r13,8), %rdi
movq %r15, %rsi
callq 0x1f880
testl %eax, %eax
je 0x27bee
incq %r13
cmpq %r13, %r12
jne 0x27bd4
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: loadDataFromDisk
void loadDataFromDisk(void) {
    // 记录开始时间
    long long start = ustime();

    // AOF 持久化已打开？
    if (server.aof_state == REDIS_AOF_ON) {
        // 尝试载入 AOF 文件
        if (loadAppendOnlyFile(server.aof_filename) == REDIS_OK)
            // 打印载入信息，并计算载入耗时长度
            redisLog(REDIS_NOTICE,"DB loaded from append only file: %.3f seconds",(float)(ustime()-start)/1000000);
    // AOF 持久化未打开
    } else {
        // 尝试载入 RDB 文件
        if (rdbLoad(server.rdb_filename) == REDIS_OK) {
            // 打印载入信息，并计算载入耗时长度
            redisLog(REDIS_NOTICE,"DB loaded from disk: %.3f seconds",
                (float)(ustime()-start)/1000000);
        } else if (errno != ENOENT) {
            redisLog(REDIS_WARNING,"Fatal error loading the DB: %s. Exiting.",strerror(errno));
            exit(1);
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f2f0
imulq $-0xf4240, (%rbx), %r14 # imm = 0xFFF0BDC0
subq 0x8(%rbx), %r14
cmpl $0x1, 0xa2851(%rip)     # 0xca478
jne 0x27c58
movq 0xa2850(%rip), %rdi     # 0xca480
callq 0x4a063
testl %eax, %eax
jne 0x27c74
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f2f0
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
leaq 0x6eb16(%rip), %rsi     # 0x9676c
jmp 0x27c99
movq 0xa28d1(%rip), %rdi     # 0xca530
callq 0x3811a
testl %eax, %eax
je 0x27c7c
callq 0x1f810
movl (%rax), %edi
cmpl $0x2, %edi
jne 0x27cca
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f2f0
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
leaq 0x6eb01(%rip), %rsi     # 0x9679a
imulq $0xf4240, %rcx, %rcx    # imm = 0xF4240
addq %rax, %rcx
addq %r14, %rcx
cvtsi2ss %rcx, %xmm0
divss 0x6c5b5(%rip), %xmm0    # 0x94268
cvtss2sd %xmm0, %xmm0
movl $0x2, %edi
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x23064
callq 0x1f630
leaq 0x6eae6(%rip), %rsi     # 0x967bc
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
callq 0x23064
movl $0x1, %edi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisSetProcTitle
void redisSetProcTitle(char *title) {
#ifdef USE_SETPROCTITLE
    char *server_mode = "";
    if (server.cluster_enabled) server_mode = " [cluster]";
    else if (server.sentinel_mode) server_mode = " [sentinel]";

    setproctitle("%s %s:%d%s",
        title,
        server.bindaddr_count ? server.bindaddr[0] : "*",
        server.port,
        server_mode);
#else
    REDIS_NOTUSED(title);
#endif
}

// Assembly:
cmpl $0x0, 0xa22fd(%rip)     # 0xca02c
leaq 0x6f5ab(%rip), %rax     # 0x972e1
leaq 0x6eafa(%rip), %rcx     # 0x96837
cmoveq %rax, %rcx
movq %rdi, %rsi
cmpl $0x0, 0xa2a19(%rip)     # 0xca764
leaq 0x6eada(%rip), %r8      # 0x9682c
cmoveq %rcx, %r8
cmpl $0x0, 0xa235b(%rip)     # 0xca0b8
je 0x27d68
movq 0xa22d2(%rip), %rdx     # 0xca038
jmp 0x27d6f
leaq 0x6cac5(%rip), %rdx     # 0x94834
movl 0xa22bb(%rip), %ecx     # 0xca030
leaq 0x6eac7(%rip), %rdi     # 0x96843
xorl %eax, %eax
jmp 0x60be8
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdsnewlen
sds sdsnewlen(const void *init, size_t initlen) {

    struct sdshdr *sh;

    // 根据是否有初始化内容，选择适当的内存分配方式
    // T = O(N)
    if (init) {
        // zmalloc 不初始化所分配的内存
        sh = zmalloc(sizeof(struct sdshdr)+initlen+1);
    } else {
        // zcalloc 将分配的内存全部初始化为 0
        sh = zcalloc(sizeof(struct sdshdr)+initlen+1);
    }

    // 内存分配失败，返回
    if (sh == NULL) return NULL;

    // 设置初始化长度
    sh->len = initlen;
    // 新 sds 不预留任何空间
    sh->free = 0;
    // 如果有指定初始化内容，将它们复制到 sdshdr 的 buf 中
    // T = O(N)
    if (initlen && init)
        memcpy(sh->buf, init, initlen);
    // 以 \0 结尾
    sh->buf[initlen] = '\0';

    // 返回 buf 部分，而不是整个 sdshdr
    return (char*)sh->buf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x9(%rsi), %rdi
testq %r14, %r14
je 0x28163
callq 0x29709
jmp 0x28168
callq 0x2975b
movq %rax, %r15
testq %rax, %rax
je 0x281a6
testq %r14, %r14
sete %al
movl %ebx, (%r15)
movl $0x0, 0x4(%r15)
testq %rbx, %rbx
sete %cl
orb %al, %cl
jne 0x2819a
leaq 0x8(%r15), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1fbd0
movb $0x0, 0x8(%r15,%rbx)
addq $0x8, %r15
jmp 0x281a9
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdsIncrLen
void sdsIncrLen(sds s, int incr) {
    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));

    // 确保 sds 空间足够
    assert(sh->free >= incr);

    // 更新属性
    sh->len += incr;
    sh->free -= incr;

    // 这个 assert 其实可以忽略
    // 因为前一个 assert 已经确保 sh->free - incr >= 0 了
    assert(sh->free >= 0);

    // 放置新的结尾符号
    s[sh->len] = '\0';
}

// Assembly:
pushq %rax
movl -0x4(%rdi), %eax
cmpl %esi, %eax
jl 0x282e2
movslq -0x8(%rdi), %rdx
movslq %esi, %rcx
addq %rdx, %rcx
movl %ecx, -0x8(%rdi)
subl %esi, %eax
movl %eax, -0x4(%rdi)
js 0x28301
movb $0x0, (%rdi,%rcx)
popq %rax
retq
leaq 0x6e88b(%rip), %rdi     # 0x96b74
leaq 0x6e895(%rip), %rsi     # 0x96b85
leaq 0x6e894(%rip), %rcx     # 0x96b8b
movl $0x164, %edx            # imm = 0x164
callq 0x1f2c0
leaq 0x6e89d(%rip), %rdi     # 0x96ba5
leaq 0x6e876(%rip), %rsi     # 0x96b85
leaq 0x6e875(%rip), %rcx     # 0x96b8b
movl $0x16c, %edx            # imm = 0x16C
callq 0x1f2c0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdsgrowzero
sds sdsgrowzero(sds s, size_t len) {
    struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
    size_t totlen, curlen = sh->len;

    // 如果 len 比字符串的现有长度小，
    // 那么直接返回，不做动作
    if (len <= curlen) return s;

    // 扩展 sds
    // T = O(N)
    s = sdsMakeRoomFor(s,len-curlen);
    // 如果内存不足，直接返回
    if (s == NULL) return NULL;

    /* Make sure added region doesn't contain garbage */
    // 将新分配的空间用 0 填充，防止出现垃圾内容
    // T = O(N)
    sh = (void*)(s-(sizeof(struct sdshdr)));
    memset(s+curlen,0,(len-curlen+1)); /* also set trailing \0 byte */

    // 更新属性
    totlen = sh->len+sh->free;
    sh->len = len;
    sh->free = totlen-sh->len;

    // 返回新的 sds
    return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq -0x8(%rdi), %r12
movq %rsi, %r15
subq %r12, %r15
jbe 0x28371
movq %rsi, %r14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2823a
testq %rax, %rax
je 0x2836f
movq %rax, %rbx
addq %rax, %r12
incq %r15
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1f110
movl -0x8(%rbx), %eax
movl %r14d, -0x8(%rbx)
subl %r14d, %eax
addl %eax, -0x4(%rbx)
jmp 0x28371
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdscatlen
sds sdscatlen(sds s, const void *t, size_t len) {
    
    struct sdshdr *sh;
    
    // 原有字符串长度
    size_t curlen = sdslen(s);

    // 扩展 sds 空间
    // T = O(N)
    s = sdsMakeRoomFor(s,len);

    // 内存不足？直接返回
    if (s == NULL) return NULL;

    // 复制 t 中的内容到字符串后部
    // T = O(N)
    sh = (void*) (s-(sizeof(struct sdshdr)));
    memcpy(s+curlen, t, len);

    // 更新属性
    sh->len = curlen+len;
    sh->free = sh->free-len;

    // 添加新结尾符号
    s[curlen+len] = '\0';

    // 返回新 sds
    return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movslq -0x8(%rdi), %r12
movq %rdx, %rsi
callq 0x2823a
testq %rax, %rax
je 0x283c5
movq %rax, %r14
movq %rax, %rdi
addq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1fbd0
addq %rbx, %r12
movl %r12d, -0x8(%r14)
subl %ebx, -0x4(%r14)
movb $0x0, (%r14,%r12)
jmp 0x283c8
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdscpylen
sds sdscpylen(sds s, const char *t, size_t len) {

    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));

    // sds 现有 buf 的长度
    size_t totlen = sh->free+sh->len;

    // 如果 s 的 buf 长度不满足 len ，那么扩展它
    if (totlen < len) {
        // T = O(N)
        s = sdsMakeRoomFor(s,len-sh->len);
        if (s == NULL) return NULL;
        sh = (void*) (s-(sizeof(struct sdshdr)));
        totlen = sh->free+sh->len;
    }

    // 复制内容
    // T = O(N)
    memcpy(s, t, len);

    // 添加终结符号
    s[len] = '\0';

    // 更新属性
    sh->len = len;
    sh->free = totlen-len;

    // 返回新的 sds
    return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movslq -0x4(%rdi), %r12
movslq -0x8(%rdi), %rax
addq %rax, %r12
cmpq %rdx, %r12
jae 0x284dc
movq %r14, %rsi
subq %rax, %rsi
movq %rbx, %rdi
callq 0x2823a
testq %rax, %rax
je 0x2850b
movq %rax, %rbx
movq %rax, %r13
addq $-0x8, %r13
movl -0x8(%rax), %r12d
addl -0x4(%rax), %r12d
jmp 0x284e0
leaq -0x8(%rbx), %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1fbd0
movb $0x0, (%rbx,%r14)
movl %r14d, -0x8(%rbx)
subl %r14d, %r12d
movl %r12d, 0x4(%r13)
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %ebx, %ebx
jmp 0x284fe
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdscatvprintf
sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
    va_list cpy;
    char staticbuf[1024], *buf = staticbuf, *t;
    size_t buflen = strlen(fmt)*2;

    /* We try to start using a static buffer for speed.
     * If not possible we revert to heap allocation. */
    if (buflen > sizeof(staticbuf)) {
        buf = zmalloc(buflen);
        if (buf == NULL) return NULL;
    } else {
        buflen = sizeof(staticbuf);
    }

    /* Try with buffers two times bigger every time we fail to
     * fit the string in the current buffer size. */
    while(1) {
        buf[buflen-2] = '\0';
        va_copy(cpy,ap);
        // T = O(N)
        vsnprintf(buf, buflen, fmt, cpy);
        if (buf[buflen-2] != '\0') {
            if (buf != staticbuf) zfree(buf);
            buflen *= 2;
            buf = zmalloc(buflen);
            if (buf == NULL) return NULL;
            continue;
        }
        break;
    }

    /* Finally concat the obtained string to the SDS string and return it. */
    t = sdscat(s, buf);
    if (buf != staticbuf) zfree(buf);
    return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movq %rsi, %rdi
callq 0x1f4f0
movq %rax, %rbx
addq %rax, %rbx
movl $0x400, %ebp            # imm = 0x400
leaq 0x30(%rsp), %r12
movq %r12, %r13
cmpq $0x401, %rbx            # imm = 0x401
jb 0x286cf
movq %rbx, %rdi
callq 0x29709
movq %rax, %r13
movq %rbx, %rbp
testq %rax, %rax
je 0x28725
leaq 0x10(%rsp), %rbx
movb $0x0, -0x2(%rbp,%r13)
movq 0x10(%r14), %rax
movq %rax, 0x20(%rsp)
movups (%r14), %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x1f7b0
cmpb $0x0, -0x2(%rbp,%r13)
je 0x28729
cmpq %r12, %r13
je 0x28712
movq %r13, %rdi
callq 0x2984b
addq %rbp, %rbp
movq %rbp, %rdi
callq 0x29709
movq %rax, %r13
testq %rax, %rax
jne 0x286d4
xorl %ebx, %ebx
jmp 0x2874b
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x283d7
movq %rax, %rbx
leaq 0x30(%rsp), %rax
cmpq %rax, %r13
je 0x2874b
movq %r13, %rdi
callq 0x2984b
movq %rbx, %rax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdstrim
sds sdstrim(sds s, const char *cset) {
    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
    char *start, *end, *sp, *ep;
    size_t len;

    // 设置和记录指针
    sp = start = s;
    ep = end = s+sdslen(s)-1;

    // 修剪, T = O(N^2)
    while(sp <= end && strchr(cset, *sp)) sp++;
    while(ep > start && strchr(cset, *ep)) ep--;

    // 计算 trim 完毕之后剩余的字符串长度
    len = (sp > ep) ? 0 : ((ep-sp)+1);
    
    // 如果有需要，前移字符串内容
    // T = O(N)
    if (sh->buf != sp) memmove(sh->buf, sp, len);

    // 添加终结符
    sh->buf[len] = '\0';

    // 更新属性
    sh->free = sh->free+(sh->len-len);
    sh->len = len;

    // 返回修剪后的 sds
    return s;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movslq -0x8(%rdi), %rax
leaq (%rdi,%rax), %r12
decq %r12
movq %rdi, %r14
cmpq %rdi, %r12
jb 0x28bc9
movq %rbx, %r14
movsbl (%r14), %esi
movq %r15, %rdi
callq 0x1f790
testq %rax, %rax
je 0x28bc9
incq %r14
cmpq %r12, %r14
jbe 0x28bb0
cmpq %rbx, %r12
jbe 0x28beb
movsbl (%r12), %esi
movq %r15, %rdi
callq 0x1f790
testq %rax, %rax
je 0x28beb
decq %r12
cmpq %rbx, %r12
ja 0x28bce
movq %rbx, %r12
xorl %r15d, %r15d
subq %r14, %r12
leaq 0x1(%r12), %rax
cmovaeq %rax, %r15
cmpq %rbx, %r14
je 0x28c0d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1f780
movb $0x0, (%rbx,%r15)
movl -0x4(%rbx), %eax
subl %r15d, %eax
addl -0x8(%rbx), %eax
movl %eax, -0x4(%rbx)
movl %r15d, -0x8(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdsrange
void sdsrange(sds s, int start, int end) {
    struct sdshdr *sh = (void*) (s-(sizeof(struct sdshdr)));
    size_t newlen, len = sdslen(s);

    if (len == 0) return;
    if (start < 0) {
        start = len+start;
        if (start < 0) start = 0;
    }
    if (end < 0) {
        end = len+end;
        if (end < 0) end = 0;
    }
    newlen = (start > end) ? 0 : (end-start)+1;
    if (newlen != 0) {
        if (start >= (signed)len) {
            newlen = 0;
        } else if (end >= (signed)len) {
            end = len-1;
            newlen = (start > end) ? 0 : (end-start)+1;
        }
    } else {
        start = 0;
    }

    // 如果有需要，对字符串进行移动
    // T = O(N)
    if (start && newlen) memmove(sh->buf, sh->buf+start, newlen);

    // 添加终结符
    sh->buf[newlen] = 0;

    // 更新属性
    sh->free = sh->free+(sh->len-newlen);
    sh->len = newlen;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl -0x8(%rdi), %edi
testl %edi, %edi
je 0x28cc3
leal (%rdi,%rsi), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
testl %esi, %esi
cmovnsl %esi, %eax
leal (%rdi,%rdx), %esi
testl %esi, %esi
cmovlel %ecx, %esi
testl %edx, %edx
cmovnsl %edx, %esi
movl %esi, %edx
subl %eax, %edx
leal 0x1(%rdx), %edx
cmovbl %ecx, %edx
testl %edx, %edx
je 0x28c7c
movl %edi, %ecx
subl %eax, %ecx
jle 0x28c81
cmpl %edi, %esi
jge 0x28c86
movslq %edx, %r14
jmp 0x28c92
xorl %r14d, %r14d
jmp 0x28c94
xorl %r14d, %r14d
jmp 0x28c92
decl %edi
xorl %edx, %edx
cmpl %edi, %eax
cmovgl %edx, %ecx
movslq %ecx, %r14
movl %eax, %ecx
testl %ecx, %ecx
je 0x28cae
testq %r14, %r14
je 0x28cae
movslq %ecx, %rsi
addq %rbx, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1f780
movb $0x0, (%rbx,%r14)
movl -0x4(%rbx), %eax
subl %r14d, %eax
addl -0x8(%rbx), %eax
movl %eax, -0x4(%rbx)
movl %r14d, -0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sds.c
// Function: sdsfreesplitres
void sdsfreesplitres(sds *tokens, int count) {
    if (!tokens) return;
    while(count--)
        sdsfree(tokens[count]);
    zfree(tokens);
}

// Assembly:
testq %rdi, %rdi
je 0x28f44
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
je 0x28f35
movslq %esi, %r14
movq -0x8(%rbx,%r14,8), %rdi
testq %rdi, %rdi
je 0x28f30
addq $-0x8, %rdi
callq 0x2984b
decq %r14
jne 0x28f1d
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2984b
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/zmalloc.c
// Function: zmalloc_get_private_dirty
size_t zmalloc_get_private_dirty(void) {
    char line[1024];
    size_t pd = 0;
    FILE *fp = fopen("/proc/self/smaps","r");

    if (!fp) return 0;
    while(fgets(line,sizeof(line),fp) != NULL) {
        if (strncmp(line,"Private_Dirty:",14) == 0) {
            char *p = strchr(line,'k');
            if (p) {
                *p = '\0';
                pd += strtol(line+14,NULL,10) * 1024;
            }
        }
    }
    fclose(fp);
    return pd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
leaq 0x6d1a1(%rip), %rdi     # 0x96bcc
leaq 0x78658(%rip), %rsi     # 0xa208a
callq 0x1f360
testq %rax, %rax
je 0x29acd
movq %rax, %rbx
movq %rsp, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x1f430
testq %rax, %rax
je 0x29ad2
leaq 0xe(%rsp), %r15
xorl %r14d, %r14d
movabsq $0x5f65746176697250, %r13 # imm = 0x5F65746176697250
movabsq $0x3a79747269445f65, %rbp # imm = 0x3A79747269445F65
movq %rsp, %r12
movq (%rsp), %rax
xorq %r13, %rax
movq 0x6(%rsp), %rcx
xorq %rbp, %rcx
orq %rax, %rcx
jne 0x29ab6
movq %r12, %rdi
movl $0x6b, %esi
callq 0x1f790
testq %rax, %rax
je 0x29ab6
movb $0x0, (%rax)
movq %r15, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x1f6d0
shlq $0xa, %rax
addq %rax, %r14
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdx
callq 0x1f430
testq %rax, %rax
jne 0x29a77
jmp 0x29ad5
xorl %r14d, %r14d
jmp 0x29add
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x1f9a0
movq %r14, %rax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/zipmap.c
// Function: zipmapLookupRaw
static unsigned char *zipmapLookupRaw(unsigned char *zm, unsigned char *key, unsigned int klen, unsigned int *totlen) {

    // zm+1 略过 <zmlen> 属性，将 p 指向 zipmap 的首个节点
    unsigned char *p = zm+1, *k = NULL;
    unsigned int l,llen;

    // 遍历整个 zipmap 来寻找
    // T = O(N^2)
    while(*p != ZIPMAP_END) {
        unsigned char free;

        /* Match or skip the key */
        // 计算键的长度
        l = zipmapDecodeLength(p);
        // 计算编码键的长度所需的字节数
        llen = zipmapEncodeLength(NULL,l);
        // 对比 key
        // T = O(N)
        if (key != NULL && k == NULL && l == klen && !memcmp(p+llen,key,l)) {
            /* Only return when the user doesn't care
             * for the total length of the zipmap. */
            if (totlen != NULL) {
                // 如果调用者需要知道整个 zipmap 的长度，那么记录找到的指针到变量 k
                // 之后遍历时，程序只计算 zipmap 剩余节点的长度，不再用 memcmp 进行对比
                // 因为 k 已经不为 NULL 了
                k = p;
            } else {
                // 如果调用者不需要知道整个 zipmap 的长度，那么直接返回 p 
                return p;
            }
        }

        // 越过键节点，指向值节点
        p += llen+l;

        /* Skip the value as well */
        // 计算值的长度
        l = zipmapDecodeLength(p);
        // 计算编码值的长度所需的字节数，
        // 并移动指针 p ，越过该 <len> 属性，指向 <free> 属性
        p += zipmapEncodeLength(NULL,l);
        // 取出 <free> 属性的值
        free = p[0];
        // 略过值节点，指向下一节点
        p += l+1+free; /* +1 to skip the free byte */
    }

    // 计算并记录 zipmap 的空间长度
    // + 1 是将 ZIPMAP_END 也计算在内
    if (totlen != NULL) *totlen = (unsigned int)(p-zm)+1;

    // 返回找到 key 的指针
    return k;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbp
movl %edx, %r15d
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
leaq 0x1(%rdi), %r13
xorl %eax, %eax
movzbl (%r13), %r14d
cmpl $0xfe, %r14d
je 0x2a5a1
cmpl $0xff, %r14d
jne 0x2a5a5
jmp 0x2a64c
movl 0x1(%r13), %r14d
xorl %edx, %edx
cmpl $0xfe, %r14d
setae %dl
leal 0x1(,%rdx,4), %r12d
testq %rbx, %rbx
je 0x2a600
testq %rax, %rax
jne 0x2a600
cmpl %r15d, %r14d
jne 0x2a5fe
testq %rbp, %rbp
sete 0x7(%rsp)
movl %r12d, %edi
addq %r13, %rdi
movl %r14d, %edx
movq %rbx, %rsi
callq 0x1f6a0
xorl %edi, %edi
testl %eax, %eax
sete %dl
movq %r13, %rax
cmovneq %rdi, %rax
testb %dl, 0x7(%rsp)
je 0x2a600
xorl %eax, %eax
movq %r13, 0x8(%rsp)
jmp 0x2a641
xorl %eax, %eax
addl %r14d, %r12d
leaq (%r12,%r13), %rdx
movzbl (%r13,%r12), %r8d
cmpl $0xfd, %r8d
jbe 0x2a61a
movl 0x1(%rdx), %r8d
xorl %r10d, %r10d
cmpl $0xfe, %r8d
setae %r10b
leaq (%rdx,%r10,4), %rdi
movzbl 0x1(%rdx,%r10,4), %edx
addl %r8d, %edx
incl %edx
leaq (%rdx,%rdi), %r13
incq %r13
movb $0x1, %dil
testb %dil, %dil
jne 0x2a585
jmp 0x2a662
testq %rbp, %rbp
je 0x2a65d
subl 0x10(%rsp), %r13d
incl %r13d
movl %r13d, (%rbp)
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/zipmap.c
// Function: zipmapRawEntryLength
static unsigned int zipmapDecodeLength(unsigned char *p) {

    unsigned int len = *p;

    // 单字节长度
    if (len < ZIPMAP_BIGLEN) return len;

    // 5 字节长度
    memcpy(&len,p+1,sizeof(unsigned int));
    memrev32ifbe(&len);
    return len;
}

// Assembly:
movzbl (%rdi), %eax
cmpl $0xfd, %eax
jbe 0x2a683
movl 0x1(%rdi), %eax
xorl %ecx, %ecx
cmpl $0xfe, %eax
setae %cl
leal (%rax,%rcx,4), %eax
incl %eax
leaq (%rdi,%rax), %rcx
movzbl (%rdi,%rax), %edx
cmpl $0xfd, %edx
jbe 0x2a6a5
movl 0x1(%rcx), %edx
xorl %esi, %esi
cmpl $0xfe, %edx
setae %sil
movzbl 0x1(%rcx,%rsi,4), %ecx
addl %edx, %eax
addl %ecx, %eax
leal (%rax,%rsi,4), %eax
addl $0x2, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/zipmap.c
// Function: zipmapDel
unsigned char *zipmapDel(unsigned char *zm, unsigned char *key, unsigned int klen, int *deleted) {

    unsigned int zmlen, freelen;

    // T = O(N^2)
    unsigned char *p = zipmapLookupRaw(zm,key,klen,&zmlen);
    if (p) {
        // 找到，进行删除

        // 计算节点的总长
        freelen = zipmapRawEntryLength(p);
        // 移动内存，覆盖被删除的数据
        // T = O(N)
        memmove(p, p+freelen, zmlen-((p-zm)+freelen+1));
        // 缩小 zipmap 
        // T = O(N)
        zm = zipmapResize(zm, zmlen-freelen);

        /* Decrease zipmap length */
        // 减少 zipmap 的节点数量
        // 注意，如果节点数量已经大于等于 ZIPMAP_BIGLEN 
        // 那么这里不会进行减少，只有在调用 zipmapLen 的时候
        // 如果有需要的话，正确的节点数量才会被设置
        // 具体请看 zipmapLen 的源码
        if (zm[0] < ZIPMAP_BIGLEN) zm[0]--;

        if (deleted) *deleted = 1;
    } else {
        if (deleted) *deleted = 0;
    }

    return zm;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdi, %r14
leaq 0x4(%rsp), %rcx
callq 0x2a563
testq %rax, %rax
je 0x2a73b
movq %rax, %r15
movq %rax, %rdi
callq 0x2a676
movl %eax, %ebp
movl %eax, %eax
leaq (%r15,%rax), %rsi
movl 0x4(%rsp), %ecx
movq %r15, %rdx
subq %r14, %rdx
addq %rax, %rdx
notq %rdx
addq %rcx, %rdx
movq %r15, %rdi
callq 0x1f780
movl 0x4(%rsp), %r15d
subl %ebp, %r15d
movq %r14, %rdi
movq %r15, %rsi
callq 0x297b5
movq %rax, %r14
decl %r15d
movb $-0x1, (%rax,%r15)
movb (%rax), %al
cmpb $-0x3, %al
ja 0x2a734
decb %al
movb %al, (%r14)
movl $0x1, %eax
jmp 0x2a73d
xorl %eax, %eax
testq %rbx, %rbx
je 0x2a744
movl %eax, (%rbx)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq