// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: zsetConvert
void zsetConvert(robj *zobj, int encoding) {
    zset *zs;
    zskiplistNode *node, *next;
    robj *ele;
    double score;

    if (zobj->encoding == encoding) return;
    if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
        unsigned char *zl = zobj->ptr;
        unsigned char *eptr, *sptr;
        unsigned char *vstr;
        unsigned int vlen;
        long long vlong;

        if (encoding != OBJ_ENCODING_SKIPLIST)
            serverPanic("Unknown target encoding");

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

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

        while (eptr != NULL) {
            score = zzlGetScore(sptr);
            serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
            if (vstr == NULL)
                ele = createStringObjectFromLongLong(vlong);
            else
                ele = createStringObject((char*)vstr,vlen);

            /* Has incremented refcount since it was just created. */
            node = zslInsert(zs->zsl,score,ele);
            serverAssertWithInfo(NULL,zobj,dictAdd(zs->dict,ele,&node->score) == DICT_OK);
            incrRefCount(ele); /* Added to dictionary. */
            zzlNext(zl,&eptr,&sptr);
        }

        zfree(zobj->ptr);
        zobj->ptr = zs;
        zobj->encoding = OBJ_ENCODING_SKIPLIST;
    } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
        unsigned char *zl = ziplistNew();

        if (encoding != OBJ_ENCODING_ZIPLIST)
            serverPanic("Unknown target encoding");

        /* Approach similar to zslFree(), since we want to free the skiplist at
         * the same time as creating the ziplist. */
        zs = zobj->ptr;
        dictRelease(zs->dict);
        node = zs->zsl->header->level[0].forward;
        zfree(zs->zsl->header);
        zfree(zs->zsl);

        while (node) {
            ele = getDecodedObject(node->obj);
            zl = zzlInsertAt(zl,NULL,ele,node->score);
            decrRefCount(ele);

            next = node->level[0].forward;
            zslFreeNode(node);
            node = next;
        }

        zfree(zs);
        zobj->ptr = zl;
        zobj->encoding = OBJ_ENCODING_ZIPLIST;
    } else {
        serverPanic("Unknown sorted set encoding");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl %esi, %eax
je 0x4933c
movl %esi, %ebp
movq %rdi, %r13
cmpl $0x7, %eax
je 0x4928c
cmpl $0x5, %eax
jne 0x4938e
cmpl $0x7, %ebp
jne 0x493a3
movq %r13, (%rsp)
movq 0x8(%r13), %r15
pushq $0x10
popq %rdi
callq 0x327b9
movq %rax, %r14
leaq 0xafc4b(%rip), %rdi     # 0xf8de0
xorl %esi, %esi
callq 0x2a155
movq %rax, (%r14)
callq 0x478ee
movq %rax, 0x8(%r14)
movq %r15, %rdi
xorl %esi, %esi
callq 0x35aca
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x493d2
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x35b60
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x493ee
leaq 0x28(%rsp), %rbp
leaq 0x18(%rsp), %rbx
leaq 0x10(%rsp), %r12
testq %r13, %r13
je 0x4931f
movq 0x10(%rsp), %rdi
callq 0x48535
movsd %xmm0, 0x20(%rsp)
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
leaq 0xc(%rsp), %rdx
movq %rbp, %rcx
callq 0x35be8
testl %eax, %eax
je 0x4934b
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x49236
movl 0xc(%rsp), %esi
callq 0x39e29
jmp 0x49240
movq 0x28(%rsp), %rdi
callq 0x39e38
movq %rax, %r13
movq 0x8(%r14), %rdi
movsd 0x20(%rsp), %xmm0
movq %rax, %rsi
callq 0x479ab
movq (%r14), %rdi
leaq 0x8(%rax), %rdx
movq %r13, %rsi
callq 0x2a3ed
testl %eax, %eax
jne 0x49367
movq %r13, %rdi
callq 0x39e74
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x486f3
movq 0x18(%rsp), %r13
jmp 0x491eb
callq 0x3540c
cmpl $0x5, %ebp
jne 0x493b8
movq %rax, %rbx
movq 0x8(%r13), %r14
movq (%r14), %rdi
callq 0x2a8da
movq 0x8(%r14), %rax
movq (%rax), %rdi
movq 0x18(%rdi), %r15
callq 0x328f9
movq 0x8(%r14), %rdi
callq 0x328f9
testq %r15, %r15
je 0x49301
movq (%r15), %rdi
callq 0x3a57d
movq %rax, %r12
movsd 0x8(%r15), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x48da4
movq %rax, %rbx
movq %r12, %rdi
callq 0x3a265
movq 0x18(%r15), %r12
movq %r15, %rdi
callq 0x47944
movq %r12, %r15
jmp 0x492c2
movq %r14, %rdi
callq 0x328f9
movq %rbx, 0x8(%r13)
movl $0xffffff0f, %eax       # imm = 0xFFFFFF0F
andl (%r13), %eax
orl $0x50, %eax
movl %eax, (%r13)
jmp 0x4933c
movq (%rsp), %rbx
movq 0x8(%rbx), %rdi
callq 0x328f9
movq %r14, 0x8(%rbx)
movl $0xffffff0f, %eax       # imm = 0xFFFFFF0F
andl (%rbx), %eax
orl $0x70, %eax
movl %eax, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6b837(%rip), %rdx     # 0xb4b89
leaq 0x6b7f9(%rip), %rcx     # 0xb4b52
xorl %edi, %edi
movq (%rsp), %rsi
movl $0x461, %r8d            # imm = 0x461
jmp 0x49381
leaq 0x6b900(%rip), %rdx     # 0xb4c6e
leaq 0x6b7dd(%rip), %rcx     # 0xb4b52
xorl %edi, %edi
movq (%rsp), %rsi
movl $0x469, %r8d            # imm = 0x469
callq 0x588a4
pushq $0x1
popq %rdi
callq 0x263c0
leaq 0x69209(%rip), %rdi     # 0xb259e
leaq 0x6b7b6(%rip), %rsi     # 0xb4b52
movl $0x48d, %edx            # imm = 0x48D
jmp 0x493cb
leaq 0x6b8aa(%rip), %rdi     # 0xb4c54
leaq 0x6b7a1(%rip), %rsi     # 0xb4b52
movl $0x454, %edx            # imm = 0x454
jmp 0x493cb
leaq 0x6b895(%rip), %rdi     # 0xb4c54
leaq 0x6b78c(%rip), %rsi     # 0xb4b52
movl $0x475, %edx            # imm = 0x475
callq 0x57b45
jmp 0x49386
leaq 0x6b802(%rip), %rdx     # 0xb4bdb
leaq 0x6b772(%rip), %rcx     # 0xb4b52
xorl %edi, %edi
movq (%rsp), %rsi
movl $0x45b, %r8d            # imm = 0x45B
jmp 0x49381
leaq 0x6bb0d(%rip), %rdx     # 0xb4f02
leaq 0x6b756(%rip), %rcx     # 0xb4b52
xorl %edi, %edi
movq (%rsp), %rsi
movl $0x45d, %r8d            # imm = 0x45D
jmp 0x49381