// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/hyperloglog.c
// Function: pfmergeCommand
void pfmergeCommand(client *c) {
    uint8_t max[HLL_REGISTERS];
    struct hllhdr *hdr;
    int j;

    /* Compute an HLL with M[i] = MAX(M[i]_j).
     * We we the maximum into the max array of registers. We'll write
     * it to the target variable later. */
    memset(max,0,sizeof(max));
    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(max,o) == C_ERR) {
            addReplySds(c,sdsnew(invalid_hll_err));
            return;
        }
    }

    /* Create / unshare the destination key's value if needed. */
    robj *o = lookupKeyWrite(c->db,c->argv[1]);
    if (o == NULL) {
        /* Create the key with a string value of the exact length to
         * hold our HLL data structure. sdsnewlen() when NULL is passed
         * is guaranteed to return bytes initialized to zero. */
        o = createHLLObject();
        dbAdd(c->db,c->argv[1],o);
    } else {
        /* If key exists we are sure it's of the right type/size
         * since we checked when merging the different HLLs, so we
         * don't check again. */
        o = dbUnshareStringValue(c->db,c->argv[1],o);
    }

    /* Only support dense objects as destination. */
    if (hllSparseToDense(o) == C_ERR) {
        addReplySds(c,sdsnew(invalid_hll_err));
        return;
    }

    /* Write the resulting HLL to the destination HLL registers and
     * invalidate the cached value. */
    hdr = o->ptr;
    for (j = 0; j < HLL_REGISTERS; j++) {
        HLL_DENSE_SET_REGISTER(hdr->registers,j,max[j]);
    }
    HLL_INVALIDATE_CACHE(hdr);

    signalModifiedKey(c->db,c->argv[1]);
    /* We generate an PFADD event for PFMERGE for semantical simplicity
     * since in theory this is a mass-add of elements. */
    notifyKeyspaceEvent(NOTIFY_STRING,"pfadd",c->argv[1],c->db->id);
    server.dirty++;
    addReply(c,shared.ok);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x4000, %rsp           # imm = 0x4000
movq %rdi, %rbx
movq %rsp, %r14
movl $0x4000, %edx           # imm = 0x4000
movq %r14, %rdi
xorl %esi, %esi
callq 0x26110
pushq $0x1
popq %r12
movslq 0x38(%rbx), %rcx
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
cmpq %rcx, %r12
jge 0x7163f
movq (%rax,%r12,8), %rsi
callq 0x3aebb
testq %rax, %rax
je 0x7163a
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x71238
testl %eax, %eax
jne 0x71666
movq %r14, %rdi
movq %r15, %rsi
callq 0x710c1
cmpl $-0x1, %eax
je 0x71705
incq %r12
jmp 0x715f5
movq 0x8(%rax), %rsi
callq 0x3aec2
testq %rax, %rax
je 0x71676
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdx
callq 0x3b27c
movq %rax, %r15
jmp 0x71692
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x711b2
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x3af45
movq %r15, %rdi
callq 0x706fa
cmpl $-0x1, %eax
je 0x71705
movq 0x8(%r15), %rdx
xorl %esi, %esi
pushq $0x3f
popq %rdi
pushq $-0x40
popq %r8
cmpq $0x18000, %rsi          # imm = 0x18000
je 0x7172b
movl %esi, %r9d
shrl $0x3, %r9d
movzbl (%r14), %r10d
movl %esi, %ecx
andb $0x6, %cl
movl %edi, %r11d
shll %cl, %r11d
notb %r11b
andb 0x10(%rdx,%r9), %r11b
movq %r10, %r15
shlq %cl, %r15
movb $0x8, %al
subb %cl, %al
movl %r8d, %ebp
movl %eax, %ecx
sarl %cl, %ebp
orb %r11b, %r15b
movb %r15b, 0x10(%rdx,%r9)
andb 0x11(%rdx,%r9), %bpl
shrq %cl, %r10
orb %bpl, %r10b
movb %r10b, 0x11(%rdx,%r9)
addq $0x6, %rsi
incq %r14
jmp 0x716ac
leaq 0x4d0ac(%rip), %rdi     # 0xbe7b8
callq 0x3115a
movq %rbx, %rdi
movq %rax, %rsi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x36a9d
orb $-0x80, 0xf(%rdx)
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x3b125
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x3d15e(%rip), %rsi     # 0xae8b4
pushq $0x8
popq %rdi
callq 0x6fb58
leaq 0x88143(%rip), %rax     # 0xf98a8
incq 0x720(%rax)
leaq 0x88b9d(%rip), %rax     # 0xfa310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x36987