// File: /workspace/github_cpp_makefile_star2_O1/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 0x29f6
movq %rdi, %rbx
movq (%rdi), %r15
movq 0x8(%rdi), %r14
cmpq %r14, %r15
je 0x287d
movq %r14, %rax
subq %r15, %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 %r15, %rsi
callq 0x2dce
movq 0x10(%r12), %rdx
testq %rdx, %rdx
je 0x285f
movq 0x8(%rsp), %rcx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2ebf
jmp 0x286a
movq %r15, %rdi
movq %r14, %rsi
callq 0x2e42
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdi
shlq $0x4, %rsi
callq 0x2140
movq $0x0, 0x28(%rbx)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
cmpq $0x31, %rcx
jb 0x29f6
leaq 0x10(%rax), %rcx
movq 0x8(%rbx), %rsi
cmpq %rsi, %rcx
je 0x29d7
xorl %edx, %edx
movsd 0x175c(%rip), %xmm0     # 0x4010
movq 0x1794(%rip), %xmm1     # 0x4050
movapd 0x179c(%rip), %xmm2     # 0x4060
movsd 0x1764(%rip), %xmm3     # 0x4030
xorps %xmm4, %xmm4
cvtsi2sd %rdx, %xmm4
movq 0x8(%rax), %rsi
xorps %xmm5, %xmm5
cvtsi2sd %rsi, %xmm5
mulsd %xmm0, %xmm5
addsd %xmm4, %xmm5
movq 0x30(%rbx), %r9
movq %r9, %xmm4
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm2, %xmm4
movapd %xmm4, %xmm6
unpckhpd %xmm4, %xmm6            # xmm6 = xmm6[1],xmm4[1]
addsd %xmm4, %xmm6
divsd %xmm6, %xmm5
movapd %xmm3, %xmm4
subsd %xmm5, %xmm4
mulsd %xmm5, %xmm4
leaq (%rsi,%rdx), %rdi
xorps %xmm5, %xmm5
cvtsi2sd %rdi, %xmm5
movq 0x8(%rcx), %r8
xorps %xmm7, %xmm7
cvtsi2sd %r8, %xmm7
mulsd %xmm0, %xmm7
addsd %xmm5, %xmm7
divsd %xmm6, %xmm7
movapd %xmm3, %xmm5
subsd %xmm7, %xmm5
mulsd %xmm7, %xmm5
minsd %xmm4, %xmm5
shlq $0x2, %r9
movq %r9, %xmm4
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm2, %xmm4
movapd %xmm4, %xmm6
unpckhpd %xmm4, %xmm6            # xmm6 = xmm6[1],xmm4[1]
addsd %xmm4, %xmm6
mulsd %xmm5, %xmm6
mulsd 0x18(%rbx), %xmm6
addq %rsi, %r8
xorps %xmm4, %xmm4
cvtsi2sd %r8, %xmm4
ucomisd %xmm4, %xmm6
jae 0x299d
leaq -0x10(%rcx), %rsi
leaq 0x10(%rax), %rdx
cmpq %rax, %rsi
je 0x2995
movupd (%rcx), %xmm4
movupd %xmm4, (%rdx)
movq %rdx, %rax
movq %rdi, %rdx
jmp 0x29c6
movq %r8, 0x8(%rax)
xorps %xmm5, %xmm5
cvtsi2sdq 0x8(%rcx), %xmm5
movsd (%rcx), %xmm6
movsd (%rax), %xmm7
subsd %xmm7, %xmm6
mulsd %xmm5, %xmm6
divsd %xmm4, %xmm6
addsd %xmm7, %xmm6
movsd %xmm6, (%rax)
addq $0x10, %rcx
movq 0x8(%rbx), %rsi
cmpq %rsi, %rcx
jne 0x28cc
addq $0x10, %rax
cmpq %rsi, %rax
je 0x29f6
movq 0x8(%rbx), %rcx
movq %rcx, %rdx
subq %rsi, %rdx
addq %rdx, %rax
cmpq %rax, %rcx
je 0x29f6
movq %rax, 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