// File: /workspace/github_cpp_makefile_star2_O2/0asa[P]TTree-source/ClassicNodeTree.cpp
// Function: ClassicNodeTree::computeVimp(std::vector<float, std::allocator<float>>&, std::vector<unsigned int, std::allocator<unsigned int>>&)
void  ClassicNodeTree::computeVimp(std::vector<float> &vim, std::vector<unsigned int> &set) {
	Node* n = root;
	Stack stack;
	std::vector<unsigned int> left;
	std::vector<unsigned int> right;
	n->setLS(set);
	stack.push(n);
	while (!stack.empty()) {
		n = stack.pop();
		if (!n->isLeaf()) {
			std::vector<unsigned int> ss = n->getLS();
			((TreeNodeTest*)n->getTest())->weak->computeVimp(vim,ss);	
			// getLRset ?
			left.clear();
			right.clear();
			for (int i = 0 ; i < ss.size() ; ++i) {
				Result r = ((TreeNodeTest*)n->getTest())->weak->test((double) ss[i]);	
				if (r.prob.getProb(0)>=((TreeNodeTest*)n->getTest())->getTh())
					left.push_back(ss[i]);
				else 
					right.push_back(ss[i]);
			}
			// SHRINK TO FIT TRICK :
			std::vector<unsigned int>(left.begin(),left.end()).swap(left);
			std::vector<unsigned int>(right.begin(),right.end()).swap(right);
			//printf("((TreeNodeTest*)n)->getLRSet(ss,left,right);\n"); fflush(stdout);
			// push left and right
			n->getLeft()->setLS(left); stack.push(n->getLeft());
			n->getRight()->setLS(right); stack.push(n->getRight());			
		}
		std::vector<unsigned int> empty;
		n->setLS(empty);
	}

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdx, %r14
movq %rsi, 0x50(%rsp)
movq 0x50(%rdi), %rbx
leaq 0x70(%rsp), %rdi
callq 0x12418
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x6c64
leaq 0x88(%rsp), %rsi
movq %rbx, %rdi
callq 0x8884
leaq 0x88(%rsp), %rdi
callq 0x6886
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x1242a
leaq 0x70(%rsp), %r14
leaq 0xa0(%rsp), %r13
leaq 0x10(%rsp), %rbx
leaq 0x30(%rsp), %rbp
movq %r14, %rdi
callq 0x12460
testb %al, %al
jne 0x8789
movq %r14, %rdi
callq 0x1244e
movq %rax, %r12
movq %rax, %rdi
callq 0xe4fa
testb %al, %al
jne 0x8740
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x6c64
movq 0x30(%r12), %rax
movq 0x18(%rax), %rdi
movq (%rdi), %rax
movq 0x50(%rsp), %rsi
movq %r14, %rdx
callq *0x30(%rax)
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x8573
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x8584
movq %rax, 0x18(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x85f4
movq 0x30(%r12), %rcx
movq 0x18(%rcx), %rsi
movl (%rax,%r14,4), %edx
movq (%rsi), %rax
movq %r13, %rdi
callq *0x10(%rax)
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0xe8d2
movq 0x30(%r12), %rax
movq 0x58(%rsp), %rsi
addq %r15, %rsi
ucomisd 0x8(%rax), %xmm0
movq %rbp, %rdi
cmovbq %rbx, %rdi
callq 0x8982
movq %r13, %rdi
callq 0xfa56
incq %r14
addq $0x4, %r15
jmp 0x858a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, %rdi
leaq 0xf(%rsp), %r14
movq %r14, %rcx
callq 0x89a0
movq 0xb0(%rsp), %rax
movapd 0x30(%rsp), %xmm0
movq 0x40(%rsp), %rcx
movq %rcx, 0xb0(%rsp)
movaps 0xa0(%rsp), %xmm1
movapd %xmm0, 0xa0(%rsp)
movaps %xmm1, 0x30(%rsp)
movq %rax, 0x40(%rsp)
movq %r13, %rdi
callq 0x6886
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rdi
movq %r14, %rcx
callq 0x89a0
leaq 0x70(%rsp), %r14
movq 0xb0(%rsp), %rax
movapd 0x10(%rsp), %xmm0
movq 0x20(%rsp), %rcx
movq %rcx, 0xb0(%rsp)
movaps 0xa0(%rsp), %xmm1
movapd %xmm0, 0xa0(%rsp)
movaps %xmm1, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movq %r13, %rdi
callq 0x6886
movq %r12, %rdi
callq 0xe50c
movq %rax, %r15
leaq 0x118(%rsp), %rdi
movq %rbp, %rsi
callq 0x6c64
movq %r15, %rdi
leaq 0x118(%rsp), %r15
movq %r15, %rsi
callq 0x8884
movq %r15, %rdi
callq 0x6886
movq %r12, %rdi
callq 0xe50c
movq %r14, %rdi
movq %rax, %rsi
callq 0x1242a
movq %r12, %rdi
callq 0xe512
movq %rax, %r15
leaq 0x100(%rsp), %rdi
movq %rbx, %rsi
callq 0x6c64
movq %r15, %rdi
leaq 0x100(%rsp), %r15
movq %r15, %rsi
callq 0x8884
movq %r15, %rdi
callq 0x6886
movq %r12, %rdi
callq 0xe512
movq %r14, %rdi
movq %rax, %rsi
callq 0x1242a
leaq 0x58(%rsp), %rdi
callq 0x6886
xorpd %xmm0, %xmm0
movapd %xmm0, 0xa0(%rsp)
andq $0x0, 0xb0(%rsp)
leaq 0x130(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x6c64
movq %r12, %rdi
movq %r15, %rsi
callq 0x8884
movq %r15, %rdi
callq 0x6886
movq %r13, %rdi
callq 0x6886
jmp 0x8510
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0x70(%rsp), %rdi
callq 0x12424
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x882d
jmp 0x880c
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
jmp 0x87e0
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x6886
jmp 0x8828
jmp 0x8813
jmp 0x8813
jmp 0x880c
movq %rax, %rbx
jmp 0x8802
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x6886
leaq 0xa0(%rsp), %rdi
jmp 0x882d
movq %rax, %rbx
jmp 0x8832
jmp 0x8813
movq %rax, %rbx
jmp 0x8828
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xfa56
leaq 0x58(%rsp), %rdi
callq 0x6886
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0x70(%rsp), %rdi
callq 0x12424
movq %rbx, %rdi
callq 0x3330