// File: /workspace/github_cpp_makefile_star2_O3/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
subq $0x18, %rsp
cmpq $0x0, 0x28(%rdi)
je 0x29e6
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x8(%rdi), %r15
cmpq %r15, %r14
je 0x285f
movq %r15, %rax
subq %r14, %rax
sarq $0x4, %rax
leaq 0x1(%rax), %rcx
shrq $0x3f, %rcx
leaq (%rax,%rcx), %rdx
incq %rdx
sarq %rdx
movq %rsp, %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x2dc0
movq 0x10(%r12), %rdx
testq %rdx, %rdx
je 0x2864
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2eb1
jmp 0x286f
movq %r14, %rax
jmp 0x2889
movq %r14, %rdi
movq %r15, %rsi
callq 0x2e34
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
shlq $0x4, %rsi
callq 0x2140
movq (%rbx), %r14
movq 0x8(%rbx), %rax
movq $0x0, 0x28(%rbx)
movq %rax, %rcx
subq %r14, %rcx
cmpq $0x31, %rcx
jb 0x29e6
leaq 0x10(%r14), %rcx
cmpq %rax, %rcx
je 0x29d9
xorl %edx, %edx
movq 0x1798(%rip), %xmm0     # 0x4050
movapd 0x17a0(%rip), %xmm1     # 0x4060
movapd 0x17a8(%rip), %xmm2     # 0x4070
movapd 0x17b0(%rip), %xmm3     # 0x4080
movq 0x8(%r14), %rdi
movq 0x30(%rbx), %r9
movq %r9, %xmm4
punpckldq %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
subpd %xmm1, %xmm4
leaq (%rdi,%rdx), %rsi
movq 0x8(%rcx), %r8
xorps %xmm5, %xmm5
cvtsi2sd %rsi, %xmm5
xorps %xmm6, %xmm6
cvtsi2sd %rdx, %xmm6
xorps %xmm7, %xmm7
cvtsi2sd %r8, %xmm7
unpcklpd %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0]
xorps %xmm5, %xmm5
cvtsi2sd %rdi, %xmm5
unpcklpd %xmm7, %xmm5            # xmm5 = xmm5[0],xmm7[0]
mulpd %xmm2, %xmm5
addpd %xmm6, %xmm5
movapd %xmm4, %xmm6
unpcklpd %xmm4, %xmm6            # xmm6 = xmm6[0],xmm4[0]
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
addpd %xmm6, %xmm4
divpd %xmm4, %xmm5
movapd %xmm3, %xmm4
subpd %xmm5, %xmm4
mulpd %xmm5, %xmm4
movapd %xmm4, %xmm5
unpckhpd %xmm4, %xmm5            # xmm5 = xmm5[1],xmm4[1]
minsd %xmm4, %xmm5
shlq $0x2, %r9
movq %r9, %xmm4
punpckldq %xmm0, %xmm4    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
subpd %xmm1, %xmm4
movapd %xmm4, %xmm6
unpckhpd %xmm4, %xmm6            # xmm6 = xmm6[1],xmm4[1]
addsd %xmm4, %xmm6
mulsd %xmm5, %xmm6
mulsd 0x18(%rbx), %xmm6
addq %rdi, %r8
xorps %xmm4, %xmm4
cvtsi2sd %r8, %xmm4
ucomisd %xmm4, %xmm6
jae 0x29a1
leaq -0x10(%rcx), %rdi
leaq 0x10(%r14), %rdx
cmpq %r14, %rdi
je 0x2999
movupd (%rcx), %xmm4
movupd %xmm4, (%rdx)
movq 0x8(%rbx), %rax
movq %rdx, %r14
movq %rsi, %rdx
jmp 0x29cc
movq %r8, 0x8(%r14)
xorps %xmm5, %xmm5
cvtsi2sdq 0x8(%rcx), %xmm5
movsd (%rcx), %xmm6
movsd (%r14), %xmm7
subsd %xmm7, %xmm6
mulsd %xmm5, %xmm6
divsd %xmm4, %xmm6
addsd %xmm7, %xmm6
movsd %xmm6, (%r14)
addq $0x10, %rcx
cmpq %rax, %rcx
jne 0x28d0
addq $0x10, %r14
cmpq %rax, %r14
je 0x29e6
movq %r14, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
shlq $0x4, %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x21b0