// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rsi, 0x70(%rsp)
movq 0x50(%rdi), %rbx
leaq 0x120(%rsp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x6c64
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8884
leaq 0x120(%rsp), %rdi
callq 0x6886
movl $0x1, 0x54(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x12418
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x1242a
leaq 0x78(%rsp), %r14
leaq 0x150(%rsp), %r13
leaq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %rbp
leaq 0x30(%rsp), %r12
movq %r14, %rdi
callq 0x12460
testb %al, %al
jne 0x825d
movq %r14, %rdi
callq 0x1244e
movq %rax, %r15
movq %rax, %rdi
callq 0xe4fa
testb %al, %al
jne 0x820e
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x6c64
movq 0x30(%r15), %rax
movq 0x18(%rax), %rsi
movq (%rsi), %rax
movq %rbx, %rdi
movq %r14, %rdx
callq *0x20(%rax)
movq 0x30(%r15), %rax
movsd 0x8(%rax), %xmm0
movq %r13, %rdi
movq %rbx, %rsi
callq 0xfbe4
movq %rbx, %rdi
callq 0xfa56
movq 0x30(%r15), %rax
movsd 0x8(%rax), %xmm0
movq %r13, %rdi
callq 0xaaae
movq 0x30(%r15), %rdi
callq 0x1255a
movl %eax, %r13d
leaq 0x54(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x104d4
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movq %rdx, %xmm1
punpckldq 0xb6f3(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xb6fb(%rip), %xmm1     # 0x136f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movslq %r13d, %rdx
movq 0x70(%rsp), %rsi
movq (%rsi), %rsi
cvtss2sd (%rsi,%rdx,4), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsi,%rdx,4)
movq 0x30(%rsp), %rdx
cmpq %rdx, 0x38(%rsp)
je 0x8033
movq %rdx, 0x38(%rsp)
movq 0x10(%rsp), %rdx
cmpq %rdx, 0x18(%rsp)
je 0x8044
movq %rdx, 0x18(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x80b2
movq 0x30(%r15), %rcx
movq 0x18(%rcx), %rsi
movl (%rax,%r14,4), %edx
movq (%rsi), %rax
movq %rbx, %rdi
callq *0x10(%rax)
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xe8d2
movq 0x30(%r15), %rax
movq 0x58(%rsp), %rsi
addq %r13, %rsi
ucomisd 0x8(%rax), %xmm0
movq %r12, %rdi
cmovbq %rbp, %rdi
callq 0x8982
movq %rbx, %rdi
callq 0xfa56
incq %r14
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
addq $0x4, %r13
jmp 0x804a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
leaq 0xf(%rsp), %r14
movq %r14, %rcx
callq 0x89a0
movq 0xa0(%rsp), %rax
movapd 0x30(%rsp), %xmm0
movq 0x40(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movaps 0x90(%rsp), %xmm1
movapd %xmm0, 0x90(%rsp)
movaps %xmm1, 0x30(%rsp)
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
callq 0x6886
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x89a0
leaq 0x78(%rsp), %r14
movq 0xa0(%rsp), %rax
movapd 0x10(%rsp), %xmm0
movq 0x20(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movaps 0x90(%rsp), %xmm1
movapd %xmm0, 0x90(%rsp)
movaps %xmm1, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
callq 0x6886
movq %r15, %rdi
callq 0xe50c
movq %rax, %r13
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
callq 0x6c64
movq %r13, %rdi
leaq 0x108(%rsp), %r13
movq %r13, %rsi
callq 0x8884
movq %r13, %rdi
callq 0x6886
movq %r15, %rdi
callq 0xe50c
movq %r14, %rdi
movq %rax, %rsi
callq 0x1242a
movq %r15, %rdi
callq 0xe512
movq %rax, %r13
leaq 0xf0(%rsp), %rdi
movq %rbp, %rsi
callq 0x6c64
movq %r13, %rdi
leaq 0xf0(%rsp), %r13
movq %r13, %rsi
callq 0x8884
movq %r13, %rdi
callq 0x6886
movq %r15, %rdi
callq 0xe512
movq %r14, %rdi
movq %rax, %rsi
callq 0x1242a
leaq 0x150(%rsp), %r13
movq %r13, %rdi
callq 0xa982
leaq 0x58(%rsp), %rdi
callq 0x6886
xorps %xmm0, %xmm0
movaps %xmm0, 0x150(%rsp)
andq $0x0, 0x160(%rsp)
movq %r13, %rsi
leaq 0x138(%rsp), %r13
movq %r13, %rdi
callq 0x6c64
movq %r15, %rdi
movq %r13, %rsi
callq 0x8884
movq %r13, %rdi
callq 0x6886
leaq 0x150(%rsp), %r13
movq %r13, %rdi
callq 0x6886
jmp 0x7f32
leaq 0x78(%rsp), %rdi
callq 0x12424
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8304
movq %rax, %rbx
jmp 0x8341
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x8350
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x82c1
jmp 0x830b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x6886
jmp 0x8320
jmp 0x830b
jmp 0x8304
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xfa56
jmp 0x832d
movq %rax, %rbx
jmp 0x832d
jmp 0x830b
movq %rax, %rbx
jmp 0x82fa
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x6886
leaq 0x150(%rsp), %rdi
jmp 0x8332
movq %rax, %rbx
jmp 0x8337
jmp 0x830b
movq %rax, %rbx
jmp 0x8320
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xfa56
leaq 0x150(%rsp), %rdi
callq 0xa982
leaq 0x58(%rsp), %rdi
callq 0x6886
leaq 0x78(%rsp), %rdi
callq 0x12424
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
movq %rbx, %rdi
callq 0x3330
nop