// File: /workspace/github_cpp_makefile_star2_O2/snaury[P]t-digest-simple/./merging_tdigest.hpp
// Function: MergingTDigest::compress()
void compress() {
        if (buffer_size_ > 0) {
            std::stable_sort(summary_.begin(), summary_.end());
            buffer_size_ = 0;
            if (summary_.size() > 3) {
                auto l = summary_.begin();
                auto r = std::next(l);
                int64_t sum = 0;
                while (r != summary_.end()) {
                    // use quantile with the smallest error
                    double ql = (sum + l->count * 0.5) / count_;
                    double err = ql * (1.0 - ql);
                    double qr = (sum + l->count + r->count * 0.5) / count_;
                    double err2 = qr * (1.0 - qr);
                    if (err > err2) {
                        err = err2;
                    }
                    double k = 4 * count_ * err * epsilon_;
                    if (l->count + r->count <= k) {
                        // it is possible to merge left and right
                        *l += *r;
                    } else {
                        // skip to the next pair
                        sum += l->count;
                        if (++l != r) {
                            *l = *r;
                        }
                    }
                    ++r;
                }
                // remove all leftover centroids
                summary_.erase(++l, summary_.end());
            }
        }
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x28(%rdi)
je 0x27b7
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x8(%rbx), %rsi
callq 0x2bef
andq $0x0, 0x28(%rbx)
movq (%rbx), %r14
movq 0x8(%rbx), %rdx
movq %rdx, %rax
subq %r14, %rax
cmpq $0x31, %rax
jb 0x27b7
leaq 0x10(%r14), %r15
xorl %r12d, %r12d
movq 0x19a1(%rip), %xmm4     # 0x4040
movapd 0x19a9(%rip), %xmm5     # 0x4050
movapd 0x19b1(%rip), %xmm6     # 0x4060
movapd 0x19b9(%rip), %xmm7     # 0x4070
cmpq %rdx, %r15
je 0x27c3
movq 0x8(%r14), %rcx
movq 0x30(%rbx), %rsi
movq %rsi, %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm5, %xmm0
leaq (%rcx,%r12), %rax
movq 0x8(%r15), %rdx
cvtsi2sd %rax, %xmm1
cvtsi2sd %r12, %xmm2
cvtsi2sd %rdx, %xmm3
unpcklpd %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0]
cvtsi2sd %rcx, %xmm1
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
mulpd %xmm6, %xmm1
addpd %xmm2, %xmm1
movapd %xmm0, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addpd %xmm2, %xmm0
divpd %xmm0, %xmm1
movapd %xmm7, %xmm0
subpd %xmm1, %xmm0
mulpd %xmm1, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
minsd %xmm0, %xmm1
shlq $0x2, %rsi
movq %rsi, %xmm0
punpckldq %xmm4, %xmm0    # xmm0 = xmm0[0],xmm4[0],xmm0[1],xmm4[1]
subpd %xmm5, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
mulsd 0x18(%rbx), %xmm2
addq %rcx, %rdx
cvtsi2sd %rdx, %xmm0
ucomisd %xmm0, %xmm2
jae 0x277f
leaq -0x10(%r15), %rdx
leaq 0x10(%r14), %rcx
cmpq %r14, %rdx
je 0x2777
movupd (%r15), %xmm0
movupd %xmm0, (%rcx)
movq %rcx, %r14
movq %rax, %r12
jmp 0x27aa
movq %r14, %rdi
movq %r15, %rsi
callq 0x2bb2
movapd 0x18de(%rip), %xmm7     # 0x4070
movapd 0x18c6(%rip), %xmm6     # 0x4060
movapd 0x18ae(%rip), %xmm5     # 0x4050
movq 0x1896(%rip), %xmm4     # 0x4040
movq 0x8(%rbx), %rdx
addq $0x10, %r15
jmp 0x26b7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
addq $0x10, %r14
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2bea
nop