// File: 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:
subq $0x288, %rsp            # imm = 0x288
movq %rdi, 0x280(%rsp)
movq %rsi, 0x278(%rsp)
movq %rdx, 0x270(%rsp)
movq 0x280(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x268(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x2d660
leaq 0x238(%rsp), %rdi
callq 0x67b0
leaq 0x220(%rsp), %rdi
callq 0x67b0
movq 0x268(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x270(%rsp), %rsi
leaq 0x208(%rsp), %rdi
callq 0xcbb0
jmp 0x11b41
movq 0xb8(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x12260
jmp 0x11b58
leaq 0x208(%rsp), %rdi
callq 0x6830
movq 0x268(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x2d680
jmp 0x11b7c
jmp 0x11b7e
leaq 0x250(%rsp), %rdi
callq 0x2d720
movb %al, 0xb7(%rsp)
jmp 0x11b94
movb 0xb7(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x11ba6
jmp 0x121bc
leaq 0x250(%rsp), %rdi
callq 0x2d6d0
movq %rax, 0xa8(%rsp)
jmp 0x11bbd
movq 0xa8(%rsp), %rax
movq %rax, 0x268(%rsp)
movq 0x268(%rsp), %rdi
callq 0x21aa0
movb %al, 0xa7(%rsp)
jmp 0x11be3
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x12112
jmp 0x11bf4
movq 0x268(%rsp), %rdi
callq 0xcba0
movq %rax, 0x98(%rsp)
jmp 0x11c0b
movq 0x98(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xcbb0
jmp 0x11c22
movq 0x268(%rsp), %rdi
callq 0x12660
movq %rax, 0x90(%rsp)
jmp 0x11c39
movq 0x90(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x278(%rsp), %rsi
movq (%rdi), %rax
movq 0x30(%rax), %rax
leaq 0x1e0(%rsp), %rdx
callq *%rax
jmp 0x11c60
leaq 0x238(%rsp), %rdi
callq 0x122b0
leaq 0x220(%rsp), %rdi
callq 0x122b0
movl $0x0, 0x1dc(%rsp)
movslq 0x1dc(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x8bf0
movq %rax, %rcx
movq 0x88(%rsp), %rax
cmpq %rcx, %rax
jae 0x11e56
movq 0x268(%rsp), %rdi
callq 0x12660
movq %rax, 0x80(%rsp)
jmp 0x11ccd
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x78(%rsp)
movslq 0x1dc(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xcd80
movq 0x78(%rsp), %rsi
movl (%rax), %edx
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq 0x180(%rsp), %rdi
callq *%rax
jmp 0x11d0d
leaq 0x188(%rsp), %rdi
xorl %esi, %esi
callq 0x224f0
movsd %xmm0, 0x70(%rsp)
jmp 0x11d24
movq 0x268(%rsp), %rdi
callq 0x12660
movq %rax, 0x68(%rsp)
jmp 0x11d38
movq 0x68(%rsp), %rdi
callq 0x12670
movsd %xmm0, 0x60(%rsp)
jmp 0x11d4a
movsd 0x70(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x11e0a
movslq 0x1dc(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xcd80
movq %rax, %rsi
leaq 0x238(%rsp), %rdi
callq 0x12490
jmp 0x11d87
jmp 0x11e33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x121eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x6830
jmp 0x121eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x12100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x24b00
jmp 0x12100
movslq 0x1dc(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
callq 0xcd80
movq %rax, %rsi
leaq 0x220(%rsp), %rdi
callq 0x12490
jmp 0x11e31
jmp 0x11e33
leaq 0x180(%rsp), %rdi
callq 0x24b00
movl 0x1dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1dc(%rsp)
jmp 0x11c85
leaq 0x238(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x8aa0
movq 0x50(%rsp), %rdi
movq %rax, 0x160(%rsp)
callq 0x88f0
movq %rax, 0x158(%rsp)
leaq 0x157(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x79a0
movq 0x58(%rsp), %rcx
movq 0x160(%rsp), %rsi
movq 0x158(%rsp), %rdx
leaq 0x168(%rsp), %rdi
callq 0x12500
jmp 0x11eb8
leaq 0x168(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x238(%rsp), %rsi
callq 0x12590
movq 0x38(%rsp), %rdi
callq 0x6830
leaq 0x157(%rsp), %rdi
callq 0xbb90
leaq 0x220(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x8aa0
movq 0x40(%rsp), %rdi
movq %rax, 0x130(%rsp)
callq 0x88f0
movq %rax, 0x128(%rsp)
leaq 0x127(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x79a0
movq 0x48(%rsp), %rcx
movq 0x130(%rsp), %rsi
movq 0x128(%rsp), %rdx
leaq 0x138(%rsp), %rdi
callq 0x12500
jmp 0x11f4b
leaq 0x138(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0x220(%rsp), %rsi
callq 0x12590
movq 0x28(%rsp), %rdi
callq 0x6830
leaq 0x127(%rsp), %rdi
callq 0xbb90
movq 0x268(%rsp), %rdi
callq 0x21af0
movq %rax, 0x30(%rsp)
jmp 0x11f90
leaq 0x108(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0xcbb0
jmp 0x11fa7
movq 0x30(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x12260
jmp 0x11fbb
leaq 0x108(%rsp), %rdi
callq 0x6830
movq 0x268(%rsp), %rdi
callq 0x21af0
movq %rax, 0x20(%rsp)
jmp 0x11fdc
movq 0x20(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x2d680
jmp 0x11ff0
movq 0x268(%rsp), %rdi
callq 0x21b00
movq %rax, 0x18(%rsp)
jmp 0x12004
leaq 0xf0(%rsp), %rdi
leaq 0x220(%rsp), %rsi
callq 0xcbb0
jmp 0x1201b
movq 0x18(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x12260
jmp 0x1202f
leaq 0xf0(%rsp), %rdi
callq 0x6830
movq 0x268(%rsp), %rdi
callq 0x21b00
movq %rax, 0x10(%rsp)
jmp 0x12050
movq 0x10(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x2d680
jmp 0x12064
leaq 0x1e0(%rsp), %rdi
callq 0x6830
jmp 0x12112
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x157(%rsp), %rdi
callq 0xbb90
jmp 0x12100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x127(%rsp), %rdi
callq 0xbb90
jmp 0x12100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x6830
jmp 0x12100
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x6830
leaq 0x1e0(%rsp), %rdi
callq 0x6830
jmp 0x121eb
leaq 0xd8(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x67b0
movq (%rsp), %rsi
movq 0x268(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xcbb0
jmp 0x12143
movq 0x8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x12260
jmp 0x12157
leaq 0xc0(%rsp), %rdi
callq 0x6830
leaq 0xd8(%rsp), %rdi
callq 0x6830
jmp 0x11b7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x121ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x6830
leaq 0xd8(%rsp), %rdi
callq 0x6830
jmp 0x121eb
leaq 0x220(%rsp), %rdi
callq 0x6830
leaq 0x238(%rsp), %rdi
callq 0x6830
leaq 0x250(%rsp), %rdi
callq 0x2d670
addq $0x288, %rsp            # imm = 0x288
retq
leaq 0x220(%rsp), %rdi
callq 0x6830
leaq 0x238(%rsp), %rdi
callq 0x6830
leaq 0x250(%rsp), %rdi
callq 0x2d670
movq 0x200(%rsp), %rdi
callq 0x33e0
nop