// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/geo.c
// Function: geoGetPointsInRange
int geoGetPointsInRange(robj *zobj, double min, double max, double lon, double lat, double radius, geoArray *ga) {
    /* minex 0 = include min in range; maxex 1 = exclude max in range */
    /* That's: min <= val < max */
    zrangespec range = { .min = min, .max = max, .minex = 0, .maxex = 1 };
    size_t origincount = ga->used;
    sds member;

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

        if ((eptr = zzlFirstInRange(zl, &range)) == NULL) {
            /* Nothing exists starting at our min.  No results. */
            return 0;
        }

        sptr = ziplistNext(zl, eptr);
        while (eptr) {
            score = zzlGetScore(sptr);

            /* If we fell out of range, break. */
            if (!zslValueLteMax(score, &range))
                break;

            /* We know the element exists. ziplistGet should always succeed */
            ziplistGet(eptr, &vstr, &vlen, &vlong);
            member = (vstr == NULL) ? sdsfromlonglong(vlong) :
                                      sdsnewlen(vstr,vlen);
            if (geoAppendIfWithinRadius(ga,lon,lat,radius,score,member)
                == C_ERR) sdsfree(member);
            zzlNext(zl, &eptr, &sptr);
        }
    } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
        zset *zs = zobj->ptr;
        zskiplist *zsl = zs->zsl;
        zskiplistNode *ln;

        if ((ln = zslFirstInRange(zsl, &range)) == NULL) {
            /* Nothing exists starting at our min.  No results. */
            return 0;
        }

        while (ln) {
            robj *o = ln->obj;
            /* Abort when the node is no longer in range. */
            if (!zslValueLteMax(ln->score, &range))
                break;

            member = (o->encoding == OBJ_ENCODING_INT) ?
                        sdsfromlonglong((long)o->ptr) :
                        sdsdup(o->ptr);
            if (geoAppendIfWithinRadius(ga,lon,lat,radius,ln->score,member)
                == C_ERR) sdsfree(member);
            ln = ln->level[0].forward;
        }
    }
    return ga->used - origincount;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movsd %xmm4, 0x20(%rsp)
movsd %xmm3, 0x18(%rsp)
movsd %xmm2, 0x10(%rsp)
movsd %xmm0, 0x38(%rsp)
movsd %xmm1, 0x40(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x48(%rsp)
movq 0x10(%rsi), %r13
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x80d88
cmpl $0x5, %eax
jne 0x80e1d
movq 0x8(%rdi), %r14
xorl %r15d, %r15d
movq %r15, 0x30(%rsp)
movl $0x0, 0x4(%rsp)
movq %r15, 0x28(%rsp)
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x5110d
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x80e24
movq %r13, 0x50(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x3b745
leaq 0x60(%rsp), %r15
movq %rax, (%r15)
leaq 0x38(%rsp), %r12
leaq 0x8(%rsp), %rbp
movq 0x60(%rsp), %rdi
callq 0x50d7b
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
callq 0x502d7
testl %eax, %eax
je 0x80d7e
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x3b7cf
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x80d27
movl 0x4(%rsp), %esi
callq 0x36178
jmp 0x80d31
movq 0x28(%rsp), %rdi
callq 0x36e1a
movq %rax, %r13
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x58(%rsp), %xmm3
movq %rax, %rsi
callq 0x80b5a
cmpl $-0x1, %eax
jne 0x80d64
movq %r13, %rdi
callq 0x36330
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x50f41
cmpq $0x0, 0x8(%rsp)
jne 0x80cd9
movq 0x50(%rsp), %r13
jmp 0x80e1d
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rdi
leaq 0x38(%rsp), %rsi
callq 0x50364
testq %rax, %rax
je 0x80e36
movq %rax, %r14
leaq 0x38(%rsp), %r15
movl $0xf0, %ebp
movq (%r14), %r12
movsd 0x8(%r14), %xmm0
movq %r15, %rdi
callq 0x502d7
testl %eax, %eax
je 0x80e1d
movl (%r12), %eax
andl %ebp, %eax
movq 0x8(%r12), %rdi
cmpl $0x10, %eax
jne 0x80ddc
callq 0x36e1a
jmp 0x80de1
callq 0x362e0
movq %rax, %r12
movsd 0x8(%r14), %xmm3
movq %rbx, %rdi
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movq %rax, %rsi
callq 0x80b5a
cmpl $-0x1, %eax
jne 0x80e14
movq %r12, %rdi
callq 0x36330
movq 0x18(%r14), %r14
testq %r14, %r14
jne 0x80db0
movl 0x10(%rbx), %r15d
subl %r13d, %r15d
movl %r15d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
jmp 0x80e24