// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: genericZrangebylexCommand
void genericZrangebylexCommand(client *c, int reverse) {
    zlexrangespec range;
    robj *key = c->argv[1];
    robj *zobj;
    long offset = 0, limit = -1;
    unsigned long rangelen = 0;
    void *replylen = NULL;
    int minidx, maxidx;

    /* Parse the range arguments. */
    if (reverse) {
        /* Range is given as [max,min] */
        maxidx = 2; minidx = 3;
    } else {
        /* Range is given as [min,max] */
        minidx = 2; maxidx = 3;
    }

    if (zslParseLexRange(c->argv[minidx],c->argv[maxidx],&range) != C_OK) {
        addReplyError(c,"min or max not valid string range item");
        return;
    }

    /* Parse optional extra arguments. Note that ZCOUNT will exactly have
     * 4 arguments, so we'll never enter the following code path. */
    if (c->argc > 4) {
        int remaining = c->argc - 4;
        int pos = 4;

        while (remaining) {
            if (remaining >= 3 && !strcasecmp(c->argv[pos]->ptr,"limit")) {
                if ((getLongFromObjectOrReply(c, c->argv[pos+1], &offset, NULL) != C_OK) ||
                    (getLongFromObjectOrReply(c, c->argv[pos+2], &limit, NULL) != C_OK)) return;
                pos += 3; remaining -= 3;
            } else {
                zslFreeLexRange(&range);
                addReply(c,shared.syntaxerr);
                return;
            }
        }
    }

    /* Ok, lookup the key and get the range */
    if ((zobj = lookupKeyReadOrReply(c,key,shared.emptymultibulk)) == NULL ||
        checkType(c,zobj,OBJ_ZSET))
    {
        zslFreeLexRange(&range);
        return;
    }

    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 reversed, get the last node in range as starting point. */
        if (reverse) {
            eptr = zzlLastInLexRange(zl,&range);
        } else {
            eptr = zzlFirstInLexRange(zl,&range);
        }

        /* No "first" element in the specified interval. */
        if (eptr == NULL) {
            addReply(c, shared.emptymultibulk);
            zslFreeLexRange(&range);
            return;
        }

        /* Get score pointer for the first element. */
        serverAssertWithInfo(c,zobj,eptr != NULL);
        sptr = ziplistNext(zl,eptr);

        /* We don't know in advance how many matching elements there are in the
         * list, so we push this object that will represent the multi-bulk
         * length in the output buffer, and will "fix" it later */
        replylen = addDeferredMultiBulkLength(c);

        /* If there is an offset, just traverse the number of elements without
         * checking the score because that is done in the next loop. */
        while (eptr && offset--) {
            if (reverse) {
                zzlPrev(zl,&eptr,&sptr);
            } else {
                zzlNext(zl,&eptr,&sptr);
            }
        }

        while (eptr && limit--) {
            /* Abort when the node is no longer in range. */
            if (reverse) {
                if (!zzlLexValueGteMin(eptr,&range)) break;
            } else {
                if (!zzlLexValueLteMax(eptr,&range)) break;
            }

            /* We know the element exists, so ziplistGet should always
             * succeed. */
            serverAssertWithInfo(c,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));

            rangelen++;
            if (vstr == NULL) {
                addReplyBulkLongLong(c,vlong);
            } else {
                addReplyBulkCBuffer(c,vstr,vlen);
            }

            /* Move to next node */
            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;

        /* If reversed, get the last node in range as starting point. */
        if (reverse) {
            ln = zslLastInLexRange(zsl,&range);
        } else {
            ln = zslFirstInLexRange(zsl,&range);
        }

        /* No "first" element in the specified interval. */
        if (ln == NULL) {
            addReply(c, shared.emptymultibulk);
            zslFreeLexRange(&range);
            return;
        }

        /* We don't know in advance how many matching elements there are in the
         * list, so we push this object that will represent the multi-bulk
         * length in the output buffer, and will "fix" it later */
        replylen = addDeferredMultiBulkLength(c);

        /* If there is an offset, just traverse the number of elements without
         * checking the score because that is done in the next loop. */
        while (ln && offset--) {
            if (reverse) {
                ln = ln->backward;
            } else {
                ln = ln->level[0].forward;
            }
        }

        while (ln && limit--) {
            /* Abort when the node is no longer in range. */
            if (reverse) {
                if (!zslLexValueGteMin(ln->obj,&range)) break;
            } else {
                if (!zslLexValueLteMax(ln->obj,&range)) break;
            }

            rangelen++;
            addReplyBulk(c,ln->obj);

            /* Move to next node */
            if (reverse) {
                ln = ln->backward;
            } else {
                ln = ln->level[0].forward;
            }
        }
    } else {
        serverPanic("Unknown sorted set encoding");
    }

    zslFreeLexRange(&range);
    setDeferredMultiBulkLength(c, replylen, rangelen);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq $-0x1, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x656c8
movl $0x2, -0x60(%rbp)
movl $0x3, -0x5c(%rbp)
jmp 0x656d6
movl $0x2, -0x5c(%rbp)
movl $0x3, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x28(%rbp), %rdx
callq 0x62950
cmpl $0x0, %eax
je 0x65719
movq -0x8(%rbp), %rdi
leaq 0xd8787(%rip), %rsi     # 0x13de96
callq 0x42f90
jmp 0x65cd1
movq -0x8(%rbp), %rax
cmpl $0x4, 0x38(%rax)
jle 0x6580f
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
subl $0x4, %eax
movl %eax, -0x64(%rbp)
movl $0x4, -0x68(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x6580d
cmpl $0x3, -0x64(%rbp)
jl 0x657e3
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
leaq 0xd8d91(%rip), %rsi     # 0x13e4fb
callq 0x26300
cmpl $0x0, %eax
jne 0x657e3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x68(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
jne 0x657ca
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x68(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x48(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x49f20
cmpl $0x0, %eax
je 0x657cf
jmp 0x65cd1
movl -0x68(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x64(%rbp)
jmp 0x65808
leaq -0x28(%rbp), %rdi
callq 0x5fa40
movq -0x8(%rbp), %rdi
leaq 0x113449(%rip), %rax    # 0x178c40
movq 0x80(%rax), %rsi
callq 0x42cc0
jmp 0x65cd1
jmp 0x6573b
jmp 0x6580f
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0x113422(%rip), %rax    # 0x178c40
movq 0x68(%rax), %rdx
callq 0x4a730
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x65848
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x3, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0x65856
leaq -0x28(%rbp), %rdi
callq 0x5fa40
jmp 0x65cd1
movq -0x38(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x65ab7
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x65890
movq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x60870
movq %rax, -0x78(%rbp)
jmp 0x658a1
movq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x60780
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x658ca
movq -0x8(%rbp), %rdi
leaq 0x11338d(%rip), %rax    # 0x178c40
movq 0x68(%rax), %rsi
callq 0x42cc0
leaq -0x28(%rbp), %rdi
callq 0x5fa40
jmp 0x65cd1
cmpq $0x0, -0x78(%rbp)
je 0x658d3
jmp 0x658fe
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0xd83c9(%rip), %rdx     # 0x13dcab
leaq 0xd8339(%rip), %rcx     # 0x13dc22
movl $0xa9c, %r8d            # imm = 0xA9C
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x412e0
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
callq 0x432a0
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x78(%rbp)
movb %al, -0xb1(%rbp)
je 0x65947
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x40(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x65953
jmp 0x6597f
cmpl $0x0, -0xc(%rbp)
je 0x6596c
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x601b0
jmp 0x6597d
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x600e0
jmp 0x6591c
jmp 0x65981
xorl %eax, %eax
cmpq $0x0, -0x78(%rbp)
movb %al, -0xb2(%rbp)
je 0x659ac
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0xb2(%rbp)
movb -0xb2(%rbp), %al
testb $0x1, %al
jne 0x659bb
jmp 0x65ab2
cmpl $0x0, -0xc(%rbp)
je 0x659da
movq -0x78(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x60700
cmpl $0x0, %eax
jne 0x659d8
jmp 0x65ab2
jmp 0x659f3
movq -0x78(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x60740
cmpl $0x0, %eax
jne 0x659f1
jmp 0x65ab2
jmp 0x659f3
movq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x8c(%rbp), %rdx
leaq -0x98(%rbp), %rcx
callq 0x41470
cmpl $0x0, %eax
je 0x65a18
jmp 0x65a43
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0xd8232(%rip), %rdx     # 0x13dc59
leaq 0xd81f4(%rip), %rcx     # 0x13dc22
movl $0xab8, %r8d            # imm = 0xAB8
callq 0x78360
movl $0x1, %edi
callq 0x263c0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x65a6b
movq -0x8(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x439f0
jmp 0x65a83
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movl -0x8c(%rbp), %eax
movl %eax, %edx
callq 0x43920
cmpl $0x0, -0xc(%rbp)
je 0x65a9c
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x601b0
jmp 0x65aad
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x600e0
jmp 0x65981
jmp 0x65cb7
movq -0x38(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x65c93
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa8(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x65b0c
movq -0xa8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5fd30
movq %rax, -0xb0(%rbp)
jmp 0x65b23
movq -0xa8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5fbf0
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x65b4f
movq -0x8(%rbp), %rdi
leaq 0x113108(%rip), %rax    # 0x178c40
movq 0x68(%rax), %rsi
callq 0x42cc0
leaq -0x28(%rbp), %rdi
callq 0x5fa40
jmp 0x65cd1
movq -0x8(%rbp), %rdi
callq 0x432a0
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb3(%rbp)
je 0x65b8a
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x40(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0xb3(%rbp)
movb -0xb3(%rbp), %al
testb $0x1, %al
jne 0x65b96
jmp 0x65bc4
cmpl $0x0, -0xc(%rbp)
je 0x65bb0
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x65bc2
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x65b5c
jmp 0x65bc6
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb4(%rbp)
je 0x65bf4
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x48(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0xb4(%rbp)
movb -0xb4(%rbp), %al
testb $0x1, %al
jne 0x65c03
jmp 0x65c91
cmpl $0x0, -0xc(%rbp)
je 0x65c25
movq -0xb0(%rbp), %rax
movq (%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5f280
cmpl $0x0, %eax
jne 0x65c23
jmp 0x65c91
jmp 0x65c41
movq -0xb0(%rbp), %rax
movq (%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5f2f0
cmpl $0x0, %eax
jne 0x65c3f
jmp 0x65c91
jmp 0x65c41
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq (%rax), %rsi
callq 0x43630
cmpl $0x0, -0xc(%rbp)
je 0x65c7a
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x65c8c
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x65bc6
jmp 0x65cb5
leaq 0xd5a50(%rip), %rdi     # 0x13b6ea
leaq 0xd7f81(%rip), %rsi     # 0x13dc22
movl $0xafd, %edx            # imm = 0xAFD
callq 0x76d80
movl $0x1, %edi
callq 0x263c0
jmp 0x65cb7
leaq -0x28(%rbp), %rdi
callq 0x5fa40
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x43310
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)