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

    if (o->encoding == REDIS_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);
        redisAssert(eptr != NULL);
        sptr = ziplistNext(zl,eptr);
        redisAssert(sptr != NULL);

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

            if (count == 0) {
                int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ?
                    REDIS_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 == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
            items--;
        }
    } else if (o->encoding == REDIS_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 > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ?
                    REDIS_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 == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0;
            items--;
        }
        dictReleaseIterator(di);
    } else {
        redisPanic("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 0x50080
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x60931
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0x32e50
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x60727
jmp 0x60749
leaq 0x82be9(%rip), %rdi     # 0xe3317
leaq 0x83fa0(%rip), %rsi     # 0xe46d5
movl $0x49a, %edx            # imm = 0x49A
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x33330
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x60763
jmp 0x60785
leaq 0x82e6a(%rip), %rdi     # 0xe35d4
leaq 0x83f64(%rip), %rsi     # 0xe46d5
movl $0x49c, %edx            # imm = 0x49C
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
jmp 0x60787
cmpq $0x0, -0x40(%rbp)
je 0x6092c
movq -0x40(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x54(%rbp), %rdx
leaq -0x60(%rbp), %rcx
callq 0x33490
cmpl $0x0, %eax
je 0x607ae
jmp 0x607d0
leaq 0x84430(%rip), %rdi     # 0xe4be5
leaq 0x83f19(%rip), %rsi     # 0xe46d5
movl $0x49f, %edx            # imm = 0x49F
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x48(%rbp), %rdi
callq 0x4ee80
movsd %xmm0, -0x68(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x60882
cmpq $0x40, -0x30(%rbp)
jle 0x607fe
movl $0x40, %eax
movq %rax, -0xa8(%rbp)
jmp 0x60809
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 0x75eb0
cmpq $0x0, %rax
jne 0x6083b
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x10(%rbp), %rdi
leaq 0x843c1(%rip), %rsi     # 0xe4c07
movl $0x4, %edx
callq 0x76050
cmpq $0x0, %rax
jne 0x60862
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x60010
cmpl $0x0, %eax
jne 0x60880
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
jmp 0x60882
movq -0x10(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
callq 0x76140
cmpq $0x0, %rax
jne 0x608a2
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
cmpq $0x0, -0x50(%rbp)
je 0x608cf
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0x76050
cmpq $0x0, %rax
jne 0x608cd
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
jmp 0x608f0
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x76100
cmpq $0x0, %rax
jne 0x608ee
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
jmp 0x608f0
movq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x4f100
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x40, %rax
jne 0x6091b
movq $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x60787
jmp 0x60ae4
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x60ac0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq (%rax), %rdi
callq 0x241d0
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x24270
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x60ab5
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 0x60a49
cmpq $0x40, -0x30(%rbp)
jle 0x609bf
movl $0x40, %eax
movq %rax, -0xb0(%rbp)
jmp 0x609ca
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 0x75eb0
cmpq $0x0, %rax
jne 0x60a02
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x10(%rbp), %rdi
leaq 0x841fa(%rip), %rsi     # 0xe4c07
movl $0x4, %edx
callq 0x76050
cmpq $0x0, %rax
jne 0x60a29
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x60010
cmpl $0x0, %eax
jne 0x60a47
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
jmp 0x60a49
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rax
movsd (%rax), %xmm0
callq 0x76140
cmpq $0x0, %rax
jne 0x60a6c
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x60010
cmpl $0x0, %eax
jne 0x60a8a
movl $0x0, -0x4(%rbp)
jmp 0x60aeb
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
cmpq $0x40, %rax
jne 0x60aa4
movq $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x60962
movq -0x80(%rbp), %rdi
callq 0x243d0
jmp 0x60ae2
leaq 0x84145(%rip), %rdi     # 0xe4c0c
leaq 0x83c07(%rip), %rsi     # 0xe46d5
movl $0x4cc, %edx            # imm = 0x4CC
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x60ae4
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)