// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/rdb.c
// Function: rdbSaveObject
ssize_t rdbSaveObject(rio *rdb, robj *o) {
    ssize_t n = 0, nwritten = 0;

    if (o->type == OBJ_STRING) {
        /* Save a string value */
        if ((n = rdbSaveStringObject(rdb,o)) == -1) return -1;
        nwritten += n;
    } else if (o->type == OBJ_LIST) {
        /* Save a list value */
        if (o->encoding == OBJ_ENCODING_QUICKLIST) {
            quicklist *ql = o->ptr;
            quicklistNode *node = ql->head;

            if ((n = rdbSaveLen(rdb,ql->len)) == -1) return -1;
            nwritten += n;

            do {
                if (quicklistNodeIsCompressed(node)) {
                    void *data;
                    size_t compress_len = quicklistGetLzf(node, &data);
                    if ((n = rdbSaveLzfBlob(rdb,data,compress_len,node->sz)) == -1) return -1;
                    nwritten += n;
                } else {
                    if ((n = rdbSaveRawString(rdb,node->zl,node->sz)) == -1) return -1;
                    nwritten += n;
                }
            } while ((node = node->next));
        } else {
            serverPanic("Unknown list encoding");
        }
    } else if (o->type == OBJ_SET) {
        /* Save a set value */
        if (o->encoding == OBJ_ENCODING_HT) {
            dict *set = o->ptr;
            dictIterator *di = dictGetIterator(set);
            dictEntry *de;

            if ((n = rdbSaveLen(rdb,dictSize(set))) == -1) return -1;
            nwritten += n;

            while((de = dictNext(di)) != NULL) {
                robj *eleobj = dictGetKey(de);
                if ((n = rdbSaveStringObject(rdb,eleobj)) == -1) return -1;
                nwritten += n;
            }
            dictReleaseIterator(di);
        } else if (o->encoding == OBJ_ENCODING_INTSET) {
            size_t l = intsetBlobLen((intset*)o->ptr);

            if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
            nwritten += n;
        } else {
            serverPanic("Unknown set encoding");
        }
    } else if (o->type == OBJ_ZSET) {
        /* Save a sorted set value */
        if (o->encoding == OBJ_ENCODING_ZIPLIST) {
            size_t l = ziplistBlobLen((unsigned char*)o->ptr);

            if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
            nwritten += n;
        } else if (o->encoding == OBJ_ENCODING_SKIPLIST) {
            zset *zs = o->ptr;
            dictIterator *di = dictGetIterator(zs->dict);
            dictEntry *de;

            if ((n = rdbSaveLen(rdb,dictSize(zs->dict))) == -1) return -1;
            nwritten += n;

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

                if ((n = rdbSaveStringObject(rdb,eleobj)) == -1) return -1;
                nwritten += n;
                if ((n = rdbSaveDoubleValue(rdb,*score)) == -1) return -1;
                nwritten += n;
            }
            dictReleaseIterator(di);
        } else {
            serverPanic("Unknown sorted set encoding");
        }
    } else if (o->type == OBJ_HASH) {
        /* Save a hash value */
        if (o->encoding == OBJ_ENCODING_ZIPLIST) {
            size_t l = ziplistBlobLen((unsigned char*)o->ptr);

            if ((n = rdbSaveRawString(rdb,o->ptr,l)) == -1) return -1;
            nwritten += n;

        } else if (o->encoding == OBJ_ENCODING_HT) {
            dictIterator *di = dictGetIterator(o->ptr);
            dictEntry *de;

            if ((n = rdbSaveLen(rdb,dictSize((dict*)o->ptr))) == -1) return -1;
            nwritten += n;

            while((de = dictNext(di)) != NULL) {
                robj *key = dictGetKey(de);
                robj *val = dictGetVal(de);

                if ((n = rdbSaveStringObject(rdb,key)) == -1) return -1;
                nwritten += n;
                if ((n = rdbSaveStringObject(rdb,val)) == -1) return -1;
                nwritten += n;
            }
            dictReleaseIterator(di);

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

    } else {
        serverPanic("Unknown object type");
    }
    return nwritten;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rsi), %eax
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x4, %ecx
ja 0x4131b
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x72f11(%rip), %rdx     # 0xb3f64
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40c4e
cmpl $-0x1, %eax
je 0x41274
movslq %eax, %r15
jmp 0x412f1
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
je 0x411d7
cmpl $0x5, %eax
je 0x41132
leaq 0x730aa(%rip), %rdi     # 0xb4141
leaq 0x73030(%rip), %rsi     # 0xb40ce
movl $0x2a8, %edx            # imm = 0x2A8
jmp 0x41358
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
je 0x41251
cmpl $0x2, %eax
jne 0x41330
movq 0x8(%r14), %r14
movq %r14, %rdi
callq 0x2a99f
movq %rax, %r12
movl 0x48(%r14), %esi
addl 0x28(%r14), %esi
movq %rbx, %rdi
callq 0x40575
pushq $-0x1
popq %r14
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %r15d
movq %r12, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x412e9
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x40c4e
cltq
addq %rax, %r15
cmpl $-0x1, %eax
jne 0x410ef
jmp 0x412f4
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x4127a
cmpl $0x5, %eax
jne 0x41345
movq 0x8(%r14), %rdi
callq 0x35f52
jmp 0x4125a
andl $0xf0, %eax
cmpl $0x90, %eax
jne 0x41306
movq 0x8(%r14), %rax
movq (%rax), %r12
movl 0x18(%rax), %esi
movq %rbx, %rdi
callq 0x40575
pushq $-0x1
popq %r14
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %r15d
movl $0x30000, %ebp          # imm = 0x30000
movq %rsp, %r13
movl 0x1c(%r12), %eax
andl %ebp, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x411a9
movq %r12, %rdi
movq %r13, %rsi
callq 0x2738b
movq (%rsp), %rsi
movl 0x18(%r12), %ecx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x40891
jmp 0x411bb
movq 0x10(%r12), %rsi
movl 0x18(%r12), %edx
movq %rbx, %rdi
callq 0x40ad8
cmpq $-0x1, %rax
je 0x412f4
addq %rax, %r15
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x4117a
jmp 0x412f1
movq 0x8(%r14), %rdi
callq 0x2a99f
movq %rax, %r12
movq 0x8(%r14), %rax
movl 0x48(%rax), %esi
addl 0x28(%rax), %esi
movq %rbx, %rdi
callq 0x40575
pushq $-0x1
popq %r14
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %r15d
movq %r12, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x412e9
movq (%rax), %rsi
movq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x40c4e
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x40c4e
cmpl $-0x1, %eax
je 0x412f4
movslq %ebp, %rcx
addq %rcx, %r15
cltq
addq %rax, %r15
jmp 0x41205
movq 0x8(%r14), %rdi
callq 0x5a9dc
movq 0x8(%r14), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x40ad8
cmpq $-0x1, %rax
je 0x41274
movq %rax, %r15
jmp 0x412f1
pushq $-0x1
popq %r14
jmp 0x412f4
movq 0x8(%r14), %r14
movq (%r14), %rdi
callq 0x2a99f
movq %rax, %r12
movq (%r14), %rax
movl 0x48(%rax), %esi
addl 0x28(%rax), %esi
movq %rbx, %rdi
callq 0x40575
pushq $-0x1
popq %r14
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %r15d
movq %r12, %rdi
callq 0x2a9d3
testq %rax, %rax
je 0x412e9
movq (%rax), %rsi
movq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x40c4e
cmpl $-0x1, %eax
je 0x412f4
movl %eax, %ebp
movsd (%r13), %xmm0
movq %rbx, %rdi
callq 0x40de9
cmpl $-0x1, %eax
je 0x412f4
movslq %ebp, %rcx
addq %rcx, %r15
cltq
addq %rax, %r15
jmp 0x412a6
movq %r12, %rdi
callq 0x2aa94
movq %r15, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x72e05(%rip), %rdi     # 0xb4112
leaq 0x72dba(%rip), %rsi     # 0xb40ce
movl $0x257, %edx            # imm = 0x257
jmp 0x41358
leaq 0x712dc(%rip), %rdi     # 0xb25fe
leaq 0x72da5(%rip), %rsi     # 0xb40ce
movl $0x2ac, %edx            # imm = 0x2AC
jmp 0x41358
leaq 0x72df3(%rip), %rdi     # 0xb412a
leaq 0x72d90(%rip), %rsi     # 0xb40ce
movl $0x26f, %edx            # imm = 0x26F
jmp 0x41358
leaq 0x71252(%rip), %rdi     # 0xb259e
leaq 0x72d7b(%rip), %rsi     # 0xb40ce
movl $0x28b, %edx            # imm = 0x28B
callq 0x57b45
pushq $0x1
popq %rdi
callq 0x263c0