// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/src/t_zset.c
// Function: genericZrangebylexCommand
void genericZrangebylexCommand(redisClient *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) != REDIS_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) != REDIS_OK) ||
                    (getLongFromObjectOrReply(c, c->argv[pos+2], &limit, NULL) != REDIS_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,REDIS_ZSET))
    {
        zslFreeLexRange(&range);
        return;
    }

    if (zobj->encoding == REDIS_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. */
        redisAssertWithInfo(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. */
            redisAssertWithInfo(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 == REDIS_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 {
        redisPanic("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 0x38(%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 0x542a8
movl $0x2, -0x60(%rbp)
movl $0x3, -0x5c(%rbp)
jmp 0x542b6
movl $0x2, -0x5c(%rbp)
movl $0x3, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x28(%rbp), %rdx
callq 0x51560
cmpl $0x0, %eax
je 0x542f9
movq -0x8(%rbp), %rdi
leaq 0x8f1a5(%rip), %rsi     # 0xe3494
callq 0x35d40
jmp 0x548b1
movq -0x8(%rbp), %rax
cmpl $0x4, 0x30(%rax)
jle 0x543ef
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
subl $0x4, %eax
movl %eax, -0x64(%rbp)
movl $0x4, -0x68(%rbp)
cmpl $0x0, -0x64(%rbp)
je 0x543ed
cmpl $0x3, -0x64(%rbp)
jl 0x543c3
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
leaq 0x8f709(%rip), %rsi     # 0xe3a53
callq 0x1f2f0
cmpl $0x0, %eax
jne 0x543c3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%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 0x3b960
cmpl $0x0, %eax
jne 0x543aa
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x38(%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 0x3b960
cmpl $0x0, %eax
je 0x543af
jmp 0x548b1
movl -0x68(%rbp), %eax
addl $0x3, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x64(%rbp)
jmp 0x543e8
leaq -0x28(%rbp), %rdi
callq 0x4ea60
movq -0x8(%rbp), %rdi
leaq 0xbfd79(%rip), %rax     # 0x114150
movq 0x80(%rax), %rsi
callq 0x35a70
jmp 0x548b1
jmp 0x5431b
jmp 0x543ef
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0xbfd52(%rip), %rax     # 0x114150
movq 0x68(%rax), %rdx
callq 0x3c0c0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x54428
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x3, %edx
callq 0x3abb0
cmpl $0x0, %eax
je 0x54436
leaq -0x28(%rbp), %rdi
callq 0x4ea60
jmp 0x548b1
movq -0x38(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x5, %eax
jne 0x54697
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x54470
movq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4f890
movq %rax, -0x78(%rbp)
jmp 0x54481
movq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4f7a0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jne 0x544aa
movq -0x8(%rbp), %rdi
leaq 0xbfcbd(%rip), %rax     # 0x114150
movq 0x68(%rax), %rsi
callq 0x35a70
leaq -0x28(%rbp), %rdi
callq 0x4ea60
jmp 0x548b1
cmpq $0x0, -0x78(%rbp)
je 0x544b3
jmp 0x544de
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x8ee55(%rip), %rdx     # 0xe3317
leaq 0x8edc5(%rip), %rcx     # 0xe328e
movl $0xde1, %r8d            # imm = 0xDE1
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x33330
movq %rax, -0x80(%rbp)
movq -0x8(%rbp), %rdi
callq 0x36050
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x78(%rbp)
movb %al, -0xb1(%rbp)
je 0x54527
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 0x54533
jmp 0x5455f
cmpl $0x0, -0xc(%rbp)
je 0x5454c
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4f1d0
jmp 0x5455d
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4f100
jmp 0x544fc
jmp 0x54561
xorl %eax, %eax
cmpq $0x0, -0x78(%rbp)
movb %al, -0xb2(%rbp)
je 0x5458c
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 0x5459b
jmp 0x54692
cmpl $0x0, -0xc(%rbp)
je 0x545ba
movq -0x78(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4f720
cmpl $0x0, %eax
jne 0x545b8
jmp 0x54692
jmp 0x545d3
movq -0x78(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4f760
cmpl $0x0, %eax
jne 0x545d1
jmp 0x54692
jmp 0x545d3
movq -0x78(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x8c(%rbp), %rdx
leaq -0x98(%rbp), %rcx
callq 0x33490
cmpl $0x0, %eax
je 0x545f8
jmp 0x54623
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0x8ecbe(%rip), %rdx     # 0xe32c5
leaq 0x8ec80(%rip), %rcx     # 0xe328e
movl $0xdfd, %r8d            # imm = 0xDFD
callq 0x648b0
movl $0x1, %edi
callq 0x1f3b0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x5464b
movq -0x8(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x366c0
jmp 0x54663
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movl -0x8c(%rbp), %eax
movl %eax, %edx
callq 0x36670
cmpl $0x0, -0xc(%rbp)
je 0x5467c
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4f1d0
jmp 0x5468d
movq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4f100
jmp 0x54561
jmp 0x54897
movq -0x38(%rbp), %rax
movl (%rax), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
jne 0x54873
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 0x546ec
movq -0xa8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4ed50
movq %rax, -0xb0(%rbp)
jmp 0x54703
movq -0xa8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4ec10
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x5472f
movq -0x8(%rbp), %rdi
leaq 0xbfa38(%rip), %rax     # 0x114150
movq 0x68(%rax), %rsi
callq 0x35a70
leaq -0x28(%rbp), %rdi
callq 0x4ea60
jmp 0x548b1
movq -0x8(%rbp), %rdi
callq 0x36050
movq %rax, -0x58(%rbp)
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb3(%rbp)
je 0x5476a
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 0x54776
jmp 0x547a4
cmpl $0x0, -0xc(%rbp)
je 0x54790
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x547a2
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x5473c
jmp 0x547a6
xorl %eax, %eax
cmpq $0x0, -0xb0(%rbp)
movb %al, -0xb4(%rbp)
je 0x547d4
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 0x547e3
jmp 0x54871
cmpl $0x0, -0xc(%rbp)
je 0x54805
movq -0xb0(%rbp), %rax
movq (%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4e330
cmpl $0x0, %eax
jne 0x54803
jmp 0x54871
jmp 0x54821
movq -0xb0(%rbp), %rax
movq (%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4e3a0
cmpl $0x0, %eax
jne 0x5481f
jmp 0x54871
jmp 0x54821
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0xb0(%rbp), %rax
movq (%rax), %rsi
callq 0x36620
cmpl $0x0, -0xc(%rbp)
je 0x5485a
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x5486c
movq -0xb0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xb0(%rbp)
jmp 0x547a6
jmp 0x54895
leaq 0x8cc21(%rip), %rdi     # 0xe149b
leaq 0x8ea0d(%rip), %rsi     # 0xe328e
movl $0xe42, %edx            # imm = 0xE42
callq 0x63d40
movl $0x1, %edi
callq 0x1f3b0
jmp 0x54897
leaq -0x28(%rbp), %rdi
callq 0x4ea60
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x360c0
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)