// File: 0asa[P]TTree-source/ClassicNodeTree.cpp
// Function: ClassicNodeTree::computeGroupVimp(std::vector<float, std::allocator<float>>&, std::vector<unsigned int, std::allocator<unsigned int>>&)
void ClassicNodeTree::computeGroupVimp(std::vector<float> &gim, std::vector<unsigned int> &set) {
	Node* n = root;
	n->setLS(set);
	Score sc;
	std::vector<unsigned int> left;
	std::vector<unsigned int> right;
	Stack stack;
	stack.push(n);
	while (!stack.empty()) {
		n = stack.pop();
		if (!n->isLeaf()) {
			// test local set & compute score
			std::vector<unsigned int> ss = n->getLS();
			ContingencyTable ctable = ((TreeNodeTest*)n->getTest())->weak->test(&ss).getContingencyTable(((TreeNodeTest*)n->getTest())->getTh());
			ctable.compact(((TreeNodeTest*)n->getTest())->getTh()); // inappropié !
			// get group and add to gim
			int group = ((TreeNodeTest*)n->getTest())->getGroup();
			gim[group] += sc.getMutualInfo(ctable)*ss.size();
			// compute partition left and right and push to stack 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 $0x3a8, %rsp            # imm = 0x3A8
movq %rdi, 0x3a0(%rsp)
movq %rsi, 0x398(%rsp)
movq %rdx, 0x390(%rsp)
movq 0x3a0(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x388(%rsp)
movq 0x388(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x390(%rsp), %rsi
leaq 0x370(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0xcbb0
movq 0x100(%rsp), %rdi
movq 0x108(%rsp), %rsi
callq 0x12260
jmp 0x10f67
leaq 0x370(%rsp), %rdi
callq 0x6830
leaq 0x360(%rsp), %rdi
callq 0xcdf0
leaq 0x348(%rsp), %rdi
callq 0x67b0
leaq 0x330(%rsp), %rdi
callq 0x67b0
leaq 0x318(%rsp), %rdi
callq 0x2d660
jmp 0x10faa
movq 0x388(%rsp), %rsi
leaq 0x318(%rsp), %rdi
callq 0x2d680
jmp 0x10fc1
jmp 0x10fc3
leaq 0x318(%rsp), %rdi
callq 0x2d720
movb %al, 0xff(%rsp)
jmp 0x10fd9
movb 0xff(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x10feb
jmp 0x117f5
leaq 0x318(%rsp), %rdi
callq 0x2d6d0
movq %rax, 0xf0(%rsp)
jmp 0x11002
movq 0xf0(%rsp), %rax
movq %rax, 0x388(%rsp)
movq 0x388(%rsp), %rdi
callq 0x21aa0
movb %al, 0xef(%rsp)
jmp 0x11028
movb 0xef(%rsp), %al
testb $0x1, %al
jne 0x11749
jmp 0x11039
movq 0x388(%rsp), %rdi
callq 0xcba0
movq %rax, 0xe0(%rsp)
jmp 0x11050
movq 0xe0(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0xcbb0
jmp 0x11067
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0xd8(%rsp)
jmp 0x1107e
movq 0xd8(%rsp), %rax
movq 0x18(%rax), %rsi
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq 0x230(%rsp), %rdi
leaq 0x300(%rsp), %rdx
callq *%rax
jmp 0x110a5
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0xd0(%rsp)
jmp 0x110bc
movq 0xd0(%rsp), %rdi
callq 0x12670
movsd %xmm0, 0xc8(%rsp)
jmp 0x110d4
movsd 0xc8(%rsp), %xmm0
leaq 0x288(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x24e90
jmp 0x110f4
leaq 0x230(%rsp), %rdi
callq 0x24b00
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0xc0(%rsp)
jmp 0x11118
movq 0xc0(%rsp), %rdi
callq 0x12670
movsd %xmm0, 0xb8(%rsp)
jmp 0x11130
movsd 0xb8(%rsp), %xmm0
leaq 0x288(%rsp), %rdi
callq 0x16f90
jmp 0x11148
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0xb0(%rsp)
jmp 0x1115f
movq 0xb0(%rsp), %rdi
callq 0x2dc20
movl %eax, 0xac(%rsp)
jmp 0x11175
movl 0xac(%rsp), %eax
movl %eax, 0x22c(%rsp)
leaq 0x360(%rsp), %rdi
leaq 0x288(%rsp), %rsi
callq 0x26a40
movsd %xmm0, 0xa0(%rsp)
jmp 0x111a3
leaq 0x300(%rsp), %rdi
callq 0x8bf0
movq %rax, %xmm0
movaps 0x1f594(%rip), %xmm1    # 0x30750
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1f598(%rip), %xmm1    # 0x30760
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x98(%rsp)
movq 0x398(%rsp), %rdi
movslq 0x22c(%rsp), %rsi
callq 0x12680
movsd 0xa0(%rsp), %xmm0
movsd 0x98(%rsp), %xmm2
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rax)
leaq 0x348(%rsp), %rdi
callq 0x122b0
leaq 0x330(%rsp), %rdi
callq 0x122b0
movl $0x0, 0x228(%rsp)
movslq 0x228(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x300(%rsp), %rdi
callq 0x8bf0
movq %rax, %rcx
movq 0x90(%rsp), %rax
cmpq %rcx, %rax
jae 0x11473
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0x88(%rsp)
jmp 0x1128c
movq 0x88(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x80(%rsp)
movslq 0x228(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0xcd80
movq 0x80(%rsp), %rsi
movl (%rax), %edx
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq 0x1d0(%rsp), %rdi
callq *%rax
jmp 0x112d2
leaq 0x1d8(%rsp), %rdi
xorl %esi, %esi
callq 0x224f0
movsd %xmm0, 0x78(%rsp)
jmp 0x112e9
movq 0x388(%rsp), %rdi
callq 0x12660
movq %rax, 0x70(%rsp)
jmp 0x112fd
movq 0x70(%rsp), %rdi
callq 0x12670
movsd %xmm0, 0x68(%rsp)
jmp 0x1130f
movsd 0x78(%rsp), %xmm0
movsd 0x68(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jb 0x11427
movslq 0x228(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0xcd80
movq %rax, %rsi
leaq 0x348(%rsp), %rdi
callq 0x12490
jmp 0x1134c
jmp 0x11450
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x370(%rsp), %rdi
callq 0x6830
jmp 0x11865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x1183e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x11831
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x11737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x24b00
jmp 0x11737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x1172a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x24b00
jmp 0x1172a
movslq 0x228(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0xcd80
movq %rax, %rsi
leaq 0x330(%rsp), %rdi
callq 0x12490
jmp 0x1144e
jmp 0x11450
leaq 0x1d0(%rsp), %rdi
callq 0x24b00
movl 0x228(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x228(%rsp)
jmp 0x11244
leaq 0x348(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x8aa0
movq 0x58(%rsp), %rdi
movq %rax, 0x1b0(%rsp)
callq 0x88f0
movq %rax, 0x1a8(%rsp)
leaq 0x1a7(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x79a0
movq 0x60(%rsp), %rcx
movq 0x1b0(%rsp), %rsi
movq 0x1a8(%rsp), %rdx
leaq 0x1b8(%rsp), %rdi
callq 0x12500
jmp 0x114d5
leaq 0x1b8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
leaq 0x348(%rsp), %rsi
callq 0x12590
movq 0x40(%rsp), %rdi
callq 0x6830
leaq 0x1a7(%rsp), %rdi
callq 0xbb90
leaq 0x330(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8aa0
movq 0x48(%rsp), %rdi
movq %rax, 0x180(%rsp)
callq 0x88f0
movq %rax, 0x178(%rsp)
leaq 0x177(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x79a0
movq 0x50(%rsp), %rcx
movq 0x180(%rsp), %rsi
movq 0x178(%rsp), %rdx
leaq 0x188(%rsp), %rdi
callq 0x12500
jmp 0x11568
leaq 0x188(%rsp), %rdi
movq %rdi, 0x30(%rsp)
leaq 0x330(%rsp), %rsi
callq 0x12590
movq 0x30(%rsp), %rdi
callq 0x6830
leaq 0x177(%rsp), %rdi
callq 0xbb90
movq 0x388(%rsp), %rdi
callq 0x21af0
movq %rax, 0x38(%rsp)
jmp 0x115ad
leaq 0x158(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0xcbb0
jmp 0x115c4
movq 0x38(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x12260
jmp 0x115d8
leaq 0x158(%rsp), %rdi
callq 0x6830
movq 0x388(%rsp), %rdi
callq 0x21af0
movq %rax, 0x28(%rsp)
jmp 0x115f9
movq 0x28(%rsp), %rsi
leaq 0x318(%rsp), %rdi
callq 0x2d680
jmp 0x1160d
movq 0x388(%rsp), %rdi
callq 0x21b00
movq %rax, 0x20(%rsp)
jmp 0x11621
leaq 0x140(%rsp), %rdi
leaq 0x330(%rsp), %rsi
callq 0xcbb0
jmp 0x11638
movq 0x20(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x12260
jmp 0x1164c
leaq 0x140(%rsp), %rdi
callq 0x6830
movq 0x388(%rsp), %rdi
callq 0x21b00
movq %rax, 0x18(%rsp)
jmp 0x1166d
movq 0x18(%rsp), %rsi
leaq 0x318(%rsp), %rdi
callq 0x2d680
jmp 0x11681
leaq 0x288(%rsp), %rdi
callq 0x16d70
leaq 0x300(%rsp), %rdi
callq 0x6830
jmp 0x11749
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x1a7(%rsp), %rdi
callq 0xbb90
jmp 0x1172a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x177(%rsp), %rdi
callq 0xbb90
jmp 0x1172a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x6830
jmp 0x1172a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x6830
leaq 0x288(%rsp), %rdi
callq 0x16d70
leaq 0x300(%rsp), %rdi
callq 0x6830
jmp 0x11831
leaq 0x128(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x67b0
movq 0x8(%rsp), %rsi
movq 0x388(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rsp), %rdi
callq 0xcbb0
jmp 0x1177c
movq 0x10(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x12260
jmp 0x11790
leaq 0x110(%rsp), %rdi
callq 0x6830
leaq 0x128(%rsp), %rdi
callq 0x6830
jmp 0x10fc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
jmp 0x117e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x368(%rsp)
movl %eax, 0x364(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6830
leaq 0x128(%rsp), %rdi
callq 0x6830
jmp 0x11831
leaq 0x318(%rsp), %rdi
callq 0x2d670
leaq 0x330(%rsp), %rdi
callq 0x6830
leaq 0x348(%rsp), %rdi
callq 0x6830
leaq 0x360(%rsp), %rdi
callq 0xd410
addq $0x3a8, %rsp            # imm = 0x3A8
retq
leaq 0x318(%rsp), %rdi
callq 0x2d670
leaq 0x330(%rsp), %rdi
callq 0x6830
leaq 0x348(%rsp), %rdi
callq 0x6830
leaq 0x360(%rsp), %rdi
callq 0xd410
movq 0x368(%rsp), %rdi
callq 0x33e0
nopw %cs:(%rax,%rax)