// File: /workspace/github_c_makefile_star2_O3/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 0x8d8c0(%rip), %r15     # 0x102310
movq 0x20(%r15), %rdx
callq 0x41af9
testq %rax, %rax
je 0x74b9d
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x40d47
testl %eax, %eax
jne 0x74b9d
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r14, %rdi
callq 0x74007
movq %rax, %r14
movl 0x38(%rbx), %eax
cmpl $0x2, %eax
je 0x74b50
cmpl $0x4, %eax
jne 0x74b73
movq 0x40(%rbx), %rax
movq 0x10(%rax), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
jne 0x74b9d
movq 0x40(%rbx), %rax
movq 0x18(%rax), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x41718
testl %eax, %eax
jne 0x74b9d
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rsi
testq %rax, %rax
jns 0x74afb
testq %rsi, %rsi
jns 0x74afb
cmpq %rsi, %rax
jg 0x74b6d
testq %rax, %rax
jns 0x74b0a
addq 0x10(%rsp), %rax
movq %rax, 0x18(%rsp)
testq %rsi, %rsi
jns 0x74b19
addq 0x10(%rsp), %rsi
movq %rsi, 0x8(%rsp)
testq %rax, %rax
jns 0x74b29
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
testq %rsi, %rsi
jns 0x74b39
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
movq 0x10(%rsp), %rcx
cmpq %rcx, %rsi
jl 0x74b68
decq %rcx
movq %rcx, 0x8(%rsp)
movq %rcx, %rsi
jmp 0x74b68
movq $0x0, 0x18(%rsp)
movq 0x10(%rsp), %rsi
decq %rsi
movq %rsi, 0x8(%rsp)
xorl %eax, %eax
subq %rax, %rsi
jge 0x74b84
movq 0x20(%r15), %rsi
jmp 0x74b7a
movq 0x80(%r15), %rsi
movq %rbx, %rdi
callq 0x3c854
jmp 0x74b9d
incq %rsi
addq %rax, %r14
movq %r14, %rdi
callq 0x73870
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3d23f
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq