// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/aof.c
// Function: rewriteSortedSetObject
int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
    long long count = 0, items = zsetLength(o);

    if (o->encoding == OBJ_ENCODING_ZIPLIST) {
        unsigned char *zl = o->ptr;
        unsigned char *eptr, *sptr;
        unsigned char *vstr;
        unsigned int vlen;
        long long vll;
        double score;

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

        while (eptr != NULL) {
            serverAssert(ziplistGet(eptr,&vstr,&vlen,&vll));
            score = zzlGetScore(sptr);

            if (count == 0) {
                int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
                    AOF_REWRITE_ITEMS_PER_CMD : items;

                if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
                if (rioWriteBulkString(r,"ZADD",4) == 0) return 0;
                if (rioWriteBulkObject(r,key) == 0) return 0;
            }
            if (rioWriteBulkDouble(r,score) == 0) return 0;
            if (vstr != NULL) {
                if (rioWriteBulkString(r,(char*)vstr,vlen) == 0) return 0;
            } else {
                if (rioWriteBulkLongLong(r,vll) == 0) return 0;
            }
            zzlNext(zl,&eptr,&sptr);
            if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0;
            items--;
        }
    } else if (o->encoding == OBJ_ENCODING_SKIPLIST) {
        zset *zs = o->ptr;
        dictIterator *di = dictGetIterator(zs->dict);
        dictEntry *de;

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

            if (count == 0) {
                int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
                    AOF_REWRITE_ITEMS_PER_CMD : items;

                if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
                if (rioWriteBulkString(r,"ZADD",4) == 0) return 0;
                if (rioWriteBulkObject(r,key) == 0) return 0;
            }
            if (rioWriteBulkDouble(r,*score) == 0) return 0;
            if (rioWriteBulkObject(r,eleobj) == 0) return 0;
            if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0;
            items--;
        }
        dictReleaseIterator(di);
    } else {
        serverPanic("Unknown sorted zset encoding");
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x61060
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x73171
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x41120
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x72f67
jmp 0x72f89
leaq 0xcad3d(%rip), %rdi     # 0x13dcab
leaq 0xcc402(%rip), %rsi     # 0x13f377
movl $0x381, %edx            # imm = 0x381
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x412e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x72fa3
jmp 0x72fc5
leaq 0xcb028(%rip), %rdi     # 0x13dfd2
leaq 0xcc3c6(%rip), %rsi     # 0x13f377
movl $0x383, %edx            # imm = 0x383
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
jmp 0x72fc7
cmpq $0x0, -0x40(%rbp)
je 0x7316c
movq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x54(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x41470
cmpl $0x0, %eax
je 0x72fee
jmp 0x73010
leaq 0xccb6b(%rip), %rdi     # 0x13fb60
leaq 0xcc37b(%rip), %rsi     # 0x13f377
movl $0x386, %edx            # imm = 0x386
callq 0x76ce0
movl $0x1, %edi
callq 0x263c0
movq -0x48(%rbp), %rdi
callq 0x5fe60
movsd %xmm0, -0x68(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x730c2
cmpq $0x40, -0x30(%rbp)
jle 0x7303e
movl $0x40, %eax
movq %rax, -0xa8(%rbp)
jmp 0x73049
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movl %eax, -0x6c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x6c(%rbp), %edx
shll %edx
addl $0x2, %edx
movl $0x2a, %esi
callq 0x8e820
cmpq $0x0, %rax
jne 0x7307b
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x10(%rbp), %rdi
leaq 0xccafc(%rip), %rsi     # 0x13fb82
movl $0x4, %edx
callq 0x8e9c0
cmpq $0x0, %rax
jne 0x730a2
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x729c0
cmpl $0x0, %eax
jne 0x730c0
movl $0x0, -0x4(%rbp)
jmp 0x7332b
jmp 0x730c2
movq -0x10(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
callq 0x8eab0
cmpq $0x0, %rax
jne 0x730e2
movl $0x0, -0x4(%rbp)
jmp 0x7332b
cmpq $0x0, -0x50(%rbp)
je 0x7310f
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0x8e9c0
cmpq $0x0, %rax
jne 0x7310d
movl $0x0, -0x4(%rbp)
jmp 0x7332b
jmp 0x73130
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x8ea70
cmpq $0x0, %rax
jne 0x7312e
movl $0x0, -0x4(%rbp)
jmp 0x7332b
jmp 0x73130
movq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x600e0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x40, %rax
jne 0x7315b
movq $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x72fc7
jmp 0x73324
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x73300
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rdi
callq 0x2e400
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x2e4a0
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x732f5
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x73289
cmpq $0x40, -0x30(%rbp)
jle 0x731ff
movl $0x40, %eax
movq %rax, -0xb0(%rbp)
jmp 0x7320a
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movl %eax, -0x9c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x9c(%rbp), %edx
shll %edx
addl $0x2, %edx
movl $0x2a, %esi
callq 0x8e820
cmpq $0x0, %rax
jne 0x73242
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x10(%rbp), %rdi
leaq 0xcc935(%rip), %rsi     # 0x13fb82
movl $0x4, %edx
callq 0x8e9c0
cmpq $0x0, %rax
jne 0x73269
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x729c0
cmpl $0x0, %eax
jne 0x73287
movl $0x0, -0x4(%rbp)
jmp 0x7332b
jmp 0x73289
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rax
movsd (%rax), %xmm0
callq 0x8eab0
cmpq $0x0, %rax
jne 0x732ac
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x729c0
cmpl $0x0, %eax
jne 0x732ca
movl $0x0, -0x4(%rbp)
jmp 0x7332b
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x40, %rax
jne 0x732e4
movq $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x731a2
movq -0x80(%rbp), %rdi
callq 0x2e600
jmp 0x73322
leaq 0xcc880(%rip), %rdi     # 0x13fb87
leaq 0xcc069(%rip), %rsi     # 0x13f377
movl $0x3b3, %edx            # imm = 0x3B3
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x73324
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)