// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/geo.c
// Function: geohashCommand
void geohashCommand(client *c) {
    char *geoalphabet= "0123456789bcdefghjkmnpqrstuvwxyz";
    int j;

    /* Look up the requested zset */
    robj *zobj = NULL;
    if ((zobj = lookupKeyReadOrReply(c, c->argv[1], shared.emptymultibulk))
        == NULL || checkType(c, zobj, OBJ_ZSET)) return;

    /* Geohash elements one after the other, using a null bulk reply for
     * missing elements. */
    addReplyMultiBulkLen(c,c->argc-2);
    for (j = 2; j < c->argc; j++) {
        double score;
        if (zsetScore(zobj, c->argv[j], &score) == C_ERR) {
            addReply(c,shared.nullbulk);
        } else {
            /* The internal format we use for geocoding is a bit different
             * than the standard, since we use as initial latitude range
             * -85,85, while the normal geohashing algorithm uses -90,90.
             * So we have to decode our position and re-encode using the
             * standard ranges in order to output a valid geohash string. */

            /* Decode... */
            double xy[2];
            if (!decodeGeohash(score,xy)) {
                addReply(c,shared.nullbulk);
                continue;
            }

            /* Re-encode */
            GeoHashRange r[2];
            GeoHashBits hash;
            r[0].min = -180;
            r[0].max = 180;
            r[1].min = -90;
            r[1].max = 90;
            geohashEncode(&r[0],&r[1],xy[0],xy[1],26,&hash);

            char buf[12];
            int i;
            for (i = 0; i < 11; i++) {
                int idx = (hash.bits >> (52-((i+1)*5))) & 0x1f;
                buf[i] = geoalphabet[idx];
            }
            buf[11] = '\0';
            addReplyBulkCBuffer(c,buf,11);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
leaq 0xa3eed(%rip), %rax     # 0x149613
movq %rax, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
leaq 0xd34f7(%rip), %rax     # 0x178c40
movq 0x68(%rax), %rdx
callq 0x4a730
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xa5773
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x3, %edx
callq 0x490a0
cmpl $0x0, %eax
je 0xa5778
jmp 0xa58db
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x38(%rax), %eax
subl $0x2, %eax
movslq %eax, %rsi
callq 0x437f0
movl $0x2, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jge 0xa58db
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x28(%rbp), %rdx
callq 0x61520
cmpl $-0x1, %eax
jne 0xa57e0
movq -0x8(%rbp), %rdi
leaq 0xd346e(%rip), %rax     # 0x178c40
movq 0x50(%rax), %rsi
callq 0x42cc0
jmp 0xa58cb
movsd -0x28(%rbp), %xmm0
leaq -0x40(%rbp), %rdi
callq 0xa3920
cmpl $0x0, %eax
jne 0xa580c
movq -0x8(%rbp), %rdi
leaq 0xd3442(%rip), %rax     # 0x178c40
movq 0x50(%rax), %rsi
callq 0x42cc0
jmp 0xa58cd
movsd 0xa3b04(%rip), %xmm0    # 0x149318
movsd %xmm0, -0x60(%rbp)
movsd 0xa3aff(%rip), %xmm0    # 0x149320
movsd %xmm0, -0x58(%rbp)
movsd 0xa3b2a(%rip), %xmm0    # 0x149358
movsd %xmm0, -0x50(%rbp)
movsd 0xa3b15(%rip), %xmm0    # 0x149350
movsd %xmm0, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x60(%rbp), %rsi
addq $0x10, %rsi
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movl $0x1a, %edx
leaq -0x70(%rbp), %rcx
callq 0xd35c0
movl $0x0, -0x80(%rbp)
cmpl $0xb, -0x80(%rbp)
jge 0xa58b5
movq -0x70(%rbp), %rax
movl -0x80(%rbp), %ecx
addl $0x1, %ecx
imull $0x5, %ecx, %edx
movl $0x34, %ecx
subl %edx, %ecx
movl %ecx, %ecx
shrq %cl, %rax
andq $0x1f, %rax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movslq -0x84(%rbp), %rcx
movb (%rax,%rcx), %cl
movslq -0x80(%rbp), %rax
movb %cl, -0x7c(%rbp,%rax)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0xa586b
movb $0x0, -0x71(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x7c(%rbp), %rsi
movl $0xb, %edx
callq 0x43920
jmp 0xa58cd
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xa5795
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)