// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/hyperloglog.c
// Function: pfcountCommand
void pfcountCommand(client *c) {
    robj *o;
    struct hllhdr *hdr;
    uint64_t card;

    /* Case 1: multi-key keys, cardinality of the union.
     *
     * When multiple keys are specified, PFCOUNT actually computes
     * the cardinality of the merge of the N HLLs specified. */
    if (c->argc > 2) {
        uint8_t max[HLL_HDR_SIZE+HLL_REGISTERS], *registers;
        int j;

        /* Compute an HLL with M[i] = MAX(M[i]_j). */
        memset(max,0,sizeof(max));
        hdr = (struct hllhdr*) max;
        hdr->encoding = HLL_RAW; /* Special internal-only encoding. */
        registers = max + HLL_HDR_SIZE;
        for (j = 1; j < c->argc; j++) {
            /* Check type and size. */
            robj *o = lookupKeyRead(c->db,c->argv[j]);
            if (o == NULL) continue; /* Assume empty HLL for non existing var.*/
            if (isHLLObjectOrReply(c,o) != C_OK) return;

            /* Merge with this HLL with our 'max' HHL by setting max[i]
             * to MAX(max[i],hll[i]). */
            if (hllMerge(registers,o) == C_ERR) {
                addReplySds(c,sdsnew(invalid_hll_err));
                return;
            }
        }

        /* Compute cardinality of the resulting set. */
        addReplyLongLong(c,hllCount(hdr,NULL));
        return;
    }

    /* Case 2: cardinality of the single HLL.
     *
     * The user specified a single key. Either return the cached value
     * or compute one and update the cache. */
    o = lookupKeyWrite(c->db,c->argv[1]);
    if (o == NULL) {
        /* No key? Cardinality is zero since no element was added, otherwise
         * we would have a key as HLLADD creates it as a side effect. */
        addReply(c,shared.czero);
    } else {
        if (isHLLObjectOrReply(c,o) != C_OK) return;
        o = dbUnshareStringValue(c->db,c->argv[1],o);

        /* Check if the cached cardinality is valid. */
        hdr = o->ptr;
        if (HLL_VALID_CACHE(hdr)) {
            /* Just return the cached value. */
            card = (uint64_t)hdr->card[0];
            card |= (uint64_t)hdr->card[1] << 8;
            card |= (uint64_t)hdr->card[2] << 16;
            card |= (uint64_t)hdr->card[3] << 24;
            card |= (uint64_t)hdr->card[4] << 32;
            card |= (uint64_t)hdr->card[5] << 40;
            card |= (uint64_t)hdr->card[6] << 48;
            card |= (uint64_t)hdr->card[7] << 56;
        } else {
            int invalid = 0;
            /* Recompute it and update the cached value. */
            card = hllCount(hdr,&invalid);
            if (invalid) {
                addReplySds(c,sdsnew(invalid_hll_err));
                return;
            }
            hdr->card[0] = card & 0xff;
            hdr->card[1] = (card >> 8) & 0xff;
            hdr->card[2] = (card >> 16) & 0xff;
            hdr->card[3] = (card >> 24) & 0xff;
            hdr->card[4] = (card >> 32) & 0xff;
            hdr->card[5] = (card >> 40) & 0xff;
            hdr->card[6] = (card >> 48) & 0xff;
            hdr->card[7] = (card >> 56) & 0xff;
            /* This is not considered a read-only command even if the
             * data structure is not modified, since the cached value
             * may be modified and given that the HLL is a Redis string
             * we need to propagate the change. */
            signalModifiedKey(c->db,c->argv[1]);
            server.dirty++;
        }
        addReplyLongLong(c,card);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4070, %rsp           # imm = 0x4070
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x2, 0x38(%rax)
jle 0x9ffa4
leaq -0x4030(%rbp), %rdi
xorl %esi, %esi
movl $0x4010, %edx           # imm = 0x4010
callq 0x26110
leaq -0x4030(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb $-0x1, 0x4(%rax)
leaq -0x4030(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x4038(%rbp)
movl $0x1, -0x403c(%rbp)
movl -0x403c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jge 0x9ff78
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x403c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4a6c0
movq %rax, -0x4048(%rbp)
cmpq $0x0, -0x4048(%rbp)
jne 0x9ff05
jmp 0x9ff64
movq -0x8(%rbp), %rdi
movq -0x4048(%rbp), %rsi
callq 0x9fb30
cmpl $0x0, %eax
je 0x9ff1f
jmp 0xa0224
movq -0x4038(%rbp), %rdi
movq -0x4048(%rbp), %rsi
callq 0x9f790
cmpl $-0x1, %eax
jne 0x9ff62
movq -0x8(%rbp), %rax
movq %rax, -0x4058(%rbp)
movq 0xd77c7(%rip), %rdi     # 0x177710
callq 0x38510
movq -0x4058(%rbp), %rdi
movq %rax, %rsi
callq 0x42e50
jmp 0xa0224
jmp 0x9ff64
movl -0x403c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x403c(%rbp)
jmp 0x9febf
movq -0x8(%rbp), %rax
movq %rax, -0x4060(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9f3c0
movq -0x4060(%rbp), %rdi
movq %rax, %rsi
callq 0x43780
jmp 0xa0224
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4a6f0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9ffe1
movq -0x8(%rbp), %rdi
leaq 0xd8c6d(%rip), %rax     # 0x178c40
movq 0x20(%rax), %rsi
callq 0x42cc0
jmp 0xa0224
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9fb30
cmpl $0x0, %eax
je 0x9fff8
jmp 0xa0224
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rdx
callq 0x4ad00
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xf(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0xa00d8
movq -0x18(%rbp), %rax
movzbl 0x8(%rax), %eax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0x9(%rax), %eax
shlq $0x8, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xa(%rax), %eax
shlq $0x10, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xb(%rax), %eax
shlq $0x18, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xc(%rax), %eax
shlq $0x20, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xd(%rax), %eax
shlq $0x28, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xe(%rax), %eax
shlq $0x30, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzbl 0xf(%rax), %eax
shlq $0x38, %rax
orq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0xa0217
movl $0x0, -0x404c(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x404c(%rbp), %rsi
callq 0x9f3c0
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x404c(%rbp)
je 0xa012a
movq -0x8(%rbp), %rax
movq %rax, -0x4068(%rbp)
movq 0xd75ff(%rip), %rdi     # 0x177710
callq 0x38510
movq -0x4068(%rbp), %rdi
movq %rax, %rsi
callq 0x42e50
jmp 0xa0224
movq -0x20(%rbp), %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x20(%rbp), %rax
shrq $0x8, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x9(%rax)
movq -0x20(%rbp), %rax
shrq $0x10, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xa(%rax)
movq -0x20(%rbp), %rax
shrq $0x18, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xb(%rax)
movq -0x20(%rbp), %rax
shrq $0x20, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x20(%rbp), %rax
shrq $0x28, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xd(%rax)
movq -0x20(%rbp), %rax
shrq $0x30, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xe(%rax)
movq -0x20(%rbp), %rax
shrq $0x38, %rax
andq $0xff, %rax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0xf(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rsi
callq 0x4aa60
leaq 0xd7fda(%rip), %rax     # 0x1781d8
movq 0x720(%rax), %rcx
addq $0x1, %rcx
leaq 0xd7fc8(%rip), %rax     # 0x1781d8
movq %rcx, 0x720(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x43780
addq $0x4070, %rsp           # imm = 0x4070
popq %rbp
retq
nopl (%rax)