// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/src/debug.c
// Function: computeDatasetDigest
void computeDatasetDigest(unsigned char *final) {
    unsigned char digest[20];
    char buf[128];
    dictIterator *di = NULL;
    dictEntry *de;
    int j;
    uint32_t aux;

    memset(final,0,20); /* Start with a clean result */

    for (j = 0; j < server.dbnum; j++) {
        redisDb *db = server.db+j;

        if (dictSize(db->dict) == 0) continue;
        di = dictGetIterator(db->dict);

        /* hash the DB id, so the same dataset moved in a different
         * DB will lead to a different digest */
        aux = htonl(j);
        mixDigest(final,&aux,sizeof(aux));

        /* Iterate this DB writing every entry */
        while((de = dictNext(di)) != NULL) {
            sds key;
            robj *keyobj, *o;
            long long expiretime;

            memset(digest,0,20); /* This key-val digest */
            key = dictGetKey(de);
            keyobj = createStringObject(key,sdslen(key));

            mixDigest(digest,key,sdslen(key));

            o = dictGetVal(de);

            aux = htonl(o->type);
            mixDigest(digest,&aux,sizeof(aux));
            expiretime = getExpire(db,keyobj);

            /* Save the key and associated value */
            if (o->type == REDIS_STRING) {
                mixObjectDigest(digest,o);
            } else if (o->type == REDIS_LIST) {
                listTypeIterator *li = listTypeInitIterator(o,0,REDIS_TAIL);
                listTypeEntry entry;
                while(listTypeNext(li,&entry)) {
                    robj *eleobj = listTypeGet(&entry);
                    mixObjectDigest(digest,eleobj);
                    decrRefCount(eleobj);
                }
                listTypeReleaseIterator(li);
            } else if (o->type == REDIS_SET) {
                setTypeIterator *si = setTypeInitIterator(o);
                robj *ele;
                while((ele = setTypeNextObject(si)) != NULL) {
                    xorObjectDigest(digest,ele);
                    decrRefCount(ele);
                }
                setTypeReleaseIterator(si);
            } else if (o->type == REDIS_ZSET) {
                unsigned char eledigest[20];

                if (o->encoding == REDIS_ENCODING_ZIPLIST) {
                    unsigned char *zl = o->ptr;
                    unsigned char *eptr, *sptr;
                    unsigned char *vstr;
                    unsigned int vlen;
                    long long vll;
                    double score;

                    eptr = ziplistIndex(zl,0);
                    redisAssert(eptr != NULL);
                    sptr = ziplistNext(zl,eptr);
                    redisAssert(sptr != NULL);

                    while (eptr != NULL) {
                        redisAssert(ziplistGet(eptr,&vstr,&vlen,&vll));
                        score = zzlGetScore(sptr);

                        memset(eledigest,0,20);
                        if (vstr != NULL) {
                            mixDigest(eledigest,vstr,vlen);
                        } else {
                            ll2string(buf,sizeof(buf),vll);
                            mixDigest(eledigest,buf,strlen(buf));
                        }

                        snprintf(buf,sizeof(buf),"%.17g",score);
                        mixDigest(eledigest,buf,strlen(buf));
                        xorDigest(digest,eledigest,20);
                        zzlNext(zl,&eptr,&sptr);
                    }
                } else if (o->encoding == REDIS_ENCODING_SKIPLIST) {
                    zset *zs = o->ptr;
                    dictIterator *di = dictGetIterator(zs->dict);
                    dictEntry *de;

                    while((de = dictNext(di)) != NULL) {
                        robj *eleobj = dictGetKey(de);
                        double *score = dictGetVal(de);

                        snprintf(buf,sizeof(buf),"%.17g",*score);
                        memset(eledigest,0,20);
                        mixObjectDigest(eledigest,eleobj);
                        mixDigest(eledigest,buf,strlen(buf));
                        xorDigest(digest,eledigest,20);
                    }
                    dictReleaseIterator(di);
                } else {
                    redisPanic("Unknown sorted set encoding");
                }
            } else if (o->type == REDIS_HASH) {
                hashTypeIterator *hi;
                robj *obj;

                hi = hashTypeInitIterator(o);
                while (hashTypeNext(hi) != REDIS_ERR) {
                    unsigned char eledigest[20];

                    memset(eledigest,0,20);
                    obj = hashTypeCurrentObject(hi,REDIS_HASH_KEY);
                    mixObjectDigest(eledigest,obj);
                    decrRefCount(obj);
                    obj = hashTypeCurrentObject(hi,REDIS_HASH_VALUE);
                    mixObjectDigest(eledigest,obj);
                    decrRefCount(obj);
                    xorDigest(digest,eledigest,20);
                }
                hashTypeReleaseIterator(hi);
            } else {
                redisPanic("Unknown object type");
            }
            /* If the key has an expire, add it to the mix */
            if (expiretime != -1) xorDigest(digest,"!!expire!!",10);
            /* We can finally xor the key-val digest to the final digest */
            xorDigest(final,digest,20);
            decrRefCount(keyobj);
        }
        dictReleaseIterator(di);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x30(%rsp)
andl $0x0, 0x10(%rdi)
leaq 0x7e449(%rip), %rsi     # 0xc6fa8
movl 0x480(%rsi), %eax
xorl %r15d, %r15d
pushq $0x14
popq %r13
leaq 0x50(%rsp), %r14
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x48fe0
movq 0x10(%rsi), %r8
movq %r15, %rcx
shlq $0x6, %rcx
movq (%r8,%rcx), %rdi
movq 0x28(%rdi), %rdx
addq 0x48(%rdi), %rdx
je 0x48fd8
addq %rcx, %r8
movq %r8, 0x70(%rsp)
callq 0x21ef6
movq %rax, 0x38(%rsp)
movq %r15, 0x68(%rsp)
movl %r15d, %eax
bswapl %eax
movl %eax, 0x8(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x48aca
movq 0x38(%rsp), %rdi
callq 0x21f2f
testq %rax, %rax
je 0x48fbc
movq %rax, %rbp
movq %r13, %rbx
andl $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq (%rax), %r15
movslq -0x8(%r15), %rsi
movq %r15, %rdi
callq 0x2ea81
movq %rax, %r13
movslq -0x8(%r15), %rdx
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x48aca
movq 0x8(%rbp), %rbp
movl (%rbp), %eax
andl $0xf, %eax
shll $0x18, %eax
movl %eax, 0x8(%rsp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x48aca
movq 0x70(%rsp), %rdi
movq %r13, 0x80(%rsp)
movq %r13, %rsi
callq 0x30ab1
movl (%rbp), %esi
movl %esi, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
ja 0x49012
leaq 0x48492(%rip), %rdx     # 0x910f8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movq %rbx, %r13
movq %rax, 0x78(%rsp)
jmpq *%rcx
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x48b07
jmp 0x48f80
movq %rbp, %rdi
callq 0x3f5c0
movq %rax, %rbp
leaq 0x10(%rsp), %r12
movq %rbp, %rdi
callq 0x3f648
cmpl $-0x1, %eax
je 0x48d08
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andl $0x0, 0x60(%rsp)
movq %rbp, %rdi
pushq $0x1
popq %rsi
callq 0x3f7f4
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x48b07
movq %r15, %rdi
callq 0x2ee1f
movq %rbp, %rdi
pushq $0x2
popq %rsi
callq 0x3f7f4
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x48b07
movq %r15, %rdi
callq 0x2ee1f
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x48a40
jmp 0x48c9c
movq %rbp, %rdi
callq 0x3f62c
jmp 0x48f80
movq %rbp, %rdi
callq 0x38fcc
movq %rax, %rbp
leaq 0x10(%rsp), %r12
movq %rbp, %rdi
callq 0x390a7
testq %rax, %rax
je 0x48d4a
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x48a99
movq %r15, %rdi
callq 0x2ee1f
jmp 0x48d25
movq %rbp, %rdi
callq 0x39035
jmp 0x48f80
shrl $0x4, %esi
andl $0xf, %esi
cmpl $0x7, %esi
je 0x48ef0
cmpl $0x5, %esi
leaq 0xa0(%rsp), %rbx
jne 0x49051
movq 0x8(%rbp), %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2abfb
movq %rax, 0x48(%rsp)
testq %rax, %rax
leaq 0x98(%rsp), %r15
leaq 0x10(%rsp), %r12
je 0x4903c
movq %rbp, %rdi
movq %rax, %rsi
callq 0x2ae0d
movq %rax, 0x40(%rsp)
testq %rax, %rax
je 0x49027
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x48f80
movq %r15, %rsi
leaq 0xc(%rsp), %rdx
leaq 0x90(%rsp), %rcx
callq 0x2aea9
testl %eax, %eax
je 0x48ff2
movq 0x40(%rsp), %rdi
callq 0x3b09e
andl $0x0, 0x60(%rsp)
movsd %xmm0, 0x88(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq 0x98(%rsp), %rsi
testq %rsi, %rsi
je 0x48e1a
movl 0xc(%rsp), %edx
movq %r14, %rdi
jmp 0x48e40
movq 0x90(%rsp), %rdx
movl $0x80, %esi
movq %rbx, %rdi
callq 0x2e511
movq %rbx, %rdi
callq 0x1f4f0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x48aca
movl $0x80, %esi
movq %rbx, %rdi
leaq 0x43f73(%rip), %rdx     # 0x8cdc7
movsd 0x88(%rsp), %xmm0
movb $0x1, %al
callq 0x1f120
movq %rbx, %rdi
callq 0x1f4f0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x48aca
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x48a40
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x3b25c
jmp 0x48db9
movq %rbp, %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
callq 0x37058
movq %rax, %rbp
leaq 0x10(%rsp), %r12
movq %rbp, %rdi
movq %r14, %rsi
callq 0x370e4
testl %eax, %eax
je 0x48ee3
movq %r14, %rdi
callq 0x37195
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x48b07
movq %r15, %rdi
callq 0x2ee1f
jmp 0x48eb4
movq %rbp, %rdi
callq 0x370df
jmp 0x48f80
movq 0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x21ef6
movq %rax, %rbp
leaq 0xa0(%rsp), %rbx
leaq 0x10(%rsp), %r12
movq %rbp, %rdi
callq 0x21f2f
testq %rax, %rax
je 0x48f78
movq (%rax), %r15
movq 0x8(%rax), %rax
movsd (%rax), %xmm0
movl $0x80, %esi
movq %rbx, %rdi
leaq 0x43e94(%rip), %rdx     # 0x8cdc7
movb $0x1, %al
callq 0x1f120
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andl $0x0, 0x60(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x48b07
movq %rbx, %rdi
callq 0x1f4f0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x48aca
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x48a40
jmp 0x48f0c
movq %rbp, %rdi
callq 0x21fe6
cmpq $-0x1, 0x78(%rsp)
je 0x48f9a
movq %r12, %rdi
leaq 0x4819e(%rip), %rsi     # 0x91130
pushq $0xa
popq %rdx
callq 0x48a40
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x48a40
movq 0x80(%rsp), %rdi
callq 0x2ee1f
jmp 0x48bcc
movq 0x38(%rsp), %rdi
callq 0x21fe6
leaq 0x7dfdb(%rip), %rsi     # 0xc6fa8
movl 0x480(%rsi), %eax
movq 0x68(%rsp), %r15
incq %r15
jmp 0x48b71
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x47b2c(%rip), %rdi     # 0x90b25
leaq 0x48128(%rip), %rsi     # 0x91128
movl $0xb7, %edx
callq 0x4906b
pushq $0x1
popq %rdi
callq 0x1f3b0
leaq 0x443ee(%rip), %rdi     # 0x8d407
leaq 0x48108(%rip), %rsi     # 0x91128
movl $0xed, %edx
jmp 0x49064
leaq 0x464db(%rip), %rdi     # 0x8f509
leaq 0x480f3(%rip), %rsi     # 0x91128
movl $0xb4, %edx
jmp 0x49005
leaq 0x46209(%rip), %rdi     # 0x8f24c
leaq 0x480de(%rip), %rsi     # 0x91128
movl $0xb2, %edx
jmp 0x49005
leaq 0x4434f(%rip), %rdi     # 0x8d3a7
leaq 0x480c9(%rip), %rsi     # 0x91128
movl $0xd8, %edx
callq 0x490e8
jmp 0x4900a