// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
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
cmpl $0x2, 0x38(%rbx)
jl 0x7e2ef
movl $0x1, %r13d
movq %rsp, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq (%rax,%r13,8), %rsi
callq 0x41acf
testq %rax, %rax
je 0x7e2e3
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7dead
testl %eax, %eax
jne 0x7e436
movq %r15, %rdi
movq %r12, %rsi
callq 0x7dd56
cmpl $-0x1, %eax
je 0x7e40f
incq %r13
movslq 0x38(%rbx), %rax
cmpq %rax, %r13
jl 0x7e2a3
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41ad6
testq %rax, %rax
je 0x7e31e
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdx
callq 0x41f24
movq %rax, %r15
jmp 0x7e33a
callq 0x7de80
movq %rax, %r15
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x41b77
movq %r15, %rdi
callq 0x7d275
cmpl $-0x1, %eax
je 0x7e40f
movq 0x8(%r15), %rdx
xorl %esi, %esi
movl %esi, %edi
shrl $0x3, %edi
movzbl (%r14), %r8d
movl %esi, %ecx
andb $0x6, %cl
movl $0x3f, %eax
shll %cl, %eax
notb %al
andb 0x10(%rdx,%rdi), %al
movq %r8, %r9
shlq %cl, %r9
orb %al, %r9b
movb $0x8, %al
subb %cl, %al
movl $0xffffffc0, %r10d      # imm = 0xFFFFFFC0
movl %eax, %ecx
sarl %cl, %r10d
movb %r9b, 0x10(%rdx,%rdi)
andb 0x11(%rdx,%rdi), %r10b
shrq %cl, %r8
orb %r10b, %r8b
movb %r8b, 0x11(%rdx,%rdi)
addq $0x6, %rsi
incq %r14
cmpq $0x18000, %rsi          # imm = 0x18000
jne 0x7e351
orb $-0x80, 0xf(%rdx)
movq 0x10(%rbx), %rdi
movq 0x40(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x41d90
movq 0x10(%rbx), %rax
movq 0x40(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x3e5f0(%rip), %rsi     # 0xbc9c4
movl $0x8, %edi
callq 0x7c665
leaq 0x834c3(%rip), %rax     # 0x1018a8
incq 0x720(%rax)
leaq 0x83f1d(%rip), %rax     # 0x102310
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3c854
leaq 0x4f7dd(%rip), %rdi     # 0xcdbf3
callq 0x362b0
movq %rbx, %rdi
movq %rax, %rsi
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3ca86
addq $0x4000, %rsp           # imm = 0x4000
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq