// File: /workspace/github_cpp_makefile_star2_O1/ashlall[P]StreamStats/ChiSquareExperiments/./../SourceCode/ChiSquare/../Quantiles/Q-Digest.cpp
// Function: QDigest::compressUpward(long)
void QDigest::compressUpward(long node)
{
  double threshold = std::floor(size / compression_factor);
  long atNode = get(node);
  while (!isRoot(node))
  {
    if (atNode > threshold)
      break;
    long atSibling = get(sibling(node));
    if (atNode + atSibling > threshold)
      break;
    long parent_ = parent(node);
    long atParent = get(parent_);
    if (atNode + atSibling + atParent > threshold)
      break;

    // restores property 2
    if (node2count.find(parent_) == node2count.end())
	node2count.insert(std::make_pair (parent_, atParent + atNode + atSibling));
    else
      {
	long hold = node2count[parent_];
	node2count[parent_] += 1;
      }
    node2count.erase(node);
    if (atSibling > 0)
      node2count.erase(sibling(node));
    node = parent_;
    atNode = atParent + atNode + atSibling;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x38(%rbp), %rax
movq %rsi, (%rax)
cvtsi2sdq 0x40(%rdi), %xmm0
divsd 0x60(%rdi), %xmm0
callq 0x2310
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
movq %rbx, %r14
callq 0x3864
movsd -0x30(%rbp), %xmm1
movq %rax, %r12
leaq 0x8(%rbx), %rax
movq %rax, -0x40(%rbp)
movq %rbx, -0x48(%rbp)
movq -0x38(%rbp), %r15
cmpq $0x1, %r15
je 0x3ac2
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
ucomisd %xmm1, %xmm0
ja 0x3ac2
movl %r15d, %esi
andl $0x1, %esi
negq %rsi
orq $0x1, %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x3864
movsd -0x30(%rbp), %xmm1
leaq (%rax,%r12), %rbx
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x398a
xorl %r15d, %r15d
jmp 0x3ab9
movq %rax, %r13
movq %r14, %rdi
movq %r15, %r14
shrq $0x3f, %r14
addq %r15, %r14
sarq %r14
movq %r14, -0x50(%rbp)
movq %r14, %rsi
callq 0x3864
movsd -0x30(%rbp), %xmm1
movq %rax, %rcx
addq %rbx, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
ucomisd %xmm1, %xmm0
setbe %r15b
ja 0x3ab5
movq %rax, %r12
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %r8
movq %r14, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x3a2b
movq (%rdx), %r9
movq %rdx, %rax
cmpq 0x8(%r9), %r14
je 0x3a2b
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x3a29
movq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x3a2b
movq %r10, %rax
cmpq %rdi, %r14
jne 0x39fe
jmp 0x3a2b
xorl %eax, %eax
testq %rax, %rax
je 0x3a59
cmpq $0x0, (%rax)
je 0x3a59
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
leaq -0x50(%rbp), %r14
movq %r14, %rsi
callq 0x77cc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x77cc
incq (%rax)
jmp 0x3a74
addq %rbx, %rcx
movq %r14, -0x60(%rbp)
movq %rcx, -0x58(%rbp)
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
leaq -0x60(%rbp), %rsi
callq 0x7522
movq %rbx, %rdi
leaq -0x38(%rbp), %rsi
callq 0x7d42
testq %r13, %r13
jle 0x3aa8
movq -0x38(%rbp), %rax
movl %eax, %ecx
andl $0x1, %ecx
negq %rcx
orq $0x1, %rcx
addq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rbx, %rdi
leaq -0x60(%rbp), %rsi
callq 0x7d42
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movsd -0x30(%rbp), %xmm1
movq -0x48(%rbp), %r14
testb %r15b, %r15b
jne 0x3933
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop