// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/hyperloglog.c
// Function: pfmergeCommand
void pfmergeCommand(redisClient *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) != REDIS_OK) return;

        /* Merge with this HLL with our 'max' HHL by setting max[i]
         * to MAX(max[i],hll[i]). */
        if (hllMerge(max,o) == REDIS_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) == REDIS_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(REDIS_NOTIFY_STRING,"pfadd",c->argv[1],c->db->id);
    server.dirty++;
    addReply(c,shared.ok);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4008, %rsp           # imm = 0x4008
movq %rdi, %rbx
movq %rsp, %r14
movl $0x4000, %edx           # imm = 0x4000
movq %r14, %rdi
xorl %esi, %esi
callq 0x1f110
cmpl $0x2, 0x30(%rbx)
jl 0x622b2
movl $0x1, %ebp
movq %rsp, %r15
leaq 0x3e074(%rip), %r12     # 0xa02b3
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq (%rax,%rbp,8), %rsi
callq 0x3136a
testq %rax, %rax
je 0x62298
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
callq 0x61e16
movl $0x1, %ecx
testl %eax, %eax
jne 0x6229d
movq %r15, %rdi
movq %r13, %rsi
callq 0x61cf6
xorl %ecx, %ecx
cmpl $-0x1, %eax
jne 0x6229d
movq %r12, %rdi
callq 0x281da
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2d894
movl $0x1, %ecx
jmp 0x6229d
movl $0x4, %ecx
testb $0x3, %cl
jne 0x623f8
incq %rbp
movslq 0x30(%rbx), %rax
cmpq %rax, %rbp
jl 0x6223f
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x31454
testq %rax, %rax
je 0x622e1
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdx
callq 0x317d7
movq %rax, %r15
jmp 0x622fd
callq 0x61de9
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
movq %r15, %rdx
callq 0x314ef
movq %r15, %rdi
callq 0x613d7
cmpl $-0x1, %eax
je 0x623d0
movq 0x8(%r15), %rdx
xorl %esi, %esi
movl %esi, %edi
shrl $0x3, %edi
movl %esi, %ecx
andb $0x6, %cl
movzbl (%r14), %r8d
movb $0x3f, %al
shlb %cl, %al
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 0x62314
orb $-0x80, 0x8(%rdx)
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
callq 0x316b7
movq 0x8(%rbx), %rax
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rdx
movl 0x30(%rax), %ecx
leaq 0x322c5(%rip), %rsi     # 0x94659
movl $0x8, %edi
callq 0x608b5
leaq 0x67c03(%rip), %rax     # 0xc9fa8
incq 0x560(%rax)
leaq 0x6844d(%rip), %rax     # 0xca800
movq 0x8(%rax), %rsi
movq %rbx, %rdi
addq $0x4008, %rsp           # imm = 0x4008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d6f0
leaq 0x3dedc(%rip), %rdi     # 0xa02b3
callq 0x281da
movq %rbx, %rdi
movq %rax, %rsi
addq $0x4008, %rsp           # imm = 0x4008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d894
addq $0x4008, %rsp           # imm = 0x4008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq