// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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, 0x30(%rsp)
movsd %xmm3, 0x28(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm0, 0x50(%rsp)
movsd %xmm1, 0x58(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x60(%rsp)
movq 0x10(%rsi), %r12
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x7, %eax
je 0x84860
cmpl $0x5, %eax
jne 0x84914
movq 0x8(%rdi), %r14
xorl %r15d, %r15d
movq %r15, 0x40(%rsp)
movl $0x0, 0x4(%rsp)
movq %r15, 0x38(%rsp)
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x547a3
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x8491b
movq %r12, 0x10(%rsp)
movq %r14, %rdi
movq %rax, %rsi
callq 0x3ead6
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x84856
leaq 0x50(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x48(%rsp), %r13
movq 0x48(%rsp), %rdi
callq 0x54417
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
callq 0x539fd
testl %eax, %eax
je 0x84856
movq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x4(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq 0x3eb60
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x847ff
movl 0x4(%rsp), %esi
callq 0x3910c
jmp 0x84809
movq 0x38(%rsp), %rdi
callq 0x39da4
movq %rax, %rbp
movq %rbx, %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movq %rax, %rsi
callq 0x84624
cmpl $-0x1, %eax
jne 0x8483c
movq %rbp, %rdi
callq 0x392b6
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x545d7
cmpq $0x0, 0x8(%rsp)
jne 0x847b1
movq 0x10(%rsp), %r12
jmp 0x84914
movq 0x8(%rdi), %rax
movq 0x8(%rax), %rdi
leaq 0x50(%rsp), %rsi
callq 0x53a8a
xorl %r15d, %r15d
testq %rax, %rax
je 0x8491b
movq %r12, 0x10(%rsp)
leaq 0x50(%rsp), %r12
movq %rax, 0x18(%rsp)
movq %rax, %r14
testq %r14, %r14
je 0x84907
movq (%r14), %r13
movsd 0x8(%r14), %xmm0
movq %r12, %rdi
callq 0x539fd
movl %eax, %ebp
testl %eax, %eax
je 0x84903
movl (%r13), %eax
movl $0xf0, %ecx
andl %ecx, %eax
movq 0x8(%r13), %rdi
cmpl $0x10, %eax
jne 0x848c7
callq 0x39da4
jmp 0x848cc
callq 0x39266
movq %rax, %r13
movsd 0x8(%r14), %xmm3
movq %rbx, %rdi
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd 0x30(%rsp), %xmm2
movq %rax, %rsi
callq 0x84624
cmpl $-0x1, %eax
jne 0x848ff
movq %r13, %rdi
callq 0x392b6
movq 0x18(%r14), %r14
testl %ebp, %ebp
jne 0x84890
cmpq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %r12
je 0x8491b
movl 0x10(%rbx), %r15d
subl %r12d, %r15d
movl %r15d, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq