// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/bitops.c
// Function: bitcountCommand
void bitcountCommand(client *c) {
    robj *o;
    long start, end, strlen;
    unsigned char *p;
    char llbuf[LONG_STR_SIZE];

    /* Lookup, check for type, and return 0 for non existing keys. */
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,OBJ_STRING)) return;
    p = getObjectReadOnlyString(o,&strlen,llbuf);

    /* Parse start/end range if any. */
    if (c->argc == 4) {
        if (getLongFromObjectOrReply(c,c->argv[2],&start,NULL) != C_OK)
            return;
        if (getLongFromObjectOrReply(c,c->argv[3],&end,NULL) != C_OK)
            return;
        /* Convert negative indexes */
        if (start < 0 && end < 0 && start > end) {
            addReply(c,shared.czero);
            return;
        }
        if (start < 0) start = strlen+start;
        if (end < 0) end = strlen+end;
        if (start < 0) start = 0;
        if (end < 0) end = 0;
        if (end >= strlen) end = strlen-1;
    } else if (c->argc == 2) {
        /* The whole string. */
        start = 0;
        end = strlen-1;
    } else {
        /* Syntax error. */
        addReply(c,shared.syntaxerr);
        return;
    }

    /* Precondition: end >= 0 && end < strlen, so the only condition where
     * zero can be returned is: start > end. */
    if (start > end) {
        addReply(c,shared.czero);
    } else {
        long bytes = end-start+1;

        addReplyLongLong(c,redisPopcount(p+start,bytes));
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
movq 0x40(%rdi), %rax
movq 0x8(%rax), %rsi
leaq 0x8ed1b(%rip), %r15     # 0x1072b0
movq 0x20(%r15), %rdx
callq 0x44f89
testq %rax, %rax
je 0x786e3
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x441ab
testl %eax, %eax
jne 0x786e3
leaq 0x18(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x77ac6
movq %rax, %r14
movl 0x38(%rbx), %eax
cmpl $0x2, %eax
je 0x7868e
cmpl $0x4, %eax
jne 0x786b9
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x44ba1
testl %eax, %eax
jne 0x786e3
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x44ba1
testl %eax, %eax
jne 0x786e3
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rax
testq %rcx, %rcx
jns 0x78640
testq %rax, %rax
jns 0x78640
cmpq %rax, %rcx
jg 0x786b3
testq %rcx, %rcx
jns 0x7864f
addq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rsp)
testq %rax, %rax
jns 0x7865e
addq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x10(%rsp)
jns 0x7866f
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x8(%rsp)
jns 0x78680
movq $0x0, 0x8(%rsp)
movq 0x18(%rsp), %rax
cmpq %rax, 0x8(%rsp)
jge 0x7869c
jmp 0x786a4
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rax
decq %rax
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rsi
subq %rax, %rsi
jge 0x786ca
movq 0x20(%r15), %rsi
jmp 0x786c0
movq 0x80(%r15), %rsi
movq %rbx, %rdi
callq 0x3fc19
jmp 0x786e3
incq %rsi
addq %rax, %r14
movq %r14, %rdi
callq 0x772ec
movq %rbx, %rdi
movq %rax, %rsi
callq 0x40606
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq