// File: /workspace/github_c_makefile_star2_O3/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 0x48e32
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x79cbc(%rip), %rdx     # 0xc2814
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x485f3
cmpl $-0x1, %eax
je 0x48d85
movslq %eax, %r15
jmp 0x48e08
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x2, %eax
je 0x48ce2
cmpl $0x5, %eax
je 0x48c3a
leaq 0x79ee5(%rip), %rdi     # 0xc2a81
leaq 0x79e6b(%rip), %rsi     # 0xc2a0e
movl $0x2a8, %edx            # imm = 0x2A8
jmp 0x48e6f
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x6, %eax
je 0x48d5f
cmpl $0x2, %eax
jne 0x48e47
movq 0x8(%r14), %r14
movq %r14, %rdi
callq 0x2efbb
movq %rax, %r12
movl 0x48(%r14), %esi
addl 0x28(%r14), %esi
movq %rbx, %rdi
callq 0x47cfe
movq $-0x1, %r14
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %r15d
movq %r12, %rdi
callq 0x2f015
testq %rax, %rax
je 0x48e00
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x485f3
cltq
addq %rax, %r15
cmpl $-0x1, %eax
jne 0x48bf7
jmp 0x48e0b
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x48d8e
cmpl $0x5, %eax
jne 0x48e5c
movq 0x8(%r14), %rdi
callq 0x3bbc5
jmp 0x48d68
andl $0xf0, %eax
cmpl $0x90, %eax
jne 0x48e1d
movq 0x8(%r14), %rax
movq (%rax), %r12
movl 0x18(%rax), %esi
movq %rbx, %rdi
callq 0x47cfe
movq $-0x1, %r14
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %r15d
movl $0x30000, %ebp          # imm = 0x30000
movq %rsp, %r13
movl 0x1c(%r12), %eax
andl %ebp, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x48cb4
movq %r12, %rdi
movq %r13, %rsi
callq 0x2b78e
movq (%rsp), %rsi
movl 0x18(%r12), %ecx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x481dd
jmp 0x48cc6
movq 0x10(%r12), %rsi
movl 0x18(%r12), %edx
movq %rbx, %rdi
callq 0x48479
cmpq $-0x1, %rax
je 0x48e0b
addq %rax, %r15
movq 0x8(%r12), %r12
testq %r12, %r12
jne 0x48c85
jmp 0x48e08
movq 0x8(%r14), %rdi
callq 0x2efbb
movq %rax, %r12
movq 0x8(%r14), %rax
movl 0x48(%rax), %esi
addl 0x28(%rax), %esi
movq %rbx, %rdi
callq 0x47cfe
movq $-0x1, %r14
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %r15d
movq %r12, %rdi
callq 0x2f015
testq %rax, %rax
je 0x48e00
movq (%rax), %rsi
movq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x485f3
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x485f3
cmpl $-0x1, %eax
je 0x48e0b
movslq %ebp, %rcx
addq %rcx, %r15
cltq
addq %rax, %r15
jmp 0x48d13
movq 0x8(%r14), %rdi
callq 0x64e5f
movq 0x8(%r14), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x48479
cmpq $-0x1, %rax
je 0x48d85
movq %rax, %r15
jmp 0x48e08
movq $-0x1, %r14
jmp 0x48e0b
movq 0x8(%r14), %r14
movq (%r14), %rdi
callq 0x2efbb
movq %rax, %r12
movq (%r14), %rax
movl 0x48(%rax), %esi
addl 0x28(%rax), %esi
movq %rbx, %rdi
callq 0x47cfe
movq $-0x1, %r14
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %r15d
movq %r12, %rdi
callq 0x2f015
testq %rax, %rax
je 0x48e00
movq (%rax), %rsi
movq 0x8(%rax), %r13
movq %rbx, %rdi
callq 0x485f3
cmpl $-0x1, %eax
je 0x48e0b
movl %eax, %ebp
movsd (%r13), %xmm0
movq %rbx, %rdi
callq 0x487f7
cmpl $-0x1, %eax
je 0x48e0b
movslq %ebp, %rcx
addq %rcx, %r15
cltq
addq %rax, %r15
jmp 0x48dbd
movq %r12, %rdi
callq 0x2f0dd
movq %r15, %r14
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x79c2e(%rip), %rdi     # 0xc2a52
leaq 0x79be3(%rip), %rsi     # 0xc2a0e
movl $0x257, %edx            # imm = 0x257
jmp 0x48e6f
leaq 0x77eed(%rip), %rdi     # 0xc0d26
leaq 0x79bce(%rip), %rsi     # 0xc2a0e
movl $0x2ac, %edx            # imm = 0x2AC
jmp 0x48e6f
leaq 0x79c1c(%rip), %rdi     # 0xc2a6a
leaq 0x79bb9(%rip), %rsi     # 0xc2a0e
movl $0x26f, %edx            # imm = 0x26F
jmp 0x48e6f
leaq 0x77e63(%rip), %rdi     # 0xc0cc6
leaq 0x79ba4(%rip), %rsi     # 0xc2a0e
movl $0x28b, %edx            # imm = 0x28B
callq 0x619b4
movl $0x1, %edi
callq 0x263c0