// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 $0x38, %rsp
movq %rdi, %rbx
movl 0x38(%rdi), %r15d
imull $0xaaaaaaab, %r15d, %eax # imm = 0xAAAAAAAB
addl $0xd5555554, %eax       # imm = 0xD5555554
cmpl $0x55555555, %eax       # imm = 0x55555555
jb 0x84b70
leaq 0x4da17(%rip), %rsi     # 0xd2571
movq %rbx, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3ffcb
leal -0x2(%r15), %eax
cltq
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x20, %rcx
addl %eax, %ecx
leal (%rcx,%rcx), %eax
movq %rcx, 0x8(%rsp)
leal 0x2(,%rcx,2), %ecx
movl %ecx, 0x4(%rsp)
cltq
leaq 0x10(,%rax,8), %rdi
callq 0x3b2ef
movq %rax, %r14
leaq 0x3aa8a(%rip), %rdi     # 0xbf640
movl $0x4, %esi
callq 0x43aef
movq %rax, (%r14)
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rdi
movq %rdi, 0x8(%r14)
callq 0x43c0c
cmpl $0x5, %r15d
jl 0x84cab
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r12d
cmovgel %eax, %r12d
xorl %r15d, %r15d
movq 0x40(%rbx), %rax
leal (%r15,%r15,2), %ecx
movslq %ecx, %rbp
leaq (%rax,%rbp,8), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
leaq 0x10(%rsp), %rdx
callq 0x843a2
movl %eax, %r13d
cmpl $-0x1, %eax
je 0x84c76
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movl $0x1a, %edi
leaq 0x28(%rsp), %rsi
callq 0xa0dbd
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0xa19a5
movq %rax, %rdi
callq 0x39da4
xorl %edi, %edi
movq %rax, %rsi
callq 0x43ab4
movq 0x40(%rbx), %rcx
movq 0x20(%rcx,%rbp,8), %rdi
leal (%r15,%r15), %ecx
movslq %ecx, %rcx
movq %rax, 0x10(%r14,%rcx,8)
movq %rdi, 0x18(%r14,%rcx,8)
callq 0x43c0c
jmp 0x84c97
xorl %r15d, %r15d
movq (%r14,%r15,8), %rdi
testq %rdi, %rdi
je 0x84c87
callq 0x440f3
incq %r15
cmpq %r15, %r12
jne 0x84c79
movq %r14, %rdi
callq 0x3b3df
cmpl $-0x1, %r13d
je 0x84cc2
incl %r15d
cmpl 0x8(%rsp), %r15d
jl 0x84bf2
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movq %r14, %rdx
callq 0x42bcb
movq %rbx, %rdi
callq 0x55d71
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq