// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: zrankGenericCommand
void zrankGenericCommand(client *c, int reverse) {
    robj *key = c->argv[1];
    robj *ele = c->argv[2];
    robj *zobj;
    unsigned long llen;
    unsigned long rank;

    if ((zobj = lookupKeyReadOrReply(c,key,shared.nullbulk)) == NULL ||
        checkType(c,zobj,OBJ_ZSET)) return;
    llen = zsetLength(zobj);

    serverAssertWithInfo(c,ele,sdsEncodedObject(ele));

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

        eptr = ziplistIndex(zl,0);
        serverAssertWithInfo(c,zobj,eptr != NULL);
        sptr = ziplistNext(zl,eptr);
        serverAssertWithInfo(c,zobj,sptr != NULL);

        rank = 1;
        while(eptr != NULL) {
            if (ziplistCompare(eptr,ele->ptr,sdslen(ele->ptr)))
                break;
            rank++;
            zzlNext(zl,&eptr,&sptr);
        }

        if (eptr != NULL) {
            if (reverse)
                addReplyLongLong(c,llen-rank);
            else
                addReplyLongLong(c,rank-1);
        } else {
            addReply(c,shared.nullbulk);
        }
    } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
        zset *zs = zobj->ptr;
        zskiplist *zsl = zs->zsl;
        dictEntry *de;
        double score;

        ele = c->argv[2];
        de = dictFind(zs->dict,ele);
        if (de != NULL) {
            score = *(double*)dictGetVal(de);
            rank = zslGetRank(zsl,score,ele);
            serverAssertWithInfo(c,ele,rank); /* Existing elements always have a rank. */
            if (reverse)
                addReplyLongLong(c,llen-rank);
            else
                addReplyLongLong(c,rank-1);
        } else {
            addReply(c,shared.nullbulk);
        }
    } else {
        serverPanic("Unknown sorted set encoding");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x112dbf(%rip), %rax    # 0x178c40
movq 0x50(%rax), %rdx
callq 0x4a730
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x65eab
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x3, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x65eb0
jmp 0x66185
movq -0x28(%rbp), %rdi
callq 0x61060
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x65ee1
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
jne 0x65ee3
jmp 0x65f0e
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd7df6(%rip), %rdx     # 0x13dce8
leaq 0xd7d29(%rip), %rcx     # 0x13dc22
movl $0xb30, %r8d            # imm = 0xB30
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x66068
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x41120
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x65f47
jmp 0x65f72
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0xd7d55(%rip), %rdx     # 0x13dcab
leaq 0xd7cc5(%rip), %rcx     # 0x13dc22
movl $0xb37, %r8d            # imm = 0xB37
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x412e0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x65f8c
jmp 0x65fb7
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq 0xd8037(%rip), %rdx     # 0x13dfd2
leaq 0xd7c80(%rip), %rcx     # 0x13dc22
movl $0xb39, %r8d            # imm = 0xB39
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq $0x1, -0x38(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x6601c
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x5f9b0
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl %eax, %edx
callq 0x41630
cmpl $0x0, %eax
je 0x65ffd
jmp 0x6601c
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x600e0
jmp 0x65fbf
cmpq $0x0, -0x48(%rbp)
je 0x6604f
cmpl $0x0, -0xc(%rbp)
je 0x6603c
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
subq -0x38(%rbp), %rsi
callq 0x43780
jmp 0x6604d
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
callq 0x43780
jmp 0x66063
movq -0x8(%rbp), %rdi
leaq 0x112be6(%rip), %rax    # 0x178c40
movq 0x50(%rax), %rsi
callq 0x42cc0
jmp 0x66185
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x66161
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x2dcb0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x6614b
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x60(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
movq -0x20(%rbp), %rsi
callq 0x5f590
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x660f4
jmp 0x6611f
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd15ca(%rip), %rdx     # 0x1376cd
leaq 0xd7b18(%rip), %rcx     # 0x13dc22
movl $0xb56, %r8d            # imm = 0xB56
callq 0x78360
movl $0x1, %edi
callq 0x263c0
cmpl $0x0, -0xc(%rbp)
je 0x66138
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
subq -0x38(%rbp), %rsi
callq 0x43780
jmp 0x66149
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
callq 0x43780
jmp 0x6615f
movq -0x8(%rbp), %rdi
leaq 0x112aea(%rip), %rax    # 0x178c40
movq 0x50(%rax), %rsi
callq 0x42cc0
jmp 0x66183
leaq 0xd5582(%rip), %rdi     # 0x13b6ea
leaq 0xd7ab3(%rip), %rsi     # 0x13dc22
movl $0xb5f, %edx            # imm = 0xB5F
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x66185
addq $0x80, %rsp
popq %rbp
retq
nop