// File: /workspace/github_cpp_makefile_star2_O2/ashlall[P]StreamStats/ChiSquareExperiments/./../SourceCode/ChiSquare/../Quantiles/Q-Digest.cpp
// Function: QDigest::compressDownward(long)
void QDigest::compressDownward(long seedNode)
{
  double threshold = std :: floor(size/compression_factor); 
	
  std::queue<long, std::list<long> > queue;
  queue.push(seedNode);
  while(!queue.empty())
  {
    long node = queue.front();
    queue.pop();
    long atNode = get(node);
    long atSibling = get(sibling(node));
    if (atNode == 0 && atSibling == 0)
      continue;
    long parent_ = parent(node);
    long atParent = get(parent_);
    if (atParent + atNode + atSibling > threshold)
       continue;
    if (node2count.find(parent_) == node2count.end())
      node2count.insert(std::make_pair (parent_, atParent + atNode + atSibling));
    else
      node2count[parent_] += 1;
    node2count.erase(node);
    node2count.erase(sibling(node));

    // Ensures that P2 holds for node and sibling subtrees
    if (!isLeaf(node))
    {
      queue.push(leftChild(node));
      queue.push(leftChild(sibling(node)));
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
leaq -0x78(%rbp), %r15
movq %rsi, (%r15)
cvtsi2sdq 0x40(%rdi), %xmm0
divsd 0x60(%rdi), %xmm0
callq 0x22d0
movsd %xmm0, -0x58(%rbp)
leaq -0x70(%rbp), %r12
movq %r12, 0x8(%r12)
movq %r12, (%r12)
andq $0x0, 0x10(%r12)
movq %r12, %rdi
movq %r15, %rsi
callq 0x7506
leaq 0x8(%rbx), %rax
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %r14
movq -0x70(%rbp), %rax
cmpq %r12, %rax
je 0x3856
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq %r12, %r15
movq %r12, %rdi
callq 0x75ee
movq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x34a2
movq %rax, %r13
movq -0x30(%rbp), %rax
movl %eax, %esi
andl $0x1, %esi
negq %rsi
orq $0x1, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x34a2
movq %rax, %r12
orq %r13, %rax
je 0x384e
movq -0x30(%rbp), %rax
cqto
pushq $0x2
popq %rcx
idivq %rcx
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x34a2
addq %r13, %r12
addq %rax, %r12
cvtsi2sd %r12, %xmm0
ucomisd -0x58(%rbp), %xmm0
ja 0x384e
movq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x6a32
testq %rax, %rax
je 0x37bf
movq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x6d42
incq (%rax)
jmp 0x37d7
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %r12, -0x48(%rbp)
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x6abc
movq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x73f6
movq -0x30(%rbp), %rax
movl %eax, %ecx
andl $0x1, %ecx
negq %rcx
orq $0x1, %rcx
addq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x73f6
movq -0x30(%rbp), %rax
cmpq %rax, 0x48(%rbx)
jle 0x384e
addq %rax, %rax
movq %rax, -0x50(%rbp)
movq %r15, %r13
movq %r15, %rdi
movq %r14, %r12
movq %r14, %rsi
callq 0x7620
movq -0x30(%rbp), %rax
movl %eax, %ecx
andl $0x1, %ecx
negq %rcx
orq $0x1, %rcx
addq %rax, %rcx
addq %rcx, %rcx
movq %rcx, -0x50(%rbp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x7620
movq %r15, %r12
jmp 0x3714
leaq -0x70(%rbp), %rdi
callq 0x61f8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x387e
jmp 0x387e
jmp 0x387e
jmp 0x387e
jmp 0x387e
jmp 0x387e
jmp 0x387e
jmp 0x387e
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x61f8
movq %rbx, %rdi
callq 0x2320