// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/hyperloglog.c
// Function: hllMerge
int hllMerge(uint8_t *max, robj *hll) {
    struct hllhdr *hdr = hll->ptr;
    int i;

    if (hdr->encoding == HLL_DENSE) {
        uint8_t val;

        for (i = 0; i < HLL_REGISTERS; i++) {
            HLL_DENSE_GET_REGISTER(val,hdr->registers,i);
            if (val > max[i]) max[i] = val;
        }
    } else {
        uint8_t *p = hll->ptr, *end = p + sdslen(hll->ptr);
        long runlen, regval;

        p += HLL_HDR_SIZE;
        i = 0;
        while(p < end) {
            if (HLL_SPARSE_IS_ZERO(p)) {
                runlen = HLL_SPARSE_ZERO_LEN(p);
                i += runlen;
                p++;
            } else if (HLL_SPARSE_IS_XZERO(p)) {
                runlen = HLL_SPARSE_XZERO_LEN(p);
                i += runlen;
                p += 2;
            } else {
                runlen = HLL_SPARSE_VAL_LEN(p);
                regval = HLL_SPARSE_VAL_VALUE(p);
                while(runlen--) {
                    if (regval > max[i]) max[i] = regval;
                    i++;
                }
                p++;
            }
        }
        if (i != HLL_REGISTERS) return C_ERR;
    }
    return C_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0x9f889
movl $0x0, -0x24(%rbp)
cmpl $0x4000, -0x24(%rbp)    # imm = 0x4000
jge 0x9f884
jmp 0x9f7d6
movq -0x20(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rbp)
imull $0x6, -0x24(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
cltq
movq %rax, -0x38(%rbp)
imull $0x6, -0x24(%rbp), %eax
andl $0x7, %eax
cltq
movq %rax, -0x40(%rbp)
movl $0x8, %eax
subq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movzbl 0x1(%rax,%rcx), %eax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
shrq %cl, %rax
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rcx
shlq %cl, %rdx
movq %rdx, %rcx
orq %rcx, %rax
andq $0x3f, %rax
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jle 0x9f874
movb -0x25(%rbp), %dl
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x9f876
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9f7c7
jmp 0x9f9ff
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x9e660
movq %rax, %rcx
movq -0x80(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x9f9eb
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x0, %eax
jne 0x9f91c
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
andl $0x3f, %eax
addl $0x1, %eax
cltq
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movslq -0x24(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x24(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x9f9e6
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
andl $0xc0, %eax
cmpl $0x40, %eax
jne 0x9f969
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
andl $0x3f, %eax
shll $0x8, %eax
movq -0x60(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
orl %ecx, %eax
addl $0x1, %eax
cltq
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movslq -0x24(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x24(%rbp)
movq -0x60(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x60(%rbp)
jmp 0x9f9e4
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
andl $0x3, %eax
addl $0x1, %eax
cltq
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
sarl $0x2, %eax
andl $0x1f, %eax
addl $0x1, %eax
cltq
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x70(%rbp)
cmpq $0x0, %rax
je 0x9f9d8
movq -0x78(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpq %rcx, %rax
jle 0x9f9cd
movq -0x78(%rbp), %rax
movb %al, %dl
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9f992
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x9f9e6
jmp 0x9f8cb
cmpl $0x4000, -0x24(%rbp)    # imm = 0x4000
je 0x9f9fd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9fa06
jmp 0x9f9ff
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)