// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/t_zset.c
// Function: genericZrangebyscoreCommand
void genericZrangebyscoreCommand(client *c, int reverse) {
    zrangespec range;
    robj *key = c->argv[1];
    robj *zobj;
    long offset = 0, limit = -1;
    int withscores = 0;
    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 (zslParseRange(c->argv[minidx],c->argv[maxidx],&range) != C_OK) {
        addReplyError(c,"min or max is not a float");
        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 >= 1 && !strcasecmp(c->argv[pos]->ptr,"withscores")) {
                pos++; remaining--;
                withscores = 1;
            } else 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 {
                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)) 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;
        double score;

        /* If reversed, get the last node in range as starting point. */
        if (reverse) {
            eptr = zzlLastInRange(zl,&range);
        } else {
            eptr = zzlFirstInRange(zl,&range);
        }

        /* No "first" element in the specified interval. */
        if (eptr == NULL) {
            addReply(c, shared.emptymultibulk);
            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--) {
            score = zzlGetScore(sptr);

            /* Abort when the node is no longer in range. */
            if (reverse) {
                if (!zslValueGteMin(score,&range)) break;
            } else {
                if (!zslValueLteMax(score,&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);
            }

            if (withscores) {
                addReplyDouble(c,score);
            }

            /* 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 = zslLastInRange(zsl,&range);
        } else {
            ln = zslFirstInRange(zsl,&range);
        }

        /* No "first" element in the specified interval. */
        if (ln == NULL) {
            addReply(c, shared.emptymultibulk);
            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 (!zslValueGteMin(ln->score,&range)) break;
            } else {
                if (!zslValueLteMax(ln->score,&range)) break;
            }

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

            if (withscores) {
                addReplyDouble(c,ln->score);
            }

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

    if (withscores) {
        rangelen *= 2;
    }

    setDeferredMultiBulkLength(c, replylen, rangelen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x8(%rax), %r14
andq $0x0, 0x28(%rsp)
orq $-0x1, 0x58(%rsp)
movl %esi, %ebp
xorl %ecx, %ecx
testl %esi, %esi
sete %cl
movq 0x10(%rax,%rcx,8), %rsi
xorl $0x3, %ecx
movq (%rax,%rcx,8), %rdi
leaq 0x30(%rsp), %rdx
callq 0x4a088
testl %eax, %eax
je 0x4b51f
leaq 0x698a6(%rip), %rsi     # 0xb4dac
movq %rbx, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36b6f
movl %ebp, 0x4(%rsp)
movl 0x38(%rbx), %r12d
movq $0x0, 0x10(%rsp)
cmpl $0x5, %r12d
movq %rbx, %r13
jl 0x4b61b
movq %r14, 0x18(%rsp)
addl $-0x4, %r12d
movq $0x0, 0x10(%rsp)
pushq $0x4
popq %r14
testl %r12d, %r12d
je 0x4b616
movq 0x40(%rbx), %rbx
movl %r14d, %r15d
movq (%rbx,%r15,8), %rax
movq 0x8(%rax), %rbp
movq %rbp, %rdi
leaq 0x69972(%rip), %rsi     # 0xb4ee7
callq 0x262f0
pushq $0x1
popq %rcx
movl %ecx, %edx
pushq $-0x1
popq %rsi
testl %eax, %eax
je 0x4b5e6
cmpl $0x3, %r12d
jl 0x4b5fb
movq %rbp, %rdi
leaq 0x69e6d(%rip), %rsi     # 0xb5403
callq 0x262f0
testl %eax, %eax
jne 0x4b5fb
movq 0x8(%rbx,%r15,8), %rsi
movq %r13, %rdi
leaq 0x28(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
jne 0x4b963
movq %r13, %rdi
movq 0x40(%r13), %rax
movq 0x10(%rax,%r15,8), %rsi
leaq 0x58(%rsp), %rdx
xorl %ecx, %ecx
callq 0x3ab5e
pushq $0x3
popq %rdx
pushq $-0x3
popq %rsi
movq 0x10(%rsp), %rcx
testl %eax, %eax
jne 0x4b963
addl %edx, %r14d
addl %esi, %r12d
movl %ecx, %eax
movq %rax, 0x10(%rsp)
movq %r13, %rbx
jmp 0x4b553
leaq 0xaed0e(%rip), %rax     # 0xfa310
movq 0x80(%rax), %rsi
movq %r13, %rdi
callq 0x36987
jmp 0x4b963
movq 0x18(%rsp), %r14
leaq 0xaecee(%rip), %r12     # 0xfa310
movq 0x68(%r12), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3aee5
testq %rax, %rax
je 0x4b963
movq %rax, %r15
pushq $0x3
popq %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3a311
testl %eax, %eax
jne 0x4b963
movl (%r15), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x4b692
cmpl $0x5, %eax
jne 0x4b9ab
movq %r13, %rbx
movq 0x8(%r15), %rbp
movl 0x4(%rsp), %r13d
leaq 0x30(%rsp), %rsi
movq %rbp, %rdi
testl %r13d, %r13d
je 0x4b7b6
callq 0x4897a
jmp 0x4b7bb
movq 0x8(%r15), %rax
movq 0x8(%rax), %rdi
cmpl $0x0, 0x4(%rsp)
je 0x4b6ad
leaq 0x30(%rsp), %rsi
callq 0x47e31
jmp 0x4b6b7
leaq 0x30(%rsp), %rsi
callq 0x47d7b
movq %rax, %r14
testq %rax, %rax
je 0x4b7ac
xorl %ebx, %ebx
cmpl $0x0, 0x4(%rsp)
sete %bl
movq %r13, %rdi
callq 0x36dad
movq %rax, 0x68(%rsp)
movq 0x28(%rsp), %rax
leaq 0x10(,%rbx,8), %r15
decq %rax
testq %r14, %r14
je 0x4b700
movq %rax, 0x28(%rsp)
cmpq $-0x1, %rax
je 0x4b700
movq (%r14,%r15), %r14
jmp 0x4b6e7
movl 0x40(%rsp), %ebp
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x48(%rsp)
xorl %r12d, %r12d
movq %r13, %rbx
movl 0x4(%rsp), %r13d
testq %r14, %r14
je 0x4b948
subq $0x1, 0x58(%rsp)
jb 0x4b948
movsd 0x8(%r14), %xmm0
xorl %eax, %eax
xorl %ecx, %ecx
testl %r13d, %r13d
je 0x4b763
ucomisd 0x18(%rsp), %xmm0
setbe %al
setb %cl
testl %ebp, %ebp
jmp 0x4b778
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setbe %al
setb %cl
cmpl $0x0, 0x48(%rsp)
cmovel %ecx, %eax
testb %al, %al
jne 0x4b948
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x36fd9
cmpl $0x0, 0x10(%rsp)
je 0x4b7a3
movsd 0x8(%r14), %xmm0
movq %rbx, %rdi
callq 0x36eb0
movq (%r14,%r15), %r14
incq %r12
jmp 0x4b72f
movq 0x68(%r12), %rsi
jmp 0x4b609
callq 0x488b1
movq %rax, %r14
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x4b975
movq %rbx, 0x8(%rsp)
movq %rbp, %rbx
movq %rbp, %rdi
movq %r14, %rsi
callq 0x35b60
leaq 0x50(%rsp), %r12
movq %rax, (%r12)
movq 0x8(%rsp), %rdi
callq 0x36dad
movq %rax, 0x68(%rsp)
leaq 0x20(%rsp), %rbp
testq %r14, %r14
je 0x4b82a
subq $0x1, 0x28(%rsp)
jb 0x4b82a
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
testl %r13d, %r13d
je 0x4b81e
callq 0x48778
jmp 0x4b823
callq 0x486f3
movq 0x20(%rsp), %r14
jmp 0x4b7fc
movl 0x40(%rsp), %ebp
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x70(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x60(%rsp)
xorl %r12d, %r12d
testq %r14, %r14
je 0x4b943
subq $0x1, 0x58(%rsp)
jb 0x4b943
movq 0x50(%rsp), %rdi
callq 0x48535
movapd %xmm0, %xmm1
xorl %eax, %eax
xorl %ecx, %ecx
testl %r13d, %r13d
je 0x4b88d
ucomisd 0x48(%rsp), %xmm1
setbe %al
setb %cl
testl %ebp, %ebp
jmp 0x4b8a2
movsd 0x70(%rsp), %xmm0
ucomisd %xmm1, %xmm0
setbe %al
setb %cl
cmpl $0x0, 0x60(%rsp)
cmovel %ecx, %eax
testb %al, %al
jne 0x4b943
movsd %xmm1, 0x18(%rsp)
movq %r14, %rdi
leaq 0x80(%rsp), %rsi
leaq 0x64(%rsp), %rdx
leaq 0x78(%rsp), %rcx
callq 0x35be8
testl %eax, %eax
je 0x4b982
movq 0x80(%rsp), %rsi
testq %rsi, %rsi
je 0x4b8f2
movl 0x64(%rsp), %edx
movq 0x8(%rsp), %rdi
callq 0x3716c
jmp 0x4b901
movq 0x78(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x37206
cmpl $0x0, 0x10(%rsp)
movsd 0x18(%rsp), %xmm0
je 0x4b918
movq 0x8(%rsp), %rdi
callq 0x36eb0
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x50(%rsp), %rdx
testl %r13d, %r13d
je 0x4b931
callq 0x48778
jmp 0x4b936
callq 0x486f3
movq 0x20(%rsp), %r14
incq %r12
jmp 0x4b851
movq 0x8(%rsp), %rbx
cmpl $0x0, 0x10(%rsp)
setne %cl
shlq %cl, %r12
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movq %r12, %rdx
callq 0x36de9
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x68(%r12), %rsi
movq %rbx, %rdi
jmp 0x4b60c
leaq 0x69200(%rip), %rdx     # 0xb4b89
leaq 0x691c2(%rip), %rcx     # 0xb4b52
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl $0x959, %r8d            # imm = 0x959
callq 0x588a4
pushq $0x1
popq %rdi
callq 0x263c0
leaq 0x66bec(%rip), %rdi     # 0xb259e
leaq 0x69199(%rip), %rsi     # 0xb4b52
movl $0x9a5, %edx            # imm = 0x9A5
callq 0x57b45
jmp 0x4b9a3