// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/rdb.c
// Function: rdbLoadObject
robj *rdbLoadObject(int rdbtype, rio *rdb) {
    robj *o = NULL, *ele, *dec;
    size_t len;
    unsigned int i;

    if (rdbtype == RDB_TYPE_STRING) {
        /* Read string value */
        if ((o = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
        o = tryObjectEncoding(o);
    } else if (rdbtype == RDB_TYPE_LIST) {
        /* Read list value */
        if ((len = rdbLoadLen(rdb,NULL)) == RDB_LENERR) return NULL;

        o = createQuicklistObject();
        quicklistSetOptions(o->ptr, server.list_max_ziplist_size,
                            server.list_compress_depth);

        /* Load every single element of the list */
        while(len--) {
            if ((ele = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
            dec = getDecodedObject(ele);
            size_t len = sdslen(dec->ptr);
            quicklistPushTail(o->ptr, dec->ptr, len);
            decrRefCount(dec);
            decrRefCount(ele);
        }
    } else if (rdbtype == RDB_TYPE_SET) {
        /* Read list/set value */
        if ((len = rdbLoadLen(rdb,NULL)) == RDB_LENERR) return NULL;

        /* Use a regular set when there are too many entries. */
        if (len > server.set_max_intset_entries) {
            o = createSetObject();
            /* It's faster to expand the dict to the right size asap in order
             * to avoid rehashing */
            if (len > DICT_HT_INITIAL_SIZE)
                dictExpand(o->ptr,len);
        } else {
            o = createIntsetObject();
        }

        /* Load every single element of the list/set */
        for (i = 0; i < len; i++) {
            long long llval;
            if ((ele = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
            ele = tryObjectEncoding(ele);

            if (o->encoding == OBJ_ENCODING_INTSET) {
                /* Fetch integer value from element */
                if (isObjectRepresentableAsLongLong(ele,&llval) == C_OK) {
                    o->ptr = intsetAdd(o->ptr,llval,NULL);
                } else {
                    setTypeConvert(o,OBJ_ENCODING_HT);
                    dictExpand(o->ptr,len);
                }
            }

            /* This will also be called when the set was just converted
             * to a regular hash table encoded set */
            if (o->encoding == OBJ_ENCODING_HT) {
                dictAdd((dict*)o->ptr,ele,NULL);
            } else {
                decrRefCount(ele);
            }
        }
    } else if (rdbtype == RDB_TYPE_ZSET) {
        /* Read list/set value */
        size_t zsetlen;
        size_t maxelelen = 0;
        zset *zs;

        if ((zsetlen = rdbLoadLen(rdb,NULL)) == RDB_LENERR) return NULL;
        o = createZsetObject();
        zs = o->ptr;

        /* Load every single element of the list/set */
        while(zsetlen--) {
            robj *ele;
            double score;
            zskiplistNode *znode;

            if ((ele = rdbLoadEncodedStringObject(rdb)) == NULL) return NULL;
            ele = tryObjectEncoding(ele);
            if (rdbLoadDoubleValue(rdb,&score) == -1) return NULL;

            /* Don't care about integer-encoded strings. */
            if (sdsEncodedObject(ele) && sdslen(ele->ptr) > maxelelen)
                maxelelen = sdslen(ele->ptr);

            znode = zslInsert(zs->zsl,score,ele);
            dictAdd(zs->dict,ele,&znode->score);
            incrRefCount(ele); /* added to skiplist */
        }

        /* Convert *after* loading, since sorted sets are not stored ordered. */
        if (zsetLength(o) <= server.zset_max_ziplist_entries &&
            maxelelen <= server.zset_max_ziplist_value)
                zsetConvert(o,OBJ_ENCODING_ZIPLIST);
    } else if (rdbtype == RDB_TYPE_HASH) {
        size_t len;
        int ret;

        len = rdbLoadLen(rdb, NULL);
        if (len == RDB_LENERR) return NULL;

        o = createHashObject();

        /* Too many entries? Use a hash table. */
        if (len > server.hash_max_ziplist_entries)
            hashTypeConvert(o, OBJ_ENCODING_HT);

        /* Load every field and value into the ziplist */
        while (o->encoding == OBJ_ENCODING_ZIPLIST && len > 0) {
            robj *field, *value;

            len--;
            /* Load raw strings */
            field = rdbLoadStringObject(rdb);
            if (field == NULL) return NULL;
            serverAssert(sdsEncodedObject(field));
            value = rdbLoadStringObject(rdb);
            if (value == NULL) return NULL;
            serverAssert(sdsEncodedObject(value));

            /* Add pair to ziplist */
            o->ptr = ziplistPush(o->ptr, field->ptr, sdslen(field->ptr), ZIPLIST_TAIL);
            o->ptr = ziplistPush(o->ptr, value->ptr, sdslen(value->ptr), ZIPLIST_TAIL);
            /* Convert to hash table if size threshold is exceeded */
            if (sdslen(field->ptr) > server.hash_max_ziplist_value ||
                sdslen(value->ptr) > server.hash_max_ziplist_value)
            {
                decrRefCount(field);
                decrRefCount(value);
                hashTypeConvert(o, OBJ_ENCODING_HT);
                break;
            }
            decrRefCount(field);
            decrRefCount(value);
        }

        /* Load remaining fields and values into the hash table */
        while (o->encoding == OBJ_ENCODING_HT && len > 0) {
            robj *field, *value;

            len--;
            /* Load encoded strings */
            field = rdbLoadEncodedStringObject(rdb);
            if (field == NULL) return NULL;
            value = rdbLoadEncodedStringObject(rdb);
            if (value == NULL) return NULL;

            field = tryObjectEncoding(field);
            value = tryObjectEncoding(value);

            /* Add pair to hash table */
            ret = dictAdd((dict*)o->ptr, field, value);
            if (ret == DICT_ERR) {
                rdbExitReportCorruptRDB("Duplicate keys detected");
            }
        }

        /* All pairs should be read by now */
        serverAssert(len == 0);
    } else if (rdbtype == RDB_TYPE_LIST_QUICKLIST) {
        if ((len = rdbLoadLen(rdb,NULL)) == RDB_LENERR) return NULL;
        o = createQuicklistObject();
        quicklistSetOptions(o->ptr, server.list_max_ziplist_size,
                            server.list_compress_depth);

        while (len--) {
            unsigned char *zl = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
            if (zl == NULL) return NULL;
            quicklistAppendZiplist(o->ptr, zl);
        }
    } else if (rdbtype == RDB_TYPE_HASH_ZIPMAP  ||
               rdbtype == RDB_TYPE_LIST_ZIPLIST ||
               rdbtype == RDB_TYPE_SET_INTSET   ||
               rdbtype == RDB_TYPE_ZSET_ZIPLIST ||
               rdbtype == RDB_TYPE_HASH_ZIPLIST)
    {
        unsigned char *encoded = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
        if (encoded == NULL) return NULL;
        o = createObject(OBJ_STRING,encoded); /* Obj type fixed below. */

        /* Fix the object encoding, and make sure to convert the encoded
         * data type into the base type if accordingly to the current
         * configuration there are too many elements in the encoded data
         * type. Note that we only check the length and not max element
         * size as this is an O(N) scan. Eventually everything will get
         * converted. */
        switch(rdbtype) {
            case RDB_TYPE_HASH_ZIPMAP:
                /* Convert to ziplist encoded hash. This must be deprecated
                 * when loading dumps created by Redis 2.4 gets deprecated. */
                {
                    unsigned char *zl = ziplistNew();
                    unsigned char *zi = zipmapRewind(o->ptr);
                    unsigned char *fstr, *vstr;
                    unsigned int flen, vlen;
                    unsigned int maxlen = 0;

                    while ((zi = zipmapNext(zi, &fstr, &flen, &vstr, &vlen)) != NULL) {
                        if (flen > maxlen) maxlen = flen;
                        if (vlen > maxlen) maxlen = vlen;
                        zl = ziplistPush(zl, fstr, flen, ZIPLIST_TAIL);
                        zl = ziplistPush(zl, vstr, vlen, ZIPLIST_TAIL);
                    }

                    zfree(o->ptr);
                    o->ptr = zl;
                    o->type = OBJ_HASH;
                    o->encoding = OBJ_ENCODING_ZIPLIST;

                    if (hashTypeLength(o) > server.hash_max_ziplist_entries ||
                        maxlen > server.hash_max_ziplist_value)
                    {
                        hashTypeConvert(o, OBJ_ENCODING_HT);
                    }
                }
                break;
            case RDB_TYPE_LIST_ZIPLIST:
                o->type = OBJ_LIST;
                o->encoding = OBJ_ENCODING_ZIPLIST;
                listTypeConvert(o,OBJ_ENCODING_QUICKLIST);
                break;
            case RDB_TYPE_SET_INTSET:
                o->type = OBJ_SET;
                o->encoding = OBJ_ENCODING_INTSET;
                if (intsetLen(o->ptr) > server.set_max_intset_entries)
                    setTypeConvert(o,OBJ_ENCODING_HT);
                break;
            case RDB_TYPE_ZSET_ZIPLIST:
                o->type = OBJ_ZSET;
                o->encoding = OBJ_ENCODING_ZIPLIST;
                if (zsetLength(o) > server.zset_max_ziplist_entries)
                    zsetConvert(o,OBJ_ENCODING_SKIPLIST);
                break;
            case RDB_TYPE_HASH_ZIPLIST:
                o->type = OBJ_HASH;
                o->encoding = OBJ_ENCODING_ZIPLIST;
                if (hashTypeLength(o) > server.hash_max_ziplist_entries)
                    hashTypeConvert(o, OBJ_ENCODING_HT);
                break;
            default:
                rdbExitReportCorruptRDB("Unknown RDB encoding type %d",rdbtype);
                break;
        }
    } else {
        rdbExitReportCorruptRDB("Unknown RDB encoding type %d",rdbtype);
    }
    return o;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r12
movl %edi, %edx
cmpl $0xe, %edi
ja 0x41e6e
movl %edx, %eax
leaq 0x721f8(%rip), %rcx     # 0xb3f78
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %r12, (%rsp)
jmpq *%rax
movq %r12, %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a3ad
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4061c
cmpl $-0x1, %eax
je 0x4230f
movl %eax, %ebp
movl %eax, %r15d
leaq 0xb7ad3(%rip), %rax     # 0xf98a8
cmpq %r15, 0x950(%rax)
jae 0x421b8
callq 0x3a079
movq %rax, %rbx
cmpl $0x5, %ebp
jb 0x421c0
movq 0x8(%rbx), %rdi
movq %r15, %rsi
callq 0x2a1b7
jmp 0x421c0
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4061c
cmpl $-0x1, %eax
je 0x4230f
movl %eax, %r14d
callq 0x3a038
movq %rax, %rbx
movq 0x8(%rax), %rdi
leaq 0xb7a79(%rip), %rax     # 0xf98a8
movl 0x970(%rax), %esi
movl 0x974(%rax), %edx
callq 0x271d0
pushq $0x2
popq %rbp
subq $0x1, %r14
jb 0x4230f
movq %r12, %rdi
movl %ebp, %esi
callq 0x40cf4
testq %rax, %rax
je 0x4230d
movq 0x8(%rbx), %rdi
movq %rax, %rsi
callq 0x2779d
jmp 0x41e43
leal -0x9(%rdx), %r14d
cmpl $0x4, %r14d
ja 0x4247b
pushq $0x2
popq %rsi
movq %r12, %rdi
callq 0x40cf4
testq %rax, %rax
je 0x4230d
xorl %r13d, %r13d
xorl %edi, %edi
movq %rax, %rsi
callq 0x39d58
movq %rax, %rbx
leaq 0x7210d(%rip), %rax     # 0xb3fb4
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
callq 0x3540c
movq %rax, %r15
movq 0x8(%rbx), %rdi
callq 0x33bcb
movq %rax, %r12
leaq 0x10(%rsp), %rbp
pushq $0x1
popq %r14
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
leaq 0x14(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq %rbp, %r8
callq 0x33bd0
testq %rax, %rax
je 0x423fe
movq %rax, %r12
movl 0x14(%rsp), %edx
cmpl %r13d, %edx
cmoval %edx, %r13d
movl 0x10(%rsp), %eax
cmpl %r13d, %eax
cmoval %eax, %r13d
movq 0x8(%rsp), %rsi
movq %r15, %rdi
movl %r14d, %ecx
callq 0x35aa8
movq 0x20(%rsp), %rsi
movl 0x10(%rsp), %edx
movq %rax, %rdi
movl %r14d, %ecx
callq 0x35aa8
movq %rax, %r15
jmp 0x41ecd
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4061c
cmpl $-0x1, %eax
je 0x4230f
movl %eax, %r14d
callq 0x3a038
movq %rax, %rbx
movq 0x8(%rax), %rdi
leaq 0xb794b(%rip), %rax     # 0xf98a8
movl 0x970(%rax), %esi
movl 0x974(%rax), %edx
callq 0x271d0
subq $0x1, %r14
jb 0x4230f
movq %r12, %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %r15
movq %rax, %rdi
callq 0x3a57d
movq %rax, %r12
movq 0x8(%rax), %r13
movq %r13, %rdi
callq 0x40cbc
movq 0x8(%rbx), %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x276f0
movq %r12, %rdi
movq (%rsp), %r12
callq 0x3a265
movq %r15, %rdi
callq 0x3a265
jmp 0x41f6e
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4061c
cmpl $-0x1, %eax
je 0x4230f
movl %eax, %r13d
callq 0x3a0df
movq %rax, %rbx
movq 0x8(%rax), %rbp
xorl %r14d, %r14d
subq $0x1, %r13
jb 0x42321
movq %r12, %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %rdi
callq 0x3a3ad
movq %rax, %r15
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x40e71
cmpl $-0x1, %eax
je 0x4230d
movl (%r15), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x42045
movq 0x8(%r15), %rdi
callq 0x40cbc
cmpq %r14, %rax
cmovaq %rax, %r14
movq 0x8(%rbp), %rdi
movsd 0x8(%rsp), %xmm0
movq %r15, %rsi
callq 0x479ab
movq (%rbp), %rdi
leaq 0x8(%rax), %rdx
movq %r15, %rsi
callq 0x2a3ed
movq %r15, %rdi
callq 0x39e74
movq (%rsp), %r12
jmp 0x41fef
xorl %ebx, %ebx
movq %r12, %rdi
xorl %esi, %esi
callq 0x4061c
cmpl $-0x1, %eax
je 0x4230f
movl %eax, %r14d
callq 0x3a0c0
movq %rax, %rbx
leaq 0xb7809(%rip), %rax     # 0xf98a8
cmpq %r14, 0x940(%rax)
jae 0x420b3
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x4c673
movl (%rbx), %eax
movl $0xf0, %ecx
andl %ecx, %eax
cmpl $0x50, %eax
jne 0x42288
testq %r14, %r14
je 0x42288
movq %r12, %rdi
callq 0x40dda
testq %rax, %rax
je 0x4230d
movq %rax, %r15
movl (%rax), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x42446
movq %r12, %rdi
callq 0x40dda
testq %rax, %rax
je 0x4230d
movq %rax, %r12
movq %r14, 0x18(%rsp)
movl (%rax), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x4245b
movq 0x8(%rbx), %r13
movq 0x8(%r15), %rbp
movq %rbp, %rdi
callq 0x40cbc
movq %r13, %rdi
movq %rbp, %rsi
movl %eax, %edx
movq %rbx, %r14
pushq $0x1
popq %rbx
movl %ebx, %ecx
callq 0x35aa8
movq %rax, %r13
movq %rax, 0x8(%r14)
movq 0x8(%r12), %rbp
movq %rbp, %rdi
callq 0x40cbc
movq %r13, %rdi
movq %rbp, %rsi
movl %eax, %edx
movl %ebx, %ecx
movq %r14, %rbx
callq 0x35aa8
movq %rax, 0x8(%r14)
movq 0x8(%r15), %rdi
callq 0x40cbc
leaq 0xb7734(%rip), %rcx     # 0xf98a8
movq 0x948(%rcx), %r13
cmpq %r13, %rax
ja 0x42261
movq 0x8(%r12), %rdi
callq 0x40cbc
cmpq %r13, %rax
ja 0x42261
movq %r15, %rdi
callq 0x3a265
movq %r12, %rdi
callq 0x3a265
movq 0x18(%rsp), %r14
decq %r14
movq (%rsp), %r12
jmp 0x420b3
callq 0x3a0a1
movq %rax, %rbx
movl $0xf0, %r14d
leaq 0x8(%rsp), %r12
subl $0x1, %ebp
jb 0x4230f
movq (%rsp), %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %rdi
callq 0x3a3ad
movq %rax, %r13
movl (%rbx), %eax
andl %r14d, %eax
cmpl $0x60, %eax
jne 0x42237
movq %r13, %rdi
movq %r12, %rsi
callq 0x3a335
testl %eax, %eax
je 0x42223
movq %rbx, %rdi
pushq $0x2
popq %rsi
callq 0x45d89
movq 0x8(%rbx), %rdi
movq %r15, %rsi
callq 0x2a1b7
jmp 0x42237
movq 0x8(%rbx), %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0x5a65e
movq %rax, 0x8(%rbx)
movl (%rbx), %eax
andl %r14d, %eax
cmpl $0x20, %eax
jne 0x42254
movq 0x8(%rbx), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x2a3ed
jmp 0x421cb
movq %r13, %rdi
callq 0x3a265
jmp 0x421cb
movq %r15, %rdi
callq 0x3a265
movq %r12, %rdi
callq 0x3a265
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x4c673
movq 0x18(%rsp), %r14
decq %r14
movq (%rsp), %r12
movl $0xf0, %ebp
movq %r14, %r13
movl (%rbx), %ecx
andl %ebp, %ecx
addq $-0x1, %r13
setb %al
cmpl $0x20, %ecx
jne 0x4234b
testb %al, %al
je 0x4234b
movq %r12, %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %r15
movq %r12, %rdi
callq 0x40de1
testq %rax, %rax
je 0x4230d
movq %rax, %r12
movq %r15, %rdi
callq 0x3a3ad
movq %rax, %r15
movq %r12, %rdi
callq 0x3a3ad
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2a3ed
movq %r13, %r14
cmpl $0x1, %eax
movq (%rsp), %r12
jne 0x42290
leaq 0x72029(%rip), %rsi     # 0xb432a
movl $0x46c, %edi            # imm = 0x46C
xorl %eax, %eax
callq 0x40308
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x490f5
movl %eax, %ecx
leaq 0xb7576(%rip), %rax     # 0xf98a8
cmpq %rcx, 0x958(%rax)
jb 0x4230f
cmpq 0x960(%rax), %r14
ja 0x4230f
pushq $0x5
jmp 0x423dd
testq %r14, %r14
je 0x4230f
leaq 0x71feb(%rip), %rdi     # 0xb4342
leaq 0x71d70(%rip), %rsi     # 0xb40ce
movl $0x471, %edx            # imm = 0x471
jmp 0x4246e
movb $0x54, (%rbx)
movq %rbx, %rdi
callq 0x4cbe1
leaq 0xb752e(%rip), %rcx     # 0xf98a8
cmpq 0x940(%rcx), %rax
jbe 0x4230f
jmp 0x42436
movb $0x62, (%rbx)
movq 0x8(%rbx), %rdi
callq 0x5a9d8
movl %eax, %eax
leaq 0xb750b(%rip), %rcx     # 0xf98a8
cmpq %rax, 0x950(%rcx)
jae 0x4230f
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x45d89
jmp 0x4230f
movb $0x53, (%rbx)
movq %rbx, %rdi
callq 0x490f5
movl %eax, %eax
leaq 0xb74da(%rip), %rcx     # 0xf98a8
cmpq %rax, 0x958(%rcx)
jae 0x4230f
pushq $0x7
popq %rsi
movq %rbx, %rdi
callq 0x4913d
jmp 0x4230f
movb $0x51, (%rbx)
pushq $0x9
popq %rsi
movq %rbx, %rdi
callq 0x44530
jmp 0x4230f
movq 0x8(%rbx), %rdi
callq 0x328f9
movq %r15, 0x8(%rbx)
movb $0x54, (%rbx)
movq %rbx, %rdi
callq 0x4cbe1
leaq 0xb748b(%rip), %rcx     # 0xf98a8
cmpq 0x940(%rcx), %rax
ja 0x42436
movl %r13d, %eax
cmpq %rax, 0x948(%rcx)
jae 0x4230f
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x4c673
jmp 0x4230f
leaq 0x71ead(%rip), %rdi     # 0xb42fa
leaq 0x71c7a(%rip), %rsi     # 0xb40ce
movl $0x446, %edx            # imm = 0x446
jmp 0x4246e
leaq 0x71eb0(%rip), %rdi     # 0xb4312
leaq 0x71c65(%rip), %rsi     # 0xb40ce
movl $0x449, %edx            # imm = 0x449
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0
leaq 0x71ec9(%rip), %rsi     # 0xb434b
movl $0x4c7, %edi            # imm = 0x4C7
xorl %eax, %eax
callq 0x40308