// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/geohash-int/geohash_helper.c
// Function: geohashGetAreasByRadius
GeoHashRadius geohashGetAreasByRadius(double longitude, double latitude, double radius_meters) {
    GeoHashRange long_range, lat_range;
    GeoHashRadius radius;
    GeoHashBits hash;
    GeoHashNeighbors neighbors;
    GeoHashArea area;
    double min_lon, max_lon, min_lat, max_lat;
    double bounds[4];
    int steps;

    geohashBoundingBox(longitude, latitude, radius_meters, bounds);
    min_lon = bounds[0];
    min_lat = bounds[1];
    max_lon = bounds[2];
    max_lat = bounds[3];

    steps = geohashEstimateStepsByRadius(radius_meters,latitude);

    geohashGetCoordRange(&long_range,&lat_range);
    geohashEncode(&long_range,&lat_range,longitude,latitude,steps,&hash);
    geohashNeighbors(&hash,&neighbors);
    geohashDecode(long_range,lat_range,hash,&area);

    /* Check if the step is enough at the limits of the covered area.
     * Sometimes when the search area is near an edge of the
     * area, the estimated step is not small enough, since one of the
     * north / south / west / east square is too near to the search area
     * to cover everything. */
    int decrease_step = 0;
    {
        GeoHashArea north, south, east, west;

        geohashDecode(long_range, lat_range, neighbors.north, &north);
        geohashDecode(long_range, lat_range, neighbors.south, &south);
        geohashDecode(long_range, lat_range, neighbors.east, &east);
        geohashDecode(long_range, lat_range, neighbors.west, &west);

        if (geohashGetDistance(longitude,latitude,longitude,north.latitude.max)
            < radius_meters) decrease_step = 1;
        if (geohashGetDistance(longitude,latitude,longitude,south.latitude.min)
            < radius_meters) decrease_step = 1;
        if (geohashGetDistance(longitude,latitude,east.longitude.max,latitude)
            < radius_meters) decrease_step = 1;
        if (geohashGetDistance(longitude,latitude,west.longitude.min,latitude)
            < radius_meters) decrease_step = 1;
    }

    if (steps > 1 && decrease_step) {
        steps--;
        geohashEncode(&long_range,&lat_range,longitude,latitude,steps,&hash);
        geohashNeighbors(&hash,&neighbors);
        geohashDecode(long_range,lat_range,hash,&area);
    }

    /* Exclude the search areas that are useless. */
    if (area.latitude.min < min_lat) {
        GZERO(neighbors.south);
        GZERO(neighbors.south_west);
        GZERO(neighbors.south_east);
    }
    if (area.latitude.max > max_lat) {
        GZERO(neighbors.north);
        GZERO(neighbors.north_east);
        GZERO(neighbors.north_west);
    }
    if (area.longitude.min < min_lon) {
        GZERO(neighbors.west);
        GZERO(neighbors.south_west);
        GZERO(neighbors.north_west);
    }
    if (area.longitude.max > max_lon) {
        GZERO(neighbors.east);
        GZERO(neighbors.south_east);
        GZERO(neighbors.north_east);
    }
    radius.hash = hash;
    radius.neighbors = neighbors;
    radius.area = area;
    return radius;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x218(%rbp)
movq %rdi, -0x210(%rbp)
movsd %xmm0, -0x8(%rbp)
movsd %xmm1, -0x10(%rbp)
movsd %xmm2, -0x18(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x18(%rbp), %xmm2
leaq -0x140(%rbp), %rdi
callq 0xd4460
movsd -0x140(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x138(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
movsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x118(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0xd4380
movzbl %al, %eax
movl %eax, -0x144(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xd3570
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movl -0x144(%rbp), %eax
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rcx
movzbl %al, %edx
callq 0xd35c0
leaq -0x48(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xd3fc0
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0x48(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
movzbl -0x40(%rbp), %esi
callq 0xd3a00
movl $0x0, -0x148(%rbp)
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0xc8(%rbp), %rdi
leaq -0x178(%rbp), %rdx
movzbl -0xc0(%rbp), %esi
callq 0xd3a00
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0x98(%rbp), %rdi
leaq -0x1a8(%rbp), %rdx
movzbl -0x90(%rbp), %esi
callq 0xd3a00
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0xb8(%rbp), %rdi
leaq -0x1d8(%rbp), %rdx
movzbl -0xb0(%rbp), %esi
callq 0xd3a00
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0xa8(%rbp), %rdi
leaq -0x208(%rbp), %rdx
movzbl -0xa0(%rbp), %esi
callq 0xd3a00
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x8(%rbp), %xmm2
movsd -0x150(%rbp), %xmm3
callq 0xd4a70
movaps %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd47fa
movl $0x1, -0x148(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x8(%rbp), %xmm2
movsd -0x188(%rbp), %xmm3
callq 0xd4a70
movaps %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd482e
movl $0x1, -0x148(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x1c0(%rbp), %xmm2
movsd -0x10(%rbp), %xmm3
callq 0xd4a70
movaps %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd4862
movl $0x1, -0x148(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x1f8(%rbp), %xmm2
movsd -0x10(%rbp), %xmm3
callq 0xd4a70
movaps %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd4896
movl $0x1, -0x148(%rbp)
cmpl $0x1, -0x144(%rbp)
jle 0xd4913
cmpl $0x0, -0x148(%rbp)
je 0xd4913
movl -0x144(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x144(%rbp)
movsd -0x8(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movl -0x144(%rbp), %eax
leaq -0x28(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x48(%rbp), %rcx
movzbl %al, %edx
callq 0xd35c0
leaq -0x48(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xd3fc0
movsd -0x28(%rbp), %xmm0
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
movsd -0x30(%rbp), %xmm3
movq -0x48(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
movzbl -0x40(%rbp), %esi
callq 0xd3a00
movsd -0xd8(%rbp), %xmm1
movsd -0x110(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd4953
movb $0x0, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movb $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movb $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movsd -0xd0(%rbp), %xmm0
ucomisd -0x118(%rbp), %xmm0
jbe 0xd4992
movb $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movb $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movb $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movsd -0xe8(%rbp), %xmm1
movsd -0x100(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd49d2
movb $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movb $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movb $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movsd -0xe0(%rbp), %xmm0
ucomisd -0x108(%rbp), %xmm0
jbe 0xd4a11
movb $0x0, -0xb0(%rbp)
movq $0x0, -0xb8(%rbp)
movb $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movb $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x218(%rbp), %rdi
movq -0x48(%rbp), %rax
movq %rax, (%rdi)
movq -0x40(%rbp), %rax
movq %rax, 0x8(%rdi)
addq $0x40, %rdi
leaq -0xc8(%rbp), %rsi
movl $0x80, %edx
callq 0x26c60
movq -0x218(%rbp), %rdi
addq $0x10, %rdi
leaq -0xf8(%rbp), %rsi
movl $0x30, %edx
callq 0x26c60
movq -0x210(%rbp), %rax
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
nopl (%rax,%rax)