// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x51b26
movl $0x0, -0x4(%rbp)
jmp 0x51dd3
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x51b41
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3aaa0
movq -0x18(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x1f110
movq -0x10(%rbp), %rax
cmpl $0x2, 0x8(%rax)
jne 0x51c53
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x6, 0xc(%rax)
jne 0x51bcb
movq -0x20(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %esi
leaq -0x28(%rbp), %rdx
callq 0x67a60
cmpb $0x0, %al
jne 0x51b9c
movl $0x0, -0x4(%rbp)
jmp 0x51dd3
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rax
movsd 0x8c624(%rip), %xmm0    # 0xde1d8
movsd %xmm0, 0x48(%rax)
movq -0x20(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x51c4e
movq -0x10(%rbp), %rax
cmpl $0x2, 0xc(%rax)
jne 0x51c2a
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x51bec
movl $0x0, -0x4(%rbp)
jmp 0x51dd3
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movsd 0x8c5cd(%rip), %xmm0    # 0xde1d8
movsd %xmm0, 0x48(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x24270
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x51c4c
leaq 0x90f33(%rip), %rdi     # 0xe2b64
leaq 0x91656(%rip), %rsi     # 0xe328e
movl $0x976, %edx            # imm = 0x976
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x51c4e
jmp 0x51dcc
movq -0x10(%rbp), %rax
cmpl $0x3, 0x8(%rax)
jne 0x51da8
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x5, 0xc(%rax)
jne 0x51d22
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x51c91
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x51c9d
movl $0x0, -0x4(%rbp)
jmp 0x51dd3
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdx
addq $0x38, %rdx
movq -0x18(%rbp), %rcx
addq $0x40, %rcx
callq 0x33490
cmpl $0x0, %eax
je 0x51cc9
jmp 0x51ceb
leaq 0x91812(%rip), %rdi     # 0xe34e2
leaq 0x915b7(%rip), %rsi     # 0xe328e
movl $0x987, %edx            # imm = 0x987
callq 0x63ca0
movl $0x1, %edi
callq 0x1f3b0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x4ee80
movq -0x18(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x30(%rbp), %rsi
addq $0x8, %rsi
movq -0x30(%rbp), %rdx
addq $0x10, %rdx
callq 0x4f100
jmp 0x51da6
movq -0x10(%rbp), %rax
cmpl $0x7, 0xc(%rax)
jne 0x51d82
movq -0x30(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x51d43
movl $0x0, -0x4(%rbp)
jmp 0x51dd3
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movsd 0x8(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x48(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x51da4
leaq 0x8f712(%rip), %rdi     # 0xe149b
leaq 0x914fe(%rip), %rsi     # 0xe328e
movl $0x99a, %edx            # imm = 0x99A
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x51da6
jmp 0x51dca
leaq 0x91720(%rip), %rdi     # 0xe34cf
leaq 0x914d8(%rip), %rsi     # 0xe328e
movl $0x99d, %edx            # imm = 0x99D
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x51dcc
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)