// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: zcountCommand
void zcountCommand(client *c) {
    robj *key = c->argv[1];
    robj *zobj;
    zrangespec range;
    int count = 0;

    /* Parse the range arguments */
    if (zslParseRange(c->argv[2],c->argv[3],&range) != C_OK) {
        addReplyError(c,"min or max is not a float");
        return;
    }

    /* Lookup the sorted set */
    if ((zobj = lookupKeyReadOrReply(c, key, shared.czero)) == NULL ||
        checkType(c, zobj, OBJ_ZSET)) return;

    if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
        unsigned char *zl = zobj->ptr;
        unsigned char *eptr, *sptr;
        double score;

        /* Use the first element in range as the starting point */
        eptr = zzlFirstInRange(zl,&range);

        /* No "first" element */
        if (eptr == NULL) {
            addReply(c, shared.czero);
            return;
        }

        /* First element is in range */
        sptr = ziplistNext(zl,eptr);
        score = zzlGetScore(sptr);
        serverAssertWithInfo(c,zobj,zslValueLteMax(score,&range));

        /* Iterate over elements in range */
        while (eptr) {
            score = zzlGetScore(sptr);

            /* Abort when the node is no longer in range. */
            if (!zslValueLteMax(score,&range)) {
                break;
            } else {
                count++;
                zzlNext(zl,&eptr,&sptr);
            }
        }
    } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
        zset *zs = zobj->ptr;
        zskiplist *zsl = zs->zsl;
        zskiplistNode *zn;
        unsigned long rank;

        /* Find first element in range */
        zn = zslFirstInRange(zsl, &range);

        /* Use rank of first element, if any, to determine preliminary count */
        if (zn != NULL) {
            rank = zslGetRank(zsl, zn->score, zn->obj);
            count = (zsl->length - (rank - 1));

            /* Find last element in range */
            zn = zslLastInRange(zsl, &range);

            /* Use rank of last element, if any, to determine the actual count */
            if (zn != NULL) {
                rank = zslGetRank(zsl, zn->score, zn->obj);
                count -= (zsl->length - rank);
            }
        }
    } else {
        serverPanic("Unknown sorted set encoding");
    }

    addReplyLongLong(c, count);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x10(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rsi
leaq -0x30(%rbp), %rdx
callq 0x62750
cmpl $0x0, %eax
je 0x65181
movq -0x8(%rbp), %rdi
leaq 0xd8d05(%rip), %rsi     # 0x13de7c
callq 0x42f90
jmp 0x653b9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq 0x113ab0(%rip), %rax    # 0x178c40
movq 0x20(%rax), %rdx
callq 0x4a730
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x651ba
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x3, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x651bf
jmp 0x653b9
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x652bd
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x603a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x65211
movq -0x8(%rbp), %rdi
leaq 0x113a3d(%rip), %rax    # 0x178c40
movq 0x20(%rax), %rsi
callq 0x42cc0
jmp 0x653b9
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x412e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x5fe60
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
leaq -0x30(%rbp), %rdi
callq 0x5ea10
cmpl $0x0, %eax
je 0x65245
jmp 0x65270
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0xd8d8b(%rip), %rdx     # 0x13dfdf
leaq 0xd89c7(%rip), %rcx     # 0x13dc22
movl $0x9d8, %r8d            # imm = 0x9D8
callq 0x78360
movl $0x1, %edi
callq 0x263c0
jmp 0x65272
cmpq $0x0, -0x48(%rbp)
je 0x652b8
movq -0x50(%rbp), %rdi
callq 0x5fe60
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
leaq -0x30(%rbp), %rdi
callq 0x5ea10
cmpl $0x0, %eax
jne 0x6529c
jmp 0x652b8
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x600e0
jmp 0x65272
jmp 0x653ac
movq -0x18(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x65388
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5eb90
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x65386
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x70(%rbp), %rax
movq (%rax), %rsi
callq 0x5f590
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
subq $0x1, %rcx
subq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5ecd0
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x65384
movq -0x68(%rbp), %rdi
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x70(%rbp), %rax
movq (%rax), %rsi
callq 0x5f590
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rcx
subq -0x78(%rbp), %rcx
movslq -0x34(%rbp), %rax
subq %rcx, %rax
movl %eax, -0x34(%rbp)
jmp 0x65386
jmp 0x653aa
leaq 0xd635b(%rip), %rdi     # 0x13b6ea
leaq 0xd888c(%rip), %rsi     # 0x13dc22
movl $0x9fe, %edx            # imm = 0x9FE
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x653ac
movq -0x8(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x43780
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)