// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: zrangeGenericCommand
void zrangeGenericCommand(client *c, int reverse) {
    robj *key = c->argv[1];
    robj *zobj;
    int withscores = 0;
    long start;
    long end;
    int llen;
    int rangelen;

    if ((getLongFromObjectOrReply(c, c->argv[2], &start, NULL) != C_OK) ||
        (getLongFromObjectOrReply(c, c->argv[3], &end, NULL) != C_OK)) return;

    if (c->argc == 5 && !strcasecmp(c->argv[4]->ptr,"withscores")) {
        withscores = 1;
    } else if (c->argc >= 5) {
        addReply(c,shared.syntaxerr);
        return;
    }

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

    /* Sanitize indexes. */
    llen = zsetLength(zobj);
    if (start < 0) start = llen+start;
    if (end < 0) end = llen+end;
    if (start < 0) start = 0;

    /* Invariant: start >= 0, so this test will be true when end < 0.
     * The range is empty when start > end or start >= length. */
    if (start > end || start >= llen) {
        addReply(c,shared.emptymultibulk);
        return;
    }
    if (end >= llen) end = llen-1;
    rangelen = (end-start)+1;

    /* Return the result in form of a multi-bulk reply */
    addReplyMultiBulkLen(c, withscores ? (rangelen*2) : rangelen);

    if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
        unsigned char *zl = zobj->ptr;
        unsigned char *eptr, *sptr;
        unsigned char *vstr;
        unsigned int vlen;
        long long vlong;

        if (reverse)
            eptr = ziplistIndex(zl,-2-(2*start));
        else
            eptr = ziplistIndex(zl,2*start);

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

        while (rangelen--) {
            serverAssertWithInfo(c,zobj,eptr != NULL && sptr != NULL);
            serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
            if (vstr == NULL)
                addReplyBulkLongLong(c,vlong);
            else
                addReplyBulkCBuffer(c,vstr,vlen);

            if (withscores)
                addReplyDouble(c,zzlGetScore(sptr));

            if (reverse)
                zzlPrev(zl,&eptr,&sptr);
            else
                zzlNext(zl,&eptr,&sptr);
        }

    } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
        zset *zs = zobj->ptr;
        zskiplist *zsl = zs->zsl;
        zskiplistNode *ln;
        robj *ele;

        /* Check if starting point is trivial, before doing log(N) lookup. */
        if (reverse) {
            ln = zsl->tail;
            if (start > 0)
                ln = zslGetElementByRank(zsl,llen-start);
        } else {
            ln = zsl->header->level[0].forward;
            if (start > 0)
                ln = zslGetElementByRank(zsl,start+1);
        }

        while(rangelen--) {
            serverAssertWithInfo(c,zobj,ln != NULL);
            ele = ln->obj;
            addReplyBulk(c,ele);
            if (withscores)
                addReplyDouble(c,ln->score);
            ln = reverse ? ln->backward : ln->level[0].forward;
        }
    } else {
        serverPanic("Unknown sorted set encoding");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %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)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x10(%rax), %rsi
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
jne 0x644cd
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rsi
leaq -0x38(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
je 0x644d2
jmp 0x64981
movq -0x8(%rbp), %rax
cmpl $0x5, 0x38(%rax)
jne 0x64506
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rdi
leaq 0xd9ac4(%rip), %rsi     # 0x13dfb7
callq 0x26300
cmpl $0x0, %eax
jne 0x64506
movl $0x1, -0x24(%rbp)
jmp 0x6452e
movq -0x8(%rbp), %rax
cmpl $0x5, 0x38(%rax)
jl 0x6452c
movq -0x8(%rbp), %rdi
leaq 0x114725(%rip), %rax    # 0x178c40
movq 0x80(%rax), %rsi
callq 0x42cc0
jmp 0x64981
jmp 0x6452e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x114703(%rip), %rax    # 0x178c40
movq 0x68(%rax), %rdx
callq 0x4a730
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x64567
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x3, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x6456c
jmp 0x64981
movq -0x20(%rbp), %rdi
callq 0x61060
movl %eax, -0x3c(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x6458b
movslq -0x3c(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0x6459e
movslq -0x3c(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x645ad
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jg 0x645c4
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpq %rcx, %rax
jl 0x645dd
movq -0x8(%rbp), %rdi
leaq 0x114671(%rip), %rax    # 0x178c40
movq 0x68(%rax), %rsi
callq 0x42cc0
jmp 0x64981
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpq %rcx, %rax
jl 0x645f6
movl -0x3c(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
subq -0x30(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x64623
movl -0x40(%rbp), %eax
shll %eax
movl %eax, -0x9c(%rbp)
jmp 0x6462c
movl -0x40(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rdi
movl -0x9c(%rbp), %eax
movslq %eax, %rsi
callq 0x437f0
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x647fd
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x6468a
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rcx
shlq %rcx
movq $-0x2, %rax
subq %rcx, %rax
movl %eax, %esi
callq 0x41120
movq %rax, -0x50(%rbp)
jmp 0x646a0
movq -0x48(%rbp), %rdi
movq -0x30(%rbp), %rax
shlq %rax
movl %eax, %esi
callq 0x41120
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x646a9
jmp 0x646d4
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd95f3(%rip), %rdx     # 0x13dcab
leaq 0xd9563(%rip), %rcx     # 0x13dc22
movl $0x8ba, %r8d            # imm = 0x8BA
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x412e0
movq %rax, -0x58(%rbp)
movl -0x40(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x40(%rbp)
cmpl $0x0, %eax
je 0x647f8
cmpq $0x0, -0x50(%rbp)
je 0x64709
cmpq $0x0, -0x58(%rbp)
je 0x64709
jmp 0x64734
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd98aa(%rip), %rdx     # 0x13dfc2
leaq 0xd9503(%rip), %rcx     # 0x13dc22
movl $0x8be, %r8d            # imm = 0x8BE
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x50(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x64(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0x41470
cmpl $0x0, %eax
je 0x64750
jmp 0x6477b
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd94fa(%rip), %rdx     # 0x13dc59
leaq 0xd94bc(%rip), %rcx     # 0x13dc22
movl $0x8bf, %r8d            # imm = 0x8BF
callq 0x78360
movl $0x1, %edi
callq 0x263c0
cmpq $0x0, -0x60(%rbp)
jne 0x64791
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x439f0
jmp 0x647a3
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x64(%rbp), %eax
movl %eax, %edx
callq 0x43920
cmpl $0x0, -0x24(%rbp)
je 0x647c9
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x58(%rbp), %rdi
callq 0x5fe60
movq -0xa8(%rbp), %rdi
callq 0x43480
cmpl $0x0, -0xc(%rbp)
je 0x647e2
movq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x601b0
jmp 0x647f3
movq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x600e0
jmp 0x646e5
jmp 0x64981
movq -0x20(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x6495d
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x64860
movq -0x80(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x30(%rbp)
jle 0x6485e
movq -0x80(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
subq -0x30(%rbp), %rsi
callq 0x5f710
movq %rax, -0x88(%rbp)
jmp 0x64893
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x30(%rbp)
jle 0x64891
movq -0x80(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x1, %rsi
callq 0x5f710
movq %rax, -0x88(%rbp)
jmp 0x64893
jmp 0x64895
movl -0x40(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x40(%rbp)
cmpl $0x0, %eax
je 0x6495b
cmpq $0x0, -0x88(%rbp)
je 0x648b5
jmp 0x648e0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
leaq 0xd6220(%rip), %rdx     # 0x13aae4
leaq 0xd9357(%rip), %rcx     # 0x13dc22
movl $0x8e0, %r8d            # imm = 0x8E0
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x88(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x43630
cmpl $0x0, -0x24(%rbp)
je 0x6491c
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0x43480
cmpl $0x0, -0xc(%rbp)
je 0x64936
movq -0x88(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x64948
movq -0x88(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x64895
jmp 0x6497f
leaq 0xd6d86(%rip), %rdi     # 0x13b6ea
leaq 0xd92b7(%rip), %rsi     # 0x13dc22
movl $0x8e8, %edx            # imm = 0x8E8
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x64981
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)