// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/hyperloglog.c
// Function: hllDenseSum
double hllDenseSum(uint8_t *registers, double *PE, int *ezp) {
    double E = 0;
    int j, ez = 0;

    /* Redis default is to use 16384 registers 6 bits each. The code works
     * with other values by modifying the defines, but for our target value
     * we take a faster path with unrolled loops. */
    if (HLL_REGISTERS == 16384 && HLL_BITS == 6) {
        uint8_t *r = registers;
        unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9,
                      r10, r11, r12, r13, r14, r15;
        for (j = 0; j < 1024; j++) {
            /* Handle 16 registers per iteration. */
            r0 = r[0] & 63; if (r0 == 0) ez++;
            r1 = (r[0] >> 6 | r[1] << 2) & 63; if (r1 == 0) ez++;
            r2 = (r[1] >> 4 | r[2] << 4) & 63; if (r2 == 0) ez++;
            r3 = (r[2] >> 2) & 63; if (r3 == 0) ez++;
            r4 = r[3] & 63; if (r4 == 0) ez++;
            r5 = (r[3] >> 6 | r[4] << 2) & 63; if (r5 == 0) ez++;
            r6 = (r[4] >> 4 | r[5] << 4) & 63; if (r6 == 0) ez++;
            r7 = (r[5] >> 2) & 63; if (r7 == 0) ez++;
            r8 = r[6] & 63; if (r8 == 0) ez++;
            r9 = (r[6] >> 6 | r[7] << 2) & 63; if (r9 == 0) ez++;
            r10 = (r[7] >> 4 | r[8] << 4) & 63; if (r10 == 0) ez++;
            r11 = (r[8] >> 2) & 63; if (r11 == 0) ez++;
            r12 = r[9] & 63; if (r12 == 0) ez++;
            r13 = (r[9] >> 6 | r[10] << 2) & 63; if (r13 == 0) ez++;
            r14 = (r[10] >> 4 | r[11] << 4) & 63; if (r14 == 0) ez++;
            r15 = (r[11] >> 2) & 63; if (r15 == 0) ez++;

            /* Additional parens will allow the compiler to optimize the
             * code more with a loss of precision that is not very relevant
             * here (floating point math is not commutative!). */
            E += (PE[r0] + PE[r1]) + (PE[r2] + PE[r3]) + (PE[r4] + PE[r5]) +
                 (PE[r6] + PE[r7]) + (PE[r8] + PE[r9]) + (PE[r10] + PE[r11]) +
                 (PE[r12] + PE[r13]) + (PE[r14] + PE[r15]);
            r += 12;
        }
    } else {
        for (j = 0; j < HLL_REGISTERS; j++) {
            unsigned long reg;

            HLL_DENSE_GET_REGISTER(reg,registers,j);
            if (reg == 0) {
                ez++;
                /* Increment E at the end of the loop. */
            } else {
                E += PE[reg]; /* Precomputed 2^(-reg[j]). */
            }
        }
        E += ez; /* Add 2^0 'ez' times. */
    }
    *ezp = ez;
    return E;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, -0x68(%rsp)
xorl %eax, %eax
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
movzbl (%rdi,%rax), %edx
xorl %r8d, %r8d
movl %edx, %ecx
andl $0x3f, %ecx
movq %rcx, (%rsp)
sete %r8b
movzbl 0x1(%rdi,%rax), %ecx
movl %ecx, %r9d
shrl $0x6, %edx
movq %rdx, -0x38(%rsp)
andl $0xf, %r9d
movq %r9, -0x40(%rsp)
movzbl 0x2(%rdi,%rax), %ebx
movq %rbx, -0x70(%rsp)
shrl $0x4, %ecx
shll $0x4, %ebx
andl $0x30, %ebx
movzbl 0x3(%rdi,%rax), %edx
orl %ecx, %ebx
xorl %r9d, %r9d
movl %edx, %ecx
andl $0x3f, %ecx
movq %rcx, -0x8(%rsp)
sete %r9b
movl %r9d, -0x74(%rsp)
shrl $0x6, %edx
movq %rdx, -0x48(%rsp)
movzbl 0x4(%rdi,%rax), %ecx
movl %ecx, %edx
andl $0xf, %edx
movq %rdx, -0x50(%rsp)
shrl $0x4, %ecx
movzbl 0x5(%rdi,%rax), %r13d
movq %r13, -0x18(%rsp)
xorl %r11d, %r11d
cmpl $0x4, %r13d
setb %r11b
shll $0x4, %r13d
andl $0x30, %r13d
orl %ecx, %r13d
movzbl 0x6(%rdi,%rax), %ecx
movl %ecx, %edx
xorl %r9d, %r9d
andl $0x3f, %edx
movq %rdx, -0x20(%rsp)
sete %r9b
movl %r9d, -0x78(%rsp)
shrl $0x6, %ecx
movzbl 0x7(%rdi,%rax), %edx
movl %edx, %r9d
andl $0xf, %r9d
movq %r9, -0x60(%rsp)
shrl $0x4, %edx
movzbl 0x8(%rdi,%rax), %r14d
movq %r14, -0x10(%rsp)
xorl %r9d, %r9d
cmpl $0x4, %r14d
setb %r9b
movl %r9d, -0x7c(%rsp)
shll $0x4, %r14d
andl $0x30, %r14d
orl %edx, %r14d
movzbl 0x9(%rdi,%rax), %edx
xorl %r9d, %r9d
movl %edx, %r10d
andl $0x3f, %r10d
movq %r10, -0x28(%rsp)
sete %r9b
shrl $0x6, %edx
movzbl 0xa(%rdi,%rax), %r12d
movl %r12d, %r10d
andl $0xf, %r10d
leal (%rdx,%r10,4), %edx
movq %rdx, -0x30(%rsp)
xorl %r10d, %r10d
testl %edx, %edx
sete %r10b
shrl $0x4, %r12d
movzbl 0xb(%rdi,%rax), %edx
movq %rdx, -0x58(%rsp)
xorl %ebp, %ebp
cmpl $0x4, %edx
setb %bpl
shll $0x4, %edx
andl $0x30, %edx
orl %r12d, %edx
cmpl $0x4, -0x70(%rsp)
adcl %r15d, %r8d
movq -0x38(%rsp), %r15
movq -0x40(%rsp), %r12
leal (%r15,%r12,4), %r15d
cmpl $0x1, %r15d
adcl -0x74(%rsp), %r8d
cmpl $0x1, %ebx
adcl %r11d, %r8d
movq -0x48(%rsp), %r12
movq -0x50(%rsp), %r11
leal (%r12,%r11,4), %r12d
cmpl $0x1, %r12d
adcl -0x78(%rsp), %r8d
cmpl $0x1, %r13d
adcl -0x7c(%rsp), %r8d
movq -0x60(%rsp), %r11
leal (%rcx,%r11,4), %ecx
cmpl $0x1, %ecx
adcl %r9d, %r8d
cmpl $0x1, %r14d
adcl %ebp, %r8d
movq (%rsp), %r9
movsd (%rsi,%r9,8), %xmm1
addsd (%rsi,%r15,8), %xmm1
cmpl $0x1, %edx
movl %r8d, %r15d
adcl %r10d, %r15d
movsd (%rsi,%rbx,8), %xmm2
movq -0x70(%rsp), %r8
andl $-0x4, %r8d
addsd (%rsi,%r8,2), %xmm2
movq -0x8(%rsp), %r8
movsd (%rsi,%r8,8), %xmm3
addsd (%rsi,%r12,8), %xmm3
movsd (%rsi,%r13,8), %xmm4
movq -0x18(%rsp), %r8
andl $-0x4, %r8d
addsd (%rsi,%r8,2), %xmm4
movq -0x20(%rsp), %r8
movsd (%rsi,%r8,8), %xmm5
addsd (%rsi,%rcx,8), %xmm5
movsd (%rsi,%r14,8), %xmm6
movq -0x28(%rsp), %rcx
movsd (%rsi,%rcx,8), %xmm7
movq -0x10(%rsp), %rcx
andl $-0x4, %ecx
addsd (%rsi,%rcx,2), %xmm6
movq -0x30(%rsp), %rcx
addsd (%rsi,%rcx,8), %xmm7
movsd (%rsi,%rdx,8), %xmm8
movq -0x58(%rsp), %rcx
andl $-0x4, %ecx
addsd (%rsi,%rcx,2), %xmm8
addsd %xmm1, %xmm2
addsd %xmm2, %xmm3
addsd %xmm3, %xmm4
addsd %xmm4, %xmm5
addsd %xmm5, %xmm6
addsd %xmm6, %xmm7
addsd %xmm7, %xmm8
addsd %xmm8, %xmm0
addq $0xc, %rax
cmpl $0x3000, %eax           # imm = 0x3000
jne 0x6114c
movq -0x68(%rsp), %rax
movl %r15d, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq