// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/geo.c
// Function: geoaddCommand
void geoaddCommand(client *c) {
    /* Check arguments number for sanity. */
    if ((c->argc - 2) % 3 != 0) {
        /* Need an odd number of arguments if we got this far... */
        addReplyError(c, "syntax error. Try GEOADD key [x1] [y1] [name1] "
                         "[x2] [y2] [name2] ... ");
        return;
    }

    int elements = (c->argc - 2) / 3;
    int argc = 2+elements*2; /* ZADD key score ele ... */
    robj **argv = zcalloc(argc*sizeof(robj*));
    argv[0] = createRawStringObject("zadd",4);
    argv[1] = c->argv[1]; /* key */
    incrRefCount(argv[1]);

    /* Create the argument vector to call ZADD in order to add all
     * the score,value pairs to the requested zset, where score is actually
     * an encoded version of lat,long. */
    int i;
    for (i = 0; i < elements; i++) {
        double xy[2];

        if (extractLongLatOrReply(c, (c->argv+2)+(i*3),xy) == C_ERR) {
            for (i = 0; i < argc; i++)
                if (argv[i]) decrRefCount(argv[i]);
            zfree(argv);
            return;
        }

        /* Turn the coordinates into the score of the element. */
        GeoHashBits hash;
        geohashEncodeWGS84(xy[0], xy[1], GEO_STEP_MAX, &hash);
        GeoHashFix52Bits bits = geohashAlign52Bits(hash);
        robj *score = createObject(OBJ_STRING, sdsfromlonglong(bits));
        robj *val = c->argv[2 + i * 3 + 2];
        argv[2+i*2] = score;
        argv[3+i*2] = val;
        incrRefCount(val);
    }

    /* Finally call ZADD that will do the work for us. */
    replaceClientCommandVector(c,argc,argv);
    zaddCommand(c);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movl 0x38(%rdi), %eax
addl $-0x2, %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
testl %edx, %edx
je 0x740a2
leaq 0x4c1c2(%rip), %rsi     # 0xc024e
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x36b6f
movl %eax, %r12d
leal (%r12,%r12), %eax
leal 0x2(,%r12,2), %ebx
cltq
leaq 0x10(,%rax,8), %rdi
callq 0x3280b
movq %rax, %r15
leaq 0x3a4b6(%rip), %rdi     # 0xae580
pushq $0x4
popq %rsi
callq 0x39d91
movq %rax, (%r15)
movq 0x40(%r14), %rax
movq 0x8(%rax), %rdi
movq %rdi, 0x8(%r15)
callq 0x39e74
xorl %ebp, %ebp
testl %r12d, %r12d
cmovlel %ebp, %r12d
shlq $0x4, %r12
pushq $0x10
popq %r13
cmpq %rbp, %r12
je 0x7416d
movq 0x40(%r14), %rsi
addq %r13, %rsi
movq %r14, %rdi
movq %rsp, %rdx
callq 0x73989
cmpl $-0x1, %eax
je 0x74184
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
pushq $0x1a
popq %rdi
leaq 0x18(%rsp), %rsi
callq 0x8def6
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x8e99f
movq %rax, %rdi
callq 0x31930
xorl %edi, %edi
movq %rax, %rsi
callq 0x39d58
movq 0x40(%r14), %rcx
movq 0x10(%rcx,%r13), %rdi
movq %rax, 0x10(%r15,%rbp)
movq %rdi, 0x18(%r15,%rbp)
callq 0x39e74
addq $0x10, %rbp
addq $0x18, %r13
jmp 0x740f7
movq %r14, %rdi
movl %ebx, %esi
movq %r15, %rdx
callq 0x39011
movq %r14, %rdi
callq 0x49b27
jmp 0x741ad
xorl %r14d, %r14d
testl %ebx, %ebx
cmovlel %r14d, %ebx
cmpq %r14, %rbx
je 0x741a5
movq (%r15,%r14,8), %rdi
testq %rdi, %rdi
je 0x741a0
callq 0x3a265
incq %r14
jmp 0x7418d
movq %r15, %rdi
callq 0x328f9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq