// File: /workspace/github_c_makefile_star2_O2/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 0x73dbd
cmpl $0x5, %eax
jne 0x73e59
movq %r13, 0x50(%rsp)
movq 0x8(%rdi), %r14
andq $0x0, 0x30(%rsp)
andl $0x0, 0x4(%rsp)
andq $0x0, 0x28(%rsp)
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x488b1
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x73e50
movq %rax, %r13
movq %r14, %rdi
movq %rax, %rsi
callq 0x35b60
leaq 0x60(%rsp), %r15
movq %rax, (%r15)
leaq 0x38(%rsp), %r12
leaq 0x8(%rsp), %rbp
testq %r13, %r13
je 0x73e54
movq 0x60(%rsp), %rdi
callq 0x48535
movsd %xmm0, 0x58(%rsp)
movq %r12, %rdi
callq 0x47cee
testl %eax, %eax
je 0x73e54
movq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x28(%rsp), %rcx
callq 0x35be8
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x73d68
movl 0x4(%rsp), %esi
callq 0x31018
jmp 0x73d72
movq 0x28(%rsp), %rdi
callq 0x31930
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 0x73bba
cmpl $-0x1, %eax
jne 0x73da5
movq %r13, %rdi
callq 0x311c8
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x486f3
movq 0x8(%rsp), %r13
jmp 0x73d11
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rdi
leaq 0x38(%rsp), %rsi
callq 0x47d7b
testq %rax, %rax
je 0x73e50
movq %rax, %r14
leaq 0x38(%rsp), %r15
movl $0xf0, %ebp
testq %r14, %r14
je 0x73e59
movq (%r14), %r12
movsd 0x8(%r14), %xmm0
movq %r15, %rdi
callq 0x47cee
testl %eax, %eax
je 0x73e59
movl (%r12), %eax
andl %ebp, %eax
movq 0x8(%r12), %rdi
cmpl $0x10, %eax
jne 0x73e12
callq 0x31930
jmp 0x73e17
callq 0x3117b
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 0x73bba
cmpl $-0x1, %eax
jne 0x73e4a
movq %r12, %rdi
callq 0x311c8
movq 0x18(%r14), %r14
jmp 0x73de1
xorl %eax, %eax
jmp 0x73e5f
movq 0x50(%rsp), %r13
movl 0x10(%rbx), %eax
subl %r13d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq