// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %rbx
movq %rdi, %r14
cvtsi2sdq 0x40(%rdi), %xmm0
divsd 0x60(%rdi), %xmm0
callq 0x2310
movsd %xmm0, -0x70(%rbp)
xorpd %xmm0, %xmm0
leaq -0x50(%rbp), %r15
movapd %xmm0, (%r15)
movq $0x0, 0x10(%r15)
movq %r15, 0x8(%r15)
movq %r15, (%r15)
movl $0x18, %edi
callq 0x2220
movq %rbx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq -0x40(%rbp)
movq -0x50(%rbp), %rbx
cmpq %r15, %rbx
je 0x3dc0
leaq 0x8(%r14), %rax
movq %rax, -0x68(%rbp)
movq 0x10(%rbx), %rax
movq %rax, -0x30(%rbp)
decq -0x40(%rbp)
movq %rbx, %rdi
callq 0x22f0
movq %rbx, %rdi
callq 0x21f0
movq -0x30(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x3864
movq %rax, %rbx
movl %r12d, %esi
andl $0x1, %esi
negq %rsi
orq $0x1, %rsi
addq %r12, %rsi
movq %r14, %rdi
callq 0x3864
movq %rax, %r13
orq %rbx, %rax
je 0x3db3
movq %r12, %r15
shrq $0x3f, %r15
addq %r12, %r15
sarq %r15
movq %r15, -0x78(%rbp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3864
addq %rbx, %r13
addq %rax, %r13
xorps %xmm0, %xmm0
cvtsi2sd %r13, %xmm0
ucomisd -0x70(%rbp), %xmm0
ja 0x3daf
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdi
movq %r15, %rax
xorl %edx, %edx
divq %rdi
movq %rdx, %rcx
movq (%rsi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
movq -0x68(%rbp), %rbx
je 0x3cef
movq (%rdx), %r8
movq %rdx, %rax
cmpq 0x8(%r8), %r15
je 0x3cef
movq %r8, %r9
movq (%r8), %r8
testq %r8, %r8
je 0x3ced
movq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %eax
cmpq %rcx, %rdx
jne 0x3cef
movq %r9, %rax
cmpq %rsi, %r15
jne 0x3cc2
jmp 0x3cef
xorl %eax, %eax
testq %rax, %rax
je 0x3d0b
cmpq $0x0, (%rax)
je 0x3d0b
movq %rbx, %rdi
leaq -0x78(%rbp), %rsi
callq 0x77cc
incq (%rax)
jmp 0x3d1f
movq %r15, -0x60(%rbp)
movq %r13, -0x58(%rbp)
movq %rbx, %rdi
leaq -0x60(%rbp), %rsi
callq 0x7522
movq %rbx, %rdi
leaq -0x30(%rbp), %rsi
callq 0x7d42
movq -0x30(%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 -0x30(%rbp), %rbx
cmpq %rbx, 0x48(%r14)
jle 0x3daf
movl $0x18, %edi
callq 0x2220
addq %rbx, %rbx
movq %rbx, 0x10(%rax)
movq %rax, %rdi
leaq -0x50(%rbp), %r15
movq %r15, %rsi
callq 0x2070
incq -0x40(%rbp)
movq -0x30(%rbp), %rbx
movl $0x18, %edi
callq 0x2220
movl %ebx, %ecx
andl $0x1, %ecx
negq %rcx
orq $0x1, %rcx
addq %rbx, %rcx
addq %rcx, %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2070
incq -0x40(%rbp)
leaq -0x50(%rbp), %r15
movq -0x50(%rbp), %rbx
cmpq %r15, %rbx
jne 0x3c0a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3dd9
jmp 0x3dd9
jmp 0x3dd9
jmp 0x3dd9
jmp 0x3dd9
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x50(%rbp), %r15
cmpq %r15, %rdi
je 0x3df9
movq (%rdi), %rbx
callq 0x21f0
movq %rbx, %rdi
cmpq %r15, %rbx
jne 0x3de9
movq %r14, %rdi
callq 0x2360
nop