// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl -0xc(%rbp), %eax
jne 0x61115
jmp 0x61491
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x6135a
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
cmpl $0x7, -0xc(%rbp)
je 0x6115e
leaq 0xdcbe1(%rip), %rdi     # 0x13dd24
leaq 0xdcad8(%rip), %rsi     # 0x13dc22
movl $0x454, %edx            # imm = 0x454
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
movl $0x10, %edi
callq 0x3acd0
movq %rax, -0x18(%rbp)
leaq 0x115c6d(%rip), %rdi    # 0x176de0
xorl %eax, %eax
movl %eax, %esi
callq 0x2d330
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
callq 0x5dfb0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x41120
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x611ae
jmp 0x611d9
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0xdcaee(%rip), %rdx     # 0x13dcab
leaq 0xdca5e(%rip), %rcx     # 0x13dc22
movl $0x45b, %r8d            # imm = 0x45B
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x412e0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x611f3
jmp 0x6121e
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0xdcdd0(%rip), %rdx     # 0x13dfd2
leaq 0xdca19(%rip), %rcx     # 0x13dc22
movl $0x45d, %r8d            # imm = 0x45D
callq 0x78360
movl $0x1, %edi
callq 0x263c0
jmp 0x61220
cmpq $0x0, -0x48(%rbp)
je 0x6132b
movq -0x50(%rbp), %rdi
callq 0x5fe60
movsd %xmm0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
leaq -0x68(%rbp), %rcx
callq 0x41470
cmpl $0x0, %eax
je 0x61255
jmp 0x61280
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0xdc9f5(%rip), %rdx     # 0x13dc59
leaq 0xdc9b7(%rip), %rcx     # 0x13dc22
movl $0x461, %r8d            # imm = 0x461
callq 0x78360
movl $0x1, %edi
callq 0x263c0
cmpq $0x0, -0x58(%rbp)
jne 0x61296
movq -0x68(%rbp), %rdi
callq 0x486f0
movq %rax, -0x30(%rbp)
jmp 0x612a8
movq -0x58(%rbp), %rdi
movl -0x5c(%rbp), %eax
movl %eax, %esi
callq 0x486a0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
movsd -0x38(%rbp), %xmm0
movq -0x30(%rbp), %rsi
callq 0x5e160
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
addq $0x8, %rdx
callq 0x2d8c0
cmpl $0x0, %eax
jne 0x612e1
jmp 0x6130c
movq -0x8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
leaq 0xdca4e(%rip), %rdx     # 0x13dd3e
leaq 0xdc92b(%rip), %rcx     # 0x13dc22
movl $0x469, %r8d            # imm = 0x469
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x30(%rbp), %rdi
callq 0x487b0
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x600e0
jmp 0x61220
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3afa0
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff0f, %ecx       # imm = 0xFFFFFF0F
orl $0x70, %ecx
movl %ecx, (%rax)
jmp 0x61491
movq -0x8(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x6146d
callq 0x40630
movq %rax, -0x70(%rbp)
cmpl $0x5, -0xc(%rbp)
je 0x613a0
leaq 0xdc99f(%rip), %rdi     # 0x13dd24
leaq 0xdc896(%rip), %rsi     # 0x13dc22
movl $0x475, %edx            # imm = 0x475
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x2e230
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
callq 0x3afa0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3afa0
cmpq $0x0, -0x20(%rbp)
je 0x61445
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x494f0
movq %rax, -0x30(%rbp)
movq -0x70(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rax
movsd 0x8(%rax), %xmm0
xorl %eax, %eax
movl %eax, %esi
callq 0x60ae0
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
callq 0x48f70
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5e070
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x613e8
movq -0x18(%rbp), %rdi
callq 0x3afa0
movq -0x70(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %ecx
andl $0xffffff0f, %ecx       # imm = 0xFFFFFF0F
orl $0x50, %ecx
movl %ecx, (%rax)
jmp 0x6148f
leaq 0xda276(%rip), %rdi     # 0x13b6ea
leaq 0xdc7a7(%rip), %rsi     # 0x13dc22
movl $0x48d, %edx            # imm = 0x48D
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x61491
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)