// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %r15
leaq 0xae006(%rip), %r13     # 0xfa310
movq 0x50(%r13), %rdx
callq 0x3aee5
testq %rax, %rax
je 0x4c32d
movq %rax, %r12
pushq $0x3
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3a311
testl %eax, %eax
je 0x4c33c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x490f5
movl (%r15), %ecx
shrl $0x4, %ecx
testb $0x7, %cl
jne 0x4c4b7
movl %eax, %eax
movq %rax, 0x10(%rsp)
movl (%r12), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x4c3fc
cmpl $0x5, %eax
jne 0x4c4d3
movq 0x8(%r12), %r13
movq %r13, %rdi
xorl %esi, %esi
callq 0x35aca
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x4c4ed
movq %rax, %r14
movl %ebp, 0xc(%rsp)
movq %r13, %rdi
movq %rax, %rsi
callq 0x35b60
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x4c509
xorl %r12d, %r12d
testq %r14, %r14
je 0x4c44a
movq 0x8(%r15), %rbp
movq %rbp, %rdi
callq 0x482f2
movq %r14, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x35cd0
testl %eax, %eax
jne 0x4c462
movq %r13, %rdi
leaq 0x18(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x486f3
movq 0x18(%rsp), %r14
incq %r12
jmp 0x4c3b6
movq 0x8(%r12), %rax
movq (%rax), %rdi
movq 0x8(%rax), %r15
movq 0x40(%rbx), %rax
movq 0x10(%rax), %r14
movq %r14, %rsi
callq 0x2a5f9
testq %rax, %rax
je 0x4c481
movq 0x8(%rax), %rax
movsd (%rax), %xmm0
movq %r15, %rdi
movq %r14, %rsi
callq 0x48176
testq %rax, %rax
je 0x4c525
testl %ebp, %ebp
je 0x4c49b
movq 0x10(%rsp), %rsi
subq %rax, %rsi
movq %rbx, %rdi
jmp 0x4c4a4
leaq 0xadebf(%rip), %rax     # 0xfa310
movq 0x50(%rax), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x4c32d
cmpl $0x0, 0xc(%rsp)
je 0x4c471
notq %r12
addq 0x10(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x370a6
jmp 0x4c32d
movq 0x50(%r13), %rsi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36987
decq %rax
movq %rbx, %rdi
movq %rax, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x370a6
leaq 0x6875a(%rip), %rdx     # 0xb4c18
leaq 0x6868d(%rip), %rcx     # 0xb4b52
movq %rbx, %rdi
movq %r15, %rsi
movl $0xb30, %r8d            # imm = 0xB30
jmp 0x4c53f
leaq 0x660c4(%rip), %rdi     # 0xb259e
leaq 0x68671(%rip), %rsi     # 0xb4b52
movl $0xb5f, %edx            # imm = 0xB5F
callq 0x57b45
jmp 0x4c544
leaq 0x686e7(%rip), %rdx     # 0xb4bdb
leaq 0x68657(%rip), %rcx     # 0xb4b52
movq %rbx, %rdi
movq %r12, %rsi
movl $0xb37, %r8d            # imm = 0xB37
jmp 0x4c53f
leaq 0x689f2(%rip), %rdx     # 0xb4f02
leaq 0x6863b(%rip), %rcx     # 0xb4b52
movq %rbx, %rdi
movq %r12, %rsi
movl $0xb39, %r8d            # imm = 0xB39
jmp 0x4c53f
leaq 0x62121(%rip), %rdx     # 0xae64d
leaq 0x6861f(%rip), %rcx     # 0xb4b52
movq %rbx, %rdi
movq %r14, %rsi
movl $0xb56, %r8d            # imm = 0xB56
callq 0x588a4
pushq $0x1
popq %rdi
callq 0x263c0