// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/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 0x917c6(%rip), %r15     # 0xfa310
movq 0x20(%r15), %rdx
callq 0x3aee5
testq %rax, %rax
je 0x68c8e
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x3a311
testl %eax, %eax
jne 0x68c8e
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x68235
movq %rax, %r14
movl 0x38(%rbx), %eax
cmpl $0x2, %eax
je 0x68c44
cmpl $0x4, %eax
jne 0x68c64
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
jne 0x68c8e
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x3ab5e
testl %eax, %eax
jne 0x68c8e
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rsi
testq %rax, %rax
jns 0x68bf5
testq %rsi, %rsi
jns 0x68bf5
cmpq %rsi, %rax
jg 0x68c5e
testq %rax, %rax
jns 0x68c04
addq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
testq %rsi, %rsi
jns 0x68c13
addq 0x10(%rsp), %rsi
movq %rsi, 0x8(%rsp)
testq %rax, %rax
jns 0x68c20
andq $0x0, 0x18(%rsp)
xorl %eax, %eax
testq %rsi, %rsi
jns 0x68c2d
andq $0x0, 0x8(%rsp)
xorl %esi, %esi
movq 0x10(%rsp), %rcx
cmpq %rcx, %rsi
jl 0x68c59
decq %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, %rsi
jmp 0x68c59
andq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rsi
decq %rsi
movq %rsi, 0x8(%rsp)
xorl %eax, %eax
subq %rax, %rsi
jge 0x68c75
movq 0x20(%r15), %rsi
jmp 0x68c6b
movq 0x80(%r15), %rsi
movq %rbx, %rdi
callq 0x36987
jmp 0x68c8e
incq %rsi
addq %rax, %r14
movq %r14, %rdi
callq 0x67b50
movq %rbx, %rdi
movq %rax, %rsi
callq 0x370a6
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq