// File: /workspace/github_c_makefile_star2_O3/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: zuiNext
int zuiNext(zsetopsrc *op, zsetopval *val) {

    if (op->subject == NULL)
        return 0;

    // 对上次的对象进行清理
    if (val->flags & OPVAL_DIRTY_ROBJ)
        decrRefCount(val->ele);

    // 清零 val 结构
    memset(val,0,sizeof(zsetopval));

    // 迭代集合
    if (op->type == REDIS_SET) {

        iterset *it = &op->iter.set;

        // ziplist 编码的集合
        if (op->encoding == REDIS_ENCODING_INTSET) {
            int64_t ell;

            // 取出成员
            if (!intsetGet(it->is.is,it->is.ii,&ell))
                return 0;
            val->ell = ell;
            // 分值默认为 1.0
            val->score = 1.0;

            /* Move to next element. */
            it->is.ii++;

        // 字典编码的集合
        } else if (op->encoding == REDIS_ENCODING_HT) {

            // 已为空？
            if (it->ht.de == NULL)
                return 0;

            // 取出成员
            val->ele = dictGetKey(it->ht.de);
            // 分值默认为 1.0
            val->score = 1.0;

            /* Move to next element. */
            it->ht.de = dictNext(it->ht.di);
        } else {
            redisPanic("Unknown set encoding");
        }

    // 迭代有序集合
    } else if (op->type == REDIS_ZSET) {

        iterzset *it = &op->iter.zset;

        // ziplist 编码的有序集合
        if (op->encoding == REDIS_ENCODING_ZIPLIST) {

            /* No need to check both, but better be explicit. */
            // 为空？
            if (it->zl.eptr == NULL || it->zl.sptr == NULL)
                return 0;

            // 取出成员
            redisAssert(ziplistGet(it->zl.eptr,&val->estr,&val->elen,&val->ell));
            // 取出分值
            val->score = zzlGetScore(it->zl.sptr);

            /* Move to next element. */
            zzlNext(it->zl.zl,&it->zl.eptr,&it->zl.sptr);

        // SKIPLIST 编码的有序集合
        } else if (op->encoding == REDIS_ENCODING_SKIPLIST) {

            if (it->sl.node == NULL)
                return 0;

            val->ele = it->sl.node->obj;
            val->score = it->sl.node->score;

            /* Move to next element. */
            it->sl.node = it->sl.node->level[0].forward;
        } else {
            redisPanic("Unknown sorted set encoding");
        }
    } else {
        redisPanic("Unsupported type");
    }

    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
xorl %ebp, %ebp
cmpq $0x0, (%rdi)
je 0x3fe6c
movq %rsi, %r14
movq %rdi, %rbx
testb $0x1, (%rsi)
je 0x3fd2c
movq 0x28(%r14), %rdi
callq 0x30b0c
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movl 0x8(%rbx), %eax
cmpl $0x3, %eax
je 0x3fda5
cmpl $0x2, %eax
jne 0x3fe7b
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
je 0x3fe3c
cmpl $0x6, %eax
jne 0x3fea5
movq 0x18(%rbx), %rdi
movl 0x20(%rbx), %esi
leaq 0x8(%rsp), %rdx
callq 0x4f48d
testb %al, %al
je 0x3fe6c
movq 0x8(%rsp), %rax
movq %rax, 0x40(%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x48(%r14)
incl 0x20(%rbx)
jmp 0x3fe67
movl 0xc(%rbx), %eax
cmpl $0x7, %eax
je 0x3fe0f
cmpl $0x5, %eax
jne 0x3fe90
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3fe6c
cmpq $0x0, 0x28(%rbx)
je 0x3fe6c
leaq 0x30(%r14), %rsi
leaq 0x38(%r14), %rdx
leaq 0x40(%r14), %rcx
callq 0x2c5f6
testl %eax, %eax
je 0x3fec7
leaq 0x20(%rbx), %r15
leaq 0x28(%rbx), %r12
movq 0x28(%rbx), %rdi
callq 0x3ded9
movsd %xmm0, 0x48(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3e09f
jmp 0x3fe67
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x3fe6c
movq (%rax), %rax
movq %rax, 0x28(%r14)
movq 0x20(%rbx), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, 0x48(%r14)
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
movq %rax, 0x20(%rbx)
jmp 0x3fe67
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x3fe6c
movq (%rax), %rax
movq %rax, 0x28(%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x48(%r14)
movq 0x20(%rbx), %rdi
callq 0x22acf
movq %rax, 0x28(%rbx)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x595be(%rip), %rdi     # 0x99440
leaq 0x59376(%rip), %rsi     # 0x991ff
movl $0x99d, %edx            # imm = 0x99D
jmp 0x3feb8
leaq 0x5751c(%rip), %rdi     # 0x973b3
leaq 0x59361(%rip), %rsi     # 0x991ff
movl $0x99a, %edx            # imm = 0x99A
jmp 0x3feb8
leaq 0x58c4c(%rip), %rdi     # 0x98af8
leaq 0x5934c(%rip), %rsi     # 0x991ff
movl $0x976, %edx            # imm = 0x976
callq 0x4cae0
movl $0x1, %edi
callq 0x1f3b0
leaq 0x59585(%rip), %rdi     # 0x99453
leaq 0x5932a(%rip), %rsi     # 0x991ff
movl $0x987, %edx            # imm = 0x987
callq 0x4ca32
jmp 0x3febd