LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: rewriteClientCommandArgument
void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
    robj *oldval;
   
    redisAssertWithInfo(c,NULL,i < c->argc);
    oldval = c->argv[i];
    c->argv[i] = newval;
    incrRefCount(newval);
    decrRefCount(oldval);

    /* If this is the command name make sure to fix c->cmd. */
    if (i == 0) {
        c->cmd = lookupCommandOrOriginal(c->argv[0]->ptr);
        redisAssertWithInfo(c,NULL,c->cmd != NULL);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl %esi, 0x30(%rdi)
jle 0x2fa1c
movq 0x38(%rbx), %rax
movslq %esi, %r15
movq (%rax,%r15,8), %r14
movq %rdx, (%rax,%r15,8)
movq %rdx, %rdi
callq 0x306f3
movq %r14, %rdi
callq 0x30b0c
testl %r15d, %r15d
jne 0x2fa16
movq 0x38(%rbx), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
callq 0x25c2f
movq %rax, 0x40(%rbx)
testq %rax, %rax
je 0x2fa37
popq %rbx
popq %r14
popq %r15
retq
leaq 0x677ca(%rip), %rdx     # 0x971ed
leaq 0x67374(%rip), %rcx     # 0x96d9e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x772, %r8d            # imm = 0x772
jmp 0x2fa50
leaq 0x677a0(%rip), %rdx     # 0x971de
leaq 0x67359(%rip), %rcx     # 0x96d9e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x77b, %r8d            # imm = 0x77B
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: getClientLimitClassByName
int getClientLimitClassByName(char *name) {
    if (!strcasecmp(name,"normal")) return REDIS_CLIENT_LIMIT_CLASS_NORMAL;
    else if (!strcasecmp(name,"slave")) return REDIS_CLIENT_LIMIT_CLASS_SLAVE;
    else if (!strcasecmp(name,"pubsub")) return REDIS_CLIENT_LIMIT_CLASS_PUBSUB;
    else return -1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x67757(%rip), %rsi     # 0x971f9
callq 0x1f2e0
testl %eax, %eax
je 0x2fada
leaq 0x6d3c8(%rip), %rsi     # 0x9ce7a
movq %rbx, %rdi
callq 0x1f2e0
testl %eax, %eax
je 0x2fade
leaq 0x64b4d(%rip), %rsi     # 0x94612
movq %rbx, %rdi
callq 0x1f2e0
movl %eax, %ecx
xorl %eax, %eax
negl %ecx
sbbl %eax, %eax
orl $0x2, %eax
jmp 0x2fae3
xorl %eax, %eax
jmp 0x2fae3
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: flushSlavesOutputBuffers
void flushSlavesOutputBuffers(void) {
    listIter li;
    listNode *ln;

    listRewind(server.slaves,&li);
    while((ln = listNext(&li))) {
        redisClient *slave = listNodeValue(ln);
        int events;

        events = aeGetFileEvents(server.el,slave->fd);
        if (events & AE_WRITABLE &&
            slave->replstate == REDIS_REPL_ONLINE &&
            listLength(slave->reply))
        {
            sendReplyToClient(server.el,slave->fd,slave,0);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq 0x9a3dd(%rip), %r15     # 0xc9fa8
movq 0x1c0(%r15), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0x20637
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
je 0x2fc2e
movq %rsp, %rbx
movq 0x10(%rax), %r14
movq 0x28(%r15), %rdi
movl (%r14), %esi
callq 0x20dac
testb $0x2, %al
je 0x2fc21
cmpl $0x9, 0x98(%r14)
jne 0x2fc21
movq 0x60(%r14), %rax
cmpq $0x0, 0x28(%rax)
je 0x2fc21
movl (%r14), %esi
movq %r14, %rdx
callq 0x2d3cc
movq %rbx, %rdi
callq 0x20654
testq %rax, %rax
jne 0x2fbed
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/networking.c
// Function: processEventsWhileBlocked
int processEventsWhileBlocked(void) {
    int iterations = 4; /* See the function top-comment. */
    int count = 0;
    while (iterations--) {
        int events = aeProcessEvents(server.el, AE_FILE_EVENTS|AE_DONT_WAIT);
        if (!events) break;
        count += events;
    }
    return count;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
xorl %ebx, %ebx
movl $0xfffffffb, %ebp       # imm = 0xFFFFFFFB
leaq 0x9a35e(%rip), %r14     # 0xc9fa8
incl %ebp
je 0x2fc62
movq 0x28(%r14), %rdi
movl $0x5, %esi
callq 0x20f22
addl %eax, %ebx
testl %eax, %eax
jne 0x2fc4a
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/util.c
// Function: ll2string
int ll2string(char *s, size_t len, long long value) {
    char buf[32], *p;
    unsigned long long v;
    size_t l;

    if (len == 0) return 0;
    v = (value < 0) ? -value : value;
    p = buf+31; /* point to the last character */
    do {
        *p-- = '0'+(v%10);
        v /= 10;
    } while(v);
    if (value < 0) *p-- = '-';
    p++;
    l = 32-(p-buf);
    if (l+1 > len) l = len-1; /* Make sure it fits, including the nul term */
    memcpy(s,p,l);
    s[l] = '\0';
    return l;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
testq %rsi, %rsi
je 0x30169
movq %rdx, %rcx
movq %rdi, %rbx
movq %rdx, %rdi
negq %rdi
cmovsq %rdx, %rdi
xorl %r8d, %r8d
movabsq $-0x3333333333333333, %r9 # imm = 0xCCCCCCCCCCCCCCCD
movq %rdi, %rax
mulq %r9
shrq $0x3, %rdx
leal (%rdx,%rdx), %eax
leal (%rax,%rax,4), %eax
movl %edi, %r10d
subl %eax, %r10d
orb $0x30, %r10b
movb %r10b, 0x1f(%rsp,%r8)
decq %r8
cmpq $0x9, %rdi
movq %rdx, %rdi
ja 0x300f6
movq $-0x1, %r15
testq %rcx, %rcx
jns 0x3013a
movb $0x2d, 0x1f(%rsp,%r8)
movq $-0x2, %r15
addq %r8, %r15
leaq (%rsp,%r15), %rax
addq $0x21, %rax
negq %r15
cmpq %rsi, %r15
cmovaq %rsi, %r15
leaq -0x1(%r15), %r14
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x1fbd0
movb $0x0, -0x1(%rbx,%r15)
jmp 0x3016c
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/util.c
// Function: getRandomHexChars
void getRandomHexChars(char *p, unsigned int len) {
    FILE *fp = fopen("/dev/urandom","r");
    char *charset = "0123456789abcdef";
    unsigned int j;

    if (fp == NULL || fread(p,len,1,fp) == 0) {
        /* If we can't read from /dev/urandom, do some reasonable effort
         * in order to create some entropy, since this function is used to
         * generate run_id and cluster instance IDs */
        char *x = p;
        unsigned int l = len;
        struct timeval tv;
        pid_t pid = getpid();

        /* Use time and PID to fill the initial array. */
        gettimeofday(&tv,NULL);
        if (l >= sizeof(tv.tv_usec)) {
            memcpy(x,&tv.tv_usec,sizeof(tv.tv_usec));
            l -= sizeof(tv.tv_usec);
            x += sizeof(tv.tv_usec);
        }
        if (l >= sizeof(tv.tv_sec)) {
            memcpy(x,&tv.tv_sec,sizeof(tv.tv_sec));
            l -= sizeof(tv.tv_sec);
            x += sizeof(tv.tv_sec);
        }
        if (l >= sizeof(pid)) {
            memcpy(x,&pid,sizeof(pid));
            l -= sizeof(pid);
            x += sizeof(pid);
        }
        /* Finally xor it with rand() output, that was already seeded with
         * time() at startup. */
        for (j = 0; j < len; j++)
            p[j] ^= rand();
    }
    /* Turn it into hex digits taking just 4 bits out of 8 for every byte. */
    for (j = 0; j < len; j++)
        p[j] = charset[p[j] & 0x0F];
    if (fp) fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x66f9a(%rip), %rdi     # 0x9731f
leaq 0x71d8e(%rip), %rsi     # 0xa211a
callq 0x1fa60
movq %rax, %r14
movl %r12d, %r15d
testq %rax, %rax
je 0x303b4
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rcx
callq 0x1f7c0
testq %rax, %rax
jne 0x3041d
callq 0x1f410
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x1f2f0
movq %rbx, %rax
movl %r12d, %ecx
cmpl $0x8, %r12d
jb 0x303fd
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
leal -0x8(%r12), %ecx
cmpl $0x8, %ecx
jb 0x303f9
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
leal -0x10(%r12), %ecx
leaq 0x10(%rbx), %rax
jmp 0x303fd
leaq 0x8(%rbx), %rax
cmpl $0x4, %ecx
jb 0x30404
movl %ebp, (%rax)
testl %r12d, %r12d
je 0x3041d
xorl %r13d, %r13d
callq 0x1faf0
xorb %al, (%rbx,%r13)
incq %r13
cmpq %r13, %r15
jne 0x3040c
testl %r12d, %r12d
je 0x30440
xorl %eax, %eax
leaq 0x66f01(%rip), %rcx     # 0x9732c
movzbl (%rbx,%rax), %edx
andl $0xf, %edx
movb (%rdx,%rcx), %dl
movb %dl, (%rbx,%rax)
incq %rax
cmpq %rax, %r15
jne 0x3042b
testq %r14, %r14
je 0x3045b
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f9a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createEmbeddedStringObject
robj *createEmbeddedStringObject(char *ptr, size_t len) {
    robj *o = zmalloc(sizeof(robj)+sizeof(struct sdshdr)+len+1);
    struct sdshdr *sh = (void*)(o+1);

    o->type = REDIS_STRING;
    o->encoding = REDIS_ENCODING_EMBSTR;
    o->ptr = sh+1;
    o->refcount = 1;
    o->lru = LRU_CLOCK();

    sh->len = len;
    sh->free = 0;
    if (ptr) {
        memcpy(sh->buf,ptr,len);
        sh->buf[len] = '\0';
    } else {
        memset(sh->buf,0,len+1);
    }
    return o;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x19(%rsi), %rdi
callq 0x299b5
movq %rax, %r14
movb $-0x80, (%rax)
leaq 0x18(%rax), %r12
movq %r12, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x9996c(%rip), %rax     # 0xc9fa8
movl 0x30(%rax), %eax
shll $0x8, %eax
orl $0x80, %eax
movl %eax, (%r14)
movl %ebx, 0x10(%r14)
movl $0x0, 0x14(%r14)
testq %r15, %r15
je 0x30670
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1fbd0
movb $0x0, (%r12,%rbx)
jmp 0x30680
incq %rbx
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1f110
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: dupStringObject
robj *dupStringObject(robj *o) {
    robj *d;

    redisAssert(o->type == REDIS_STRING);

    switch(o->encoding) {

    case REDIS_ENCODING_RAW:
        return createRawStringObject(o->ptr,sdslen(o->ptr));

    case REDIS_ENCODING_EMBSTR:
        return createEmbeddedStringObject(o->ptr,sdslen(o->ptr));

    case REDIS_ENCODING_INT:
        d = createObject(REDIS_STRING, NULL);
        d->encoding = REDIS_ENCODING_INT;
        d->ptr = o->ptr;
        return d;

    default:
        redisPanic("Wrong encoding.");
        break;
    }
}

// Assembly:
pushq %rbx
movl (%rdi), %eax
testb $0xf, %al
jne 0x307dd
movq %rdi, %rbx
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x307cf
cmpl $0x1, %eax
je 0x30797
testl %eax, %eax
jne 0x307f7
movq 0x8(%rbx), %rdi
movslq -0x8(%rdi), %rsi
popq %rbx
jmp 0x305d7
movl $0x10, %edi
callq 0x299b5
movb $0x0, (%rax)
movq $0x0, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x997ee(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x10, %ecx
movl %ecx, (%rax)
movq 0x8(%rbx), %rcx
movq %rcx, 0x8(%rax)
popq %rbx
retq
movq 0x8(%rbx), %rdi
movslq -0x8(%rdi), %rsi
popq %rbx
jmp 0x30609
leaq 0x665a2(%rip), %rdi     # 0x96d86
leaq 0x66b74(%rip), %rsi     # 0x9735f
movl $0xc0, %edx
callq 0x4ca32
jmp 0x3080f
leaq 0x66b6a(%rip), %rdi     # 0x97368
leaq 0x66b5a(%rip), %rsi     # 0x9735f
movl $0xd1, %edx
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createListObject
robj *createListObject(void) {

    list *l = listCreate();

    robj *o = createObject(REDIS_LIST,l);

    listSetFreeMethod(l,decrRefCountVoid);

    o->encoding = REDIS_ENCODING_LINKEDLIST;

    return o;
}

// Assembly:
pushq %rbx
callq 0x203fc
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x1, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x99767(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
incl %ecx
movl %ecx, (%rax)
leaq 0x12(%rip), %rcx        # 0x30864
movq %rcx, 0x18(%rbx)
movl $0xffffff0f, %ecx       # imm = 0xFFFFFF0F
andl (%rax), %ecx
orl $0x40, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createZiplistObject
robj *createZiplistObject(void) {

    unsigned char *zl = ziplistNew();

    robj *o = createObject(REDIS_LIST,zl);

    o->encoding = REDIS_ENCODING_ZIPLIST;

    return o;
}

// Assembly:
pushq %rbx
callq 0x2be40
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x1, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x99717(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x51, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createSetObject
robj *createSetObject(void) {

    dict *d = dictCreate(&setDictType,NULL);

    robj *o = createObject(REDIS_SET,d);

    o->encoding = REDIS_ENCODING_HT;

    return o;
}

// Assembly:
pushq %rbx
leaq 0x98fca(%rip), %rdi     # 0xc9870
xorl %esi, %esi
callq 0x2217b
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x2, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x996d9(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x22, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createIntsetObject
robj *createIntsetObject(void) {

    intset *is = intsetNew();

    robj *o = createObject(REDIS_SET,is);

    o->encoding = REDIS_ENCODING_INTSET;

    return o;
}

// Assembly:
pushq %rbx
callq 0x4f068
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x2, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x996a4(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x62, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createHashObject
robj *createHashObject(void) {

    unsigned char *zl = ziplistNew();

    robj *o = createObject(REDIS_HASH, zl);

    o->encoding = REDIS_ENCODING_ZIPLIST;

    return o;
}

// Assembly:
pushq %rbx
callq 0x2be40
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x4, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x9966f(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x54, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createZsetObject
robj *createZsetObject(void) {

    zset *zs = zmalloc(sizeof(*zs));

    robj *o;

    zs->dict = dictCreate(&zsetDictType,NULL);
    zs->zsl = zslCreate();

    o = createObject(REDIS_ZSET,zs);

    o->encoding = REDIS_ENCODING_SKIPLIST;

    return o;
}

// Assembly:
pushq %rbx
movl $0x10, %edi
callq 0x299b5
movq %rax, %rbx
leaq 0x98f45(%rip), %rdi     # 0xc98a0
xorl %esi, %esi
callq 0x2217b
movq %rax, (%rbx)
callq 0x3d036
movq %rax, 0x8(%rbx)
movl $0x10, %edi
callq 0x299b5
movb $0x3, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x9961b(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x73, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: createZsetZiplistObject
robj *createZsetZiplistObject(void) {

    unsigned char *zl = ziplistNew();

    robj *o = createObject(REDIS_ZSET,zl);

    o->encoding = REDIS_ENCODING_ZIPLIST;

    return o;
}

// Assembly:
pushq %rbx
callq 0x2be40
movq %rax, %rbx
movl $0x10, %edi
callq 0x299b5
movb $0x3, (%rax)
movq %rbx, 0x8(%rax)
movl $0x1, 0x4(%rax)
leaq 0x995e6(%rip), %rcx     # 0xc9fa8
movl 0x30(%rcx), %ecx
shll $0x8, %ecx
orl $0x53, %ecx
movl %ecx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: freeListObject
void freeListObject(robj *o) {

    switch (o->encoding) {

    case REDIS_ENCODING_LINKEDLIST:
        listRelease((list*) o->ptr);
        break;

    case REDIS_ENCODING_ZIPLIST:
        zfree(o->ptr);
        break;

    default:
        redisPanic("Unknown list encoding type");
    }
}

// Assembly:
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
je 0x309f9
cmpl $0x4, %eax
jne 0x30a02
movq 0x8(%rdi), %rdi
jmp 0x2041c
movq 0x8(%rdi), %rdi
jmp 0x29af7
pushq %rax
leaq 0x66970(%rip), %rdi     # 0x9737a
leaq 0x6694e(%rip), %rsi     # 0x9735f
movl $0x158, %edx            # imm = 0x158
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: freeSetObject
void freeSetObject(robj *o) {

    switch (o->encoding) {

    case REDIS_ENCODING_HT:
        dictRelease((dict*) o->ptr);
        break;

    case REDIS_ENCODING_INTSET:
        zfree(o->ptr);
        break;

    default:
        redisPanic("Unknown set encoding type");
    }
}

// Assembly:
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
je 0x30a40
cmpl $0x2, %eax
jne 0x30a49
movq 0x8(%rdi), %rdi
jmp 0x229a9
movq 0x8(%rdi), %rdi
jmp 0x29af7
pushq %rax
leaq 0x66946(%rip), %rdi     # 0x97397
leaq 0x66907(%rip), %rsi     # 0x9735f
movl $0x16c, %edx            # imm = 0x16C
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: freeZsetObject
void freeZsetObject(robj *o) {

    zset *zs;

    switch (o->encoding) {

    case REDIS_ENCODING_SKIPLIST:
        zs = o->ptr;
        dictRelease(zs->dict);
        zslFree(zs->zsl);
        zfree(zs);
        break;

    case REDIS_ENCODING_ZIPLIST:
        zfree(o->ptr);
        break;

    default:
        redisPanic("Unknown sorted set encoding");
    }
}

// Assembly:
pushq %rbx
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
je 0x30a99
cmpl $0x7, %eax
jne 0x30aa3
movq 0x8(%rdi), %rbx
movq (%rbx), %rdi
callq 0x229a9
movq 0x8(%rbx), %rdi
callq 0x3d0aa
movq %rbx, %rdi
jmp 0x30a9d
movq 0x8(%rdi), %rdi
popq %rbx
jmp 0x29af7
leaq 0x66909(%rip), %rdi     # 0x973b3
leaq 0x668ae(%rip), %rsi     # 0x9735f
movl $0x185, %edx            # imm = 0x185
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: freeHashObject
void freeHashObject(robj *o) {

    switch (o->encoding) {

    case REDIS_ENCODING_HT:
        dictRelease((dict*) o->ptr);
        break;

    case REDIS_ENCODING_ZIPLIST:
        zfree(o->ptr);
        break;

    default:
        redisPanic("Unknown hash encoding type");
        break;
    }
}

// Assembly:
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
je 0x30ae0
cmpl $0x2, %eax
jne 0x30ae9
movq 0x8(%rdi), %rdi
jmp 0x229a9
movq 0x8(%rdi), %rdi
jmp 0x29af7
pushq %rax
leaq 0x668e0(%rip), %rdi     # 0x973d1
leaq 0x66867(%rip), %rsi     # 0x9735f
movl $0x199, %edx            # imm = 0x199
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: decrRefCount
void decrRefCount(robj *o) {

    if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0");

    // 释放对象
    if (o->refcount == 1) {
        switch(o->type) {
        case REDIS_STRING: freeStringObject(o); break;
        case REDIS_LIST: freeListObject(o); break;
        case REDIS_SET: freeSetObject(o); break;
        case REDIS_ZSET: freeZsetObject(o); break;
        case REDIS_HASH: freeHashObject(o); break;
        default: redisPanic("Unknown object type"); break;
        }
        zfree(o);

    // 减少计数
    } else {
        o->refcount--;
    }
}

// Assembly:
pushq %rbx
movl 0x4(%rdi), %eax
testl %eax, %eax
jle 0x30b7d
movq %rdi, %rbx
cmpl $0x1, %eax
jne 0x30b47
movl (%rbx), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
ja 0x30b9f
leaq 0x66815(%rip), %rdx     # 0x97344
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
testb $-0x10, %al
jne 0x30b74
movq 0x8(%rbx), %rdi
callq 0x2850d
jmp 0x30b74
decl %eax
movl %eax, 0x4(%rbx)
popq %rbx
retq
movq %rbx, %rdi
callq 0x30ac5
jmp 0x30b74
movq %rbx, %rdi
callq 0x30a25
jmp 0x30b74
movq %rbx, %rdi
callq 0x30a6c
jmp 0x30b74
movq %rbx, %rdi
callq 0x309de
movq %rbx, %rdi
popq %rbx
jmp 0x29af7
leaq 0x6686a(%rip), %rdi     # 0x973ee
leaq 0x667d4(%rip), %rsi     # 0x9735f
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
leaq 0x6686d(%rip), %rdi     # 0x97413
leaq 0x667b2(%rip), %rsi     # 0x9735f
movl $0x1b6, %edx            # imm = 0x1B6
jmp 0x30b90
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: isObjectRepresentableAsLongLong
int isObjectRepresentableAsLongLong(robj *o, long long *llval) {

    redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);

    // INT 编码的 long 值总是能保存为 long long
    if (o->encoding == REDIS_ENCODING_INT) {
        if (llval) *llval = (long) o->ptr;
        return REDIS_OK;

    // 如果是字符串的话，那么尝试将它转换为 long long
    } else {
        return string2ll(o->ptr,sdslen(o->ptr),llval) ? REDIS_OK : REDIS_ERR;
    }
}

// Assembly:
pushq %rax
movq %rsi, %rdx
movq %rdi, %rsi
movl (%rdi), %eax
testb $0xf, %al
jne 0x30c24
andl $0xf0, %eax
cmpl $0x10, %eax
jne 0x30c0c
xorl %eax, %eax
testq %rdx, %rdx
je 0x30c22
movq 0x8(%rsi), %rcx
movq %rcx, (%rdx)
jmp 0x30c22
movq 0x8(%rsi), %rdi
movslq -0x8(%rdi), %rsi
callq 0x30179
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x1, %ecx
sbbl %eax, %eax
popq %rcx
retq
leaq 0x6615b(%rip), %rdx     # 0x96d86
leaq 0x6672d(%rip), %rcx     # 0x9735f
xorl %edi, %edi
movl $0x1fd, %r8d            # imm = 0x1FD
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getDecodedObject
robj *getDecodedObject(robj *o) {
    robj *dec;

    if (sdsEncodedObject(o)) {
        incrRefCount(o);
        return o;
    }

    // 解码对象，将对象的值从整数转换为字符串
    if (o->type == REDIS_STRING && o->encoding == REDIS_ENCODING_INT) {
        char buf[32];

        ll2string(buf,32,(long)o->ptr);
        dec = createStringObject(buf,strlen(buf));
        return dec;

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

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rax
movl (%rdi), %edx
movl %edx, %ecx
shrl $0x4, %ecx
testb $0x7, %cl
jne 0x30dac
incl 0x4(%rax)
jmp 0x30de0
testb $0xf, %dl
jne 0x30de6
andl $0xf, %ecx
cmpl $0x1, %ecx
jne 0x30de6
movq 0x8(%rax), %rdx
movq %rsp, %rbx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x300c7
movq %rbx, %rdi
callq 0x1f4f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3068f
addq $0x20, %rsp
popq %rbx
retq
leaq 0x6663c(%rip), %rdi     # 0x97429
leaq 0x6656b(%rip), %rsi     # 0x9735f
movl $0x27a, %edx            # imm = 0x27A
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: equalStringObjects
int equalStringObjects(robj *a, robj *b) {

    // 对象的编码为 INT ，直接对比值
    // 这里避免了将整数值转换为字符串，所以效率更高
    if (a->encoding == REDIS_ENCODING_INT &&
        b->encoding == REDIS_ENCODING_INT){
        /* If both strings are integer encoded just check if the stored
         * long is the same. */
        return a->ptr == b->ptr;

    // 进行字符串对象
    } else {
        return compareStringObjects(a,b) == 0;
    }
}

// Assembly:
movl $0xf0, %eax
movl (%rdi), %ecx
andl %eax, %ecx
cmpl $0x10, %ecx
jne 0x30f2a
andl (%rsi), %eax
cmpl $0x10, %eax
jne 0x30f2a
movq 0x8(%rdi), %rax
cmpq 0x8(%rsi), %rax
sete %al
jmp 0x30f3e
pushq %rax
movl $0x1, %edx
callq 0x30e08
testl %eax, %eax
sete %al
addq $0x8, %rsp
movzbl %al, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: stringObjectLen
size_t stringObjectLen(robj *o) {

    redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);

    if (sdsEncodedObject(o)) {
        return sdslen(o->ptr);

    // INT 编码，计算将这个值转换为字符串要多少字节
    // 相当于返回它的长度
    } else {
        char buf[32];
        return ll2string(buf,32,(long)o->ptr);
    }
}

// Assembly:
subq $0x28, %rsp
movq %rdi, %rsi
movl (%rdi), %eax
testb $0xf, %al
jne 0x30f77
shrl $0x4, %eax
testb $0x7, %al
jne 0x30f5f
movq 0x8(%rsi), %rax
movl -0x8(%rax), %eax
jmp 0x30f70
movq 0x8(%rsi), %rdx
movq %rsp, %rdi
movl $0x20, %esi
callq 0x300c7
cltq
addq $0x28, %rsp
retq
leaq 0x65e08(%rip), %rdx     # 0x96d86
leaq 0x663da(%rip), %rcx     # 0x9735f
xorl %edi, %edi
movl $0x2e5, %r8d            # imm = 0x2E5
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getDoubleFromObject
int getDoubleFromObject(robj *o, double *target) {
    double value;
    char *eptr;

    if (o == NULL) {
        value = 0;

    } else {
        redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);

        // 尝试从字符串中转换 double 值
        if (sdsEncodedObject(o)) {
            errno = 0;
            value = strtod(o->ptr, &eptr);
            if (isspace(((char*)o->ptr)[0]) ||
                eptr[0] != '\0' ||
                (errno == ERANGE &&
                    (value == HUGE_VAL || value == -HUGE_VAL || value == 0)) ||
                errno == EINVAL ||
                isnan(value))
                return REDIS_ERR;

        // INT 编码
        } else if (o->encoding == REDIS_ENCODING_INT) {
            value = (long)o->ptr;

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

    // 返回值
    *target = value;
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
testq %rdi, %rdi
je 0x31061
movq %rdi, %r14
movl (%rdi), %eax
testb $0xf, %al
jne 0x3107d
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x30fda
cmpl $0x1, %eax
je 0x31067
testl %eax, %eax
jne 0x3109d
callq 0x1f810
movq %rax, %r15
movl $0x0, (%rax)
movq 0x8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1fc40
movsd %xmm0, (%rsp)
callq 0x1f550
movq (%rax), %rcx
movq 0x8(%r14), %rax
movsbq (%rax), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x31073
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x31073
movl (%r15), %ecx
cmpl $0x22, %ecx
movq (%rsp), %xmm0
jne 0x31054
movq %xmm0, %rdx
btrq $0x3f, %rdx
movabsq $0x7ff0000000000000, %rsi # imm = 0x7FF0000000000000
cmpq %rsi, %rdx
sete %sil
testq %rdx, %rdx
sete %dl
orb %sil, %dl
jne 0x31073
cmpl $0x16, %ecx
je 0x31073
ucomisd %xmm0, %xmm0
jnp 0x3106d
jmp 0x31073
xorpd %xmm0, %xmm0
jmp 0x3106d
cvtsi2sdq 0x8(%r14), %xmm0
movsd %xmm0, (%rbx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x65d02(%rip), %rdx     # 0x96d86
leaq 0x662d4(%rip), %rcx     # 0x9735f
xorl %edi, %edi
movq %r14, %rsi
movl $0x301, %r8d            # imm = 0x301
callq 0x4d277
jmp 0x310b5
leaq 0x663d0(%rip), %rdi     # 0x97474
leaq 0x662b4(%rip), %rsi     # 0x9735f
movl $0x314, %edx            # imm = 0x314
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getDoubleFromObjectOrReply
int getDoubleFromObjectOrReply(redisClient *c, robj *o, double *target, const char *msg) {

    double value;

    if (getDoubleFromObject(o, &value) != REDIS_OK) {
        if (msg != NULL) {
            addReplyError(c,(char*)msg);
        } else {
            addReplyError(c,"value is not a valid float");
        }
        return REDIS_ERR;
    }

    *target = value;
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %rax
movq %rdi, %r14
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x30f9c
testl %eax, %eax
je 0x310f2
testq %rbx, %rbx
je 0x31101
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x3110b
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r15)
xorl %eax, %eax
jmp 0x31115
leaq 0x685d1(%rip), %rsi     # 0x996d9
movq %r14, %rdi
callq 0x2dc63
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getLongDoubleFromObject
int getLongDoubleFromObject(robj *o, long double *target) {
    long double value;
    char *eptr;

    if (o == NULL) {
        value = 0;
    } else {

        redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);

        // RAW 编码，尝试从字符串中转换 long double
        if (sdsEncodedObject(o)) {
            errno = 0;
            value = strtold(o->ptr, &eptr);
            if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
                errno == ERANGE || isnan(value))
                return REDIS_ERR;

        // INT 编码，直接保存
        } else if (o->encoding == REDIS_ENCODING_INT) {
            value = (long)o->ptr;

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

    *target = value;
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
fldz
testq %rdi, %rdi
je 0x311c4
movq %rdi, %r14
fstp %st(0)
movl (%rdi), %eax
testb $0xf, %al
jne 0x311d6
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x3115d
cmpl $0x1, %eax
je 0x311b9
testl %eax, %eax
jne 0x311f6
callq 0x1f810
movq %rax, %r15
movl $0x0, (%rax)
movq 0x8(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1f0f0
fstpt 0x14(%rsp)
callq 0x1f550
movq (%rax), %rcx
movq 0x8(%r14), %rax
movsbq (%rax), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x311c8
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x311c8
cmpl $0x22, (%r15)
sete %cl
fldt 0x14(%rsp)
fucomi %st(0), %st
setp %dl
orb %cl, %dl
je 0x311c4
jmp 0x311ca
movq 0x8(%r14), %rax
movq %rax, (%rsp)
fildll (%rsp)
fstpt (%rbx)
xorl %eax, %eax
fldz
fstp %st(0)
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x65ba9(%rip), %rdx     # 0x96d86
leaq 0x6617b(%rip), %rcx     # 0x9735f
xorl %edi, %edi
movq %r14, %rsi
movl $0x344, %r8d            # imm = 0x344
callq 0x4d277
jmp 0x3120e
leaq 0x66277(%rip), %rdi     # 0x97474
leaq 0x6615b(%rip), %rsi     # 0x9735f
movl $0x353, %edx            # imm = 0x353
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getLongDoubleFromObjectOrReply
int getLongDoubleFromObjectOrReply(redisClient *c, robj *o, long double *target, const char *msg) {

    long double value;

    if (getLongDoubleFromObject(o, &value) != REDIS_OK) {
        if (msg != NULL) {
            addReplyError(c,(char*)msg);
        } else {
            addReplyError(c,"value is not a valid float");
        }
        return REDIS_ERR;
    }

    *target = value;
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %rax
movq %rdi, %r14
movq %rsp, %rsi
movq %rax, %rdi
callq 0x3111f
testl %eax, %eax
je 0x31249
testq %rbx, %rbx
je 0x31253
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x3125d
fldt (%rsp)
fstpt (%r15)
xorl %eax, %eax
jmp 0x31267
leaq 0x6847f(%rip), %rsi     # 0x996d9
movq %r14, %rdi
callq 0x2dc63
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getLongLongFromObject
int getLongLongFromObject(robj *o, long long *target) {
    long long value;
    char *eptr;

    if (o == NULL) {
        // o 为 NULL 时，将值设为 0 。
        value = 0;
    } else {

        // 确保对象为 REDIS_STRING 类型
        redisAssertWithInfo(NULL,o,o->type == REDIS_STRING);
        if (sdsEncodedObject(o)) {
            errno = 0;
            // T = O(N)
            value = strtoll(o->ptr, &eptr, 10);
            if (isspace(((char*)o->ptr)[0]) || eptr[0] != '\0' ||
                errno == ERANGE)
                return REDIS_ERR;
        } else if (o->encoding == REDIS_ENCODING_INT) {
            // 对于 REDIS_ENCODING_INT 编码的整数值
            // 直接将它的值保存到 value 中
            value = (long)o->ptr;
        } else {
            redisPanic("Unknown string encoding");
        }
    }

    // 保存值到指针
    if (target) *target = value;

    // 返回结果标识符
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %r15d, %r15d
testq %rdi, %rdi
je 0x312fd
movq %rdi, %r14
movl (%rdi), %eax
testb $0xf, %al
jne 0x31313
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x312a9
cmpl $0x1, %eax
je 0x312f9
testl %eax, %eax
jne 0x31333
callq 0x1f810
movq %rax, %r12
movl $0x0, (%rax)
movq 0x8(%r14), %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x1fa70
movq %rax, %r15
callq 0x1f550
movq (%rax), %rcx
movq 0x8(%r14), %rax
movsbq (%rax), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb $0x20, 0x1(%rcx,%rdx,2)
jne 0x31307
movq (%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x31307
cmpl $0x22, (%r12)
jne 0x312fd
jmp 0x31307
movq 0x8(%r14), %r15
testq %rbx, %rbx
je 0x31305
movq %r15, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x65a6c(%rip), %rdx     # 0x96d86
leaq 0x6603e(%rip), %rcx     # 0x9735f
xorl %edi, %edi
movq %r14, %rsi
movl $0x38a, %r8d            # imm = 0x38A
callq 0x4d277
jmp 0x3134b
leaq 0x6613a(%rip), %rdi     # 0x97474
leaq 0x6601e(%rip), %rsi     # 0x9735f
movl $0x397, %edx            # imm = 0x397
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/object.c
// Function: getLongLongFromObjectOrReply
int getLongLongFromObjectOrReply(redisClient *c, robj *o, long long *target, const char *msg) {

    long long value;

    // T = O(N)
    if (getLongLongFromObject(o, &value) != REDIS_OK) {
        if (msg != NULL) {
            addReplyError(c,(char*)msg);
        } else {
            addReplyError(c,"value is not an integer or out of range");
        }
        return REDIS_ERR;
    }

    *target = value;

    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %rax
movq %rdi, %r14
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x31271
testl %eax, %eax
je 0x31388
testq %rbx, %rbx
je 0x31394
movq %r14, %rdi
movq %rbx, %rsi
jmp 0x3139e
movq 0x8(%rsp), %rax
movq %rax, (%r15)
xorl %eax, %eax
jmp 0x313a8
leaq 0x660f3(%rip), %rsi     # 0x9748e
movq %r14, %rdi
callq 0x2dc63
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: lookupKeyRead
robj *lookupKeyRead(redisDb *db, robj *key) {
    robj *val;

    // 检查 key 释放已经过期
    expireIfNeeded(db,key);

    // 从数据库中取出键的值
    val = lookupKey(db,key);

    // 更新命中/不命中信息
    if (val == NULL)
        server.stat_keyspace_misses++;
    else
        server.stat_keyspace_hits++;

    // 返回值
    return val;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x31673
movq %r14, %rdi
movq %rbx, %rsi
callq 0x315f8
xorl %ecx, %ecx
testq %rax, %rax
sete %cl
leaq 0x98945(%rip), %rdx     # 0xc9fa8
incq 0x368(%rdx,%rcx,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: expireIfNeeded
int expireIfNeeded(redisDb *db, robj *key) {

    // 取出键的过期时间
    mstime_t when = getExpire(db,key);
    mstime_t now;

    // 没有过期时间
    if (when < 0) return 0; /* No expire for this key */

    /* Don't expire anything while loading. It will be done later. */
    // 如果服务器正在进行载入，那么不进行任何过期检查
    if (server.loading) return 0;

    /* If we are in the context of a Lua script, we claim that time is
     * blocked to when the Lua script started. This way a key can expire
     * only the first time it is accessed and not in the middle of the
     * script execution, making propagation to slaves / AOF consistent.
     * See issue #1525 on Github for more information. */
    now = server.lua_caller ? server.lua_time_start : mstime();

    /* If we are running in the context of a slave, return ASAP:
     * the slave key expiration is controlled by the master that will
     * send us synthesized DEL operations for expired keys.
     *
     * Still we try to return the right information to the caller, 
     * that is, 0 if we think the key should be still valid, 1 if
     * we think the key is expired at this time. */
    // 当服务器运行在 replication 模式时
    // 附属节点并不主动删除 key
    // 它只返回一个逻辑上正确的返回值
    // 真正的删除操作要等待主节点发来删除命令时才执行
    // 从而保证数据的同步
    if (server.masterhost != NULL) return now > when;

    // 运行到这里，表示键带有过期时间，并且服务器为主节点

    /* Return when this key has not expired */
    // 如果未过期，返回 0
    if (now <= when) return 0;

    /* Delete the key */
    server.stat_expiredkeys++;

    // 向 AOF 文件和附属节点传播过期信息
    propagateExpire(db,key);

    // 发送事件通知
    notifyKeyspaceEvent(REDIS_NOTIFY_EXPIRED,
        "expired",key,db->id);

    // 将过期键从数据库中删除
    return dbDelete(db,key);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
callq 0x329dd
xorl %ebp, %ebp
testq %rax, %rax
js 0x31719
leaq 0x98910(%rip), %r12     # 0xc9fa8
cmpl $0x0, 0x2f0(%r12)
jne 0x31719
movq %rax, %r15
cmpq $0x0, 0x7f0(%r12)
je 0x316bb
movq 0x808(%r12), %rax
jmp 0x316c0
callq 0x23461
cmpq $0x0, 0x650(%r12)
je 0x316d6
xorl %ebp, %ebp
cmpq %r15, %rax
setg %bpl
jmp 0x31719
cmpq %r15, %rax
jle 0x31719
incq 0x358(%r12)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x32c3a
movl 0x30(%r14), %ecx
leaq 0x6300e(%rip), %rsi     # 0x94707
movl $0x100, %edi            # imm = 0x100
movq %rbx, %rdx
callq 0x60371
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x31a36
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: lookupKeyReadOrReply
robj *lookupKeyReadOrReply(redisClient *c, robj *key, robj *reply) {

    // 查找
    robj *o = lookupKeyRead(c->db, key);

    // 决定是否发送信息
    if (!o) addReply(c,reply);

    return o;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rdi), %r12
movq %r12, %rdi
callq 0x31673
movq %r12, %rdi
movq %r15, %rsi
callq 0x315f8
movq %rax, %r15
xorl %eax, %eax
testq %r15, %r15
sete %al
leaq 0x98829(%rip), %rcx     # 0xc9fa8
incq 0x368(%rcx,%rax,8)
testq %r15, %r15
jne 0x31797
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2d97c
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: dbAdd
void dbAdd(redisDb *db, robj *key, robj *val) {

    // 复制键名
    sds copy = sdsdup(key->ptr);

    // 尝试添加键值对
    int retval = dictAdd(db->dict, copy, val);

    // 如果键已经存在，那么停止
    redisAssertWithInfo(NULL,key,retval == REDIS_OK);

    // 如果开启了集群模式，那么将键保存到槽里面
    if (server.cluster_enabled) slotToKeyAdd(key);
 }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0x8(%rsi), %rdi
callq 0x28504
movq (%r15), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x2249c
testl %eax, %eax
jne 0x3183c
leaq 0x98788(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x7bc(%rax)
je 0x31836
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x31864
popq %rbx
popq %r14
popq %r15
retq
leaq 0x65d0d(%rip), %rdx     # 0x97550
leaq 0x6724f(%rip), %rcx     # 0x98a99
xorl %edi, %edi
movq %rbx, %rsi
movl $0xaf, %r8d
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: slotToKeyAdd
void slotToKeyAdd(robj *key) {

    // 计算出键所属的槽
    unsigned int hashslot = keyHashSlot(key->ptr,sdslen(key->ptr));

    // 将槽 slot 作为分值，键作为成员，添加到 slots_to_keys 跳跃表里面
    zslInsert(server.cluster->slots_to_keys,hashslot,key);
    incrRefCount(key);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movl -0x8(%rdi), %esi
callq 0x50c03
leaq 0x9872d(%rip), %rcx     # 0xc9fa8
movq 0x7d0(%rcx), %rcx
movq 0x60028(%rcx), %rdi
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movq %rbx, %rsi
callq 0x3d10a
movq %rbx, %rdi
popq %rbx
jmp 0x306f3
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: dbOverwrite
void dbOverwrite(redisDb *db, robj *key, robj *val) {
    dictEntry *de = dictFind(db->dict,key->ptr);
    
    // 节点必须存在，否则中止
    redisAssertWithInfo(NULL,key,de != NULL);

    // 覆写旧值
    dictReplace(db->dict, key->ptr, val);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq (%rdi), %rdi
movq 0x8(%rsi), %rsi
callq 0x226ac
testq %rax, %rax
je 0x318d4
movq (%r15), %rdi
movq 0x8(%rbx), %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x2263a
leaq 0x65e39(%rip), %rdx     # 0x97714
leaq 0x671b7(%rip), %rcx     # 0x98a99
xorl %edi, %edi
movq %rbx, %rsi
movl $0xc8, %r8d
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: removeExpire
int removeExpire(redisDb *db, robj *key) {
    /* An expire may only be removed if there is a corresponding entry in the
     * main dict. Otherwise, the key will never be freed. */
    // 确保键带有过期时间
    redisAssertWithInfo(NULL,key,dictFind(db->dict,key->ptr) != NULL);

    // 删除过期时间
    return dictDelete(db->expires,key->ptr) == DICT_OK;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x8(%rsi), %rsi
callq 0x226ac
testq %rax, %rax
je 0x31990
movq 0x8(%r14), %rdi
movq 0x8(%rbx), %rsi
callq 0x22796
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x65d58(%rip), %rdx     # 0x976ef
leaq 0x670fb(%rip), %rcx     # 0x98a99
xorl %edi, %edi
movq %rbx, %rsi
movl $0x438, %r8d            # imm = 0x438
callq 0x4d277
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: dbUnshareStringValue
robj *dbUnshareStringValue(redisDb *db, robj *key, robj *o) {
    redisAssert(o->type == REDIS_STRING);
    if (o->refcount != 1 || o->encoding != REDIS_ENCODING_RAW) {
        robj *decoded = getDecodedObject(o);
        o = createRawStringObject(decoded->ptr, sdslen(decoded->ptr));
        decrRefCount(decoded);
        dbOverwrite(db,key,o);
    }
    return o;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl (%rdx), %eax
testb $0xf, %al
jne 0x31b24
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
testb $-0x10, %al
jne 0x31ae4
cmpl $0x1, 0x4(%r14)
je 0x31b15
movq %r14, %rdi
callq 0x30d93
movq %rax, %r12
movq 0x8(%rax), %rdi
movslq -0x8(%rdi), %rsi
callq 0x305d7
movq %rax, %r14
movq %r12, %rdi
callq 0x30b0c
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x318a1
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x6525b(%rip), %rdi     # 0x96d86
leaq 0x66f67(%rip), %rsi     # 0x98a99
movl $0x155, %edx            # imm = 0x155
callq 0x4ca32
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: selectDb
int selectDb(redisClient *c, int id) {

    // 确保 id 在正确范围内
    if (id < 0 || id >= server.dbnum)
        return REDIS_ERR;

    // 切换数据库（更新指针）
    c->db = &server.db[id];

    return REDIS_OK;
}

// Assembly:
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %esi, %esi
js 0x31c40
leaq 0x98380(%rip), %rcx     # 0xc9fa8
cmpl %esi, 0x480(%rcx)
jle 0x31c40
movl %esi, %eax
shlq $0x6, %rax
addq 0x10(%rcx), %rax
movq %rax, 0x8(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: flushallCommand
void flushallCommand(redisClient *c) {

    // 发送通知
    signalFlushedDb(-1);

    // 清空所有数据库
    server.dirty += emptyDb(NULL);
    addReply(c,shared.ok);

    // 如果正在保存新的 RDB ，那么取消保存操作
    if (server.rdb_child_pid != -1) {
        kill(server.rdb_child_pid,SIGUSR1);
        rdbRemoveTempFile(server.rdb_child_pid);
    }

    // 更新 RDB 文件
    if (server.saveparamslen > 0) {
        /* Normally rdbSave() will reset dirty, but we don't want this here
         * as otherwise FLUSHALL will not be replicated nor put into the AOF. */
        // rdbSave() 会清空服务器的 dirty 属性
        // 但为了确保 FLUSHALL 命令会被正常传播，
        // 程序需要保存并在 rdbSave() 调用之后还原服务器的 dirty 属性
        int saved_dirty = server.dirty;

        rdbSave(server.rdb_filename);

        server.dirty = saved_dirty;
    }

    server.dirty++;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x4c27a
xorl %edi, %edi
callq 0x31b46
leaq 0x982b0(%rip), %r14     # 0xc9fa8
addq %rax, 0x560(%r14)
leaq 0x98afa(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x2d97c
movl 0x570(%r14), %edi
cmpl $-0x1, %edi
je 0x31d34
movl $0xa, %esi
callq 0x1f620
movl 0x570(%r14), %edi
callq 0x37964
cmpl $0x0, 0x580(%r14)
movq 0x560(%r14), %rbx
jle 0x31d54
movq 0x588(%r14), %rdi
callq 0x37460
movslq %ebx, %rbx
incq %rbx
movq %rbx, 0x560(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: delCommand
void delCommand(redisClient *c) {
    int deleted = 0, j;

    // 遍历所有输入键
    for (j = 1; j < c->argc; j++) {

        // 先删除过期的键
        expireIfNeeded(c->db,c->argv[j]);

        // 尝试删除键
        if (dbDelete(c->db,c->argv[j])) {

            // 删除键成功，发送通知

            signalModifiedKey(c->db,c->argv[j]);
            notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,
                "del",c->argv[j],c->db->id);

            server.dirty++;

            // 成功删除才增加 deleted 计数器的值
            deleted++;
        }
    }

    // 返回被删除键的数量
    addReplyLongLong(c,deleted);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
cmpl $0x2, 0x30(%rdi)
jl 0x31dff
movl $0x1, %r12d
leaq 0x62751(%rip), %r15     # 0x944dd
leaq 0x98215(%rip), %r13     # 0xc9fa8
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r12,8), %rsi
callq 0x31673
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r12,8), %rsi
callq 0x31a36
testl %eax, %eax
je 0x31df0
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%r12,8), %rsi
callq 0x4c221
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq (%rcx,%r12,8), %rdx
movl 0x30(%rax), %ecx
movl $0x4, %edi
movq %r15, %rsi
callq 0x60371
incq 0x560(%r13)
incl %r14d
incq %r12
movslq 0x30(%rbx), %rax
cmpq %rax, %r12
jl 0x31d93
movslq %r14d, %r14
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2e133
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: existsCommand
void existsCommand(redisClient *c) {

    // 检查键是否已经过期，如果已过期的话，那么将它删除
    // 这可以避免已过期的键被误认为存在
    expireIfNeeded(c->db,c->argv[1]);

    // 在数据库中查找
    if (dbExists(c->db,c->argv[1])) {
        addReply(c, shared.cone);
    } else {
        addReply(c, shared.czero);
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31673
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq (%rax), %rdi
movq 0x8(%rcx), %rsi
callq 0x226ac
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
leaq 0x989b1(%rip), %rax     # 0xca800
movq 0x20(%rax,%rcx,8), %rsi
movq %rbx, %rdi
popq %rbx
jmp 0x2d97c
// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/db.c
// Function: selectCommand
void selectCommand(redisClient *c) {
    long id;

    // 不合法的数据库号码
    if (getLongFromObjectOrReply(c, c->argv[1], &id,
        "invalid DB index") != REDIS_OK)
        return;

    if (server.cluster_enabled && id != 0) {
        addReplyError(c,"SELECT is not allowed in cluster mode");
        return;
    }

    // 切换数据库
    if (selectDb(c,id) == REDIS_ERR) {
        addReplyError(c,"invalid DB index");
    } else {
        addReply(c,shared.ok);
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x656ef(%rip), %rcx     # 0x97563
leaq 0x8(%rsp), %rdx
callq 0x313b2
testl %eax, %eax
jne 0x31ef3
leaq 0x9811f(%rip), %rax     # 0xc9fa8
cmpl $0x0, 0x7bc(%rax)
setne %dl
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x31eb1
leaq 0x656c5(%rip), %rsi     # 0x97574
jmp 0x31eeb
testl %ecx, %ecx
js 0x31ee4
cmpl %ecx, 0x480(%rax)
jle 0x31ee4
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shlq $0x6, %rcx
addq 0x10(%rax), %rcx
movq %rcx, 0x8(%rbx)
leaq 0x9892a(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
callq 0x2d97c
jmp 0x31ef3
leaq 0x65678(%rip), %rsi     # 0x97563
movq %rbx, %rdi
callq 0x2dc63
addq $0x10, %rsp
popq %rbx
retq