// File: /workspace/github_c_makefile_star2_O1/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 0x3fe3c
movq %rsi, %r14
movq %rdi, %rbx
testb $0x1, (%rsi)
je 0x3fcfc
movq 0x28(%r14), %rdi
callq 0x30834
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 0x3fd75
cmpl $0x2, %eax
jne 0x3fe4b
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
je 0x3fe0c
cmpl $0x6, %eax
jne 0x3fe75
movq 0x18(%rbx), %rdi
movl 0x20(%rbx), %esi
leaq 0x8(%rsp), %rdx
callq 0x4f9dc
testb %al, %al
je 0x3fe3c
movq 0x8(%rsp), %rax
movq %rax, 0x40(%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x48(%r14)
incl 0x20(%rbx)
jmp 0x3fe37
movl 0xc(%rbx), %eax
cmpl $0x7, %eax
je 0x3fddf
cmpl $0x5, %eax
jne 0x3fe60
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3fe3c
cmpq $0x0, 0x28(%rbx)
je 0x3fe3c
leaq 0x30(%r14), %rsi
leaq 0x38(%r14), %rdx
leaq 0x40(%r14), %rcx
callq 0x2c351
testl %eax, %eax
je 0x3fe97
leaq 0x20(%rbx), %r15
leaq 0x28(%rbx), %r12
movq 0x28(%rbx), %rdi
callq 0x3ddbd
movsd %xmm0, 0x48(%r14)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3df7d
jmp 0x3fe37
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x3fe3c
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 0x3fe37
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x3fe3c
movq (%rax), %rax
movq %rax, 0x28(%r14)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x48(%r14)
movq 0x20(%rbx), %rdi
callq 0x22913
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 0x595a5(%rip), %rdi     # 0x993f7
leaq 0x5935d(%rip), %rsi     # 0x991b6
movl $0x99d, %edx            # imm = 0x99D
jmp 0x3fe88
leaq 0x574ec(%rip), %rdi     # 0x97353
leaq 0x59348(%rip), %rsi     # 0x991b6
movl $0x99a, %edx            # imm = 0x99A
jmp 0x3fe88
leaq 0x58c20(%rip), %rdi     # 0x98a9c
leaq 0x59333(%rip), %rsi     # 0x991b6
movl $0x976, %edx            # imm = 0x976
callq 0x4d0e5
movl $0x1, %edi
callq 0x1f3b0
leaq 0x5956c(%rip), %rdi     # 0x9940a
leaq 0x59311(%rip), %rsi     # 0x991b6
movl $0x987, %edx            # imm = 0x987
callq 0x4d037
jmp 0x3fe8d