// File: /workspace/github_cpp_makefile_star2_O3/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 0xd8(%rsp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x7b86
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73dc
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0x8f58
movl %eax, 0x58(%rbx)
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8f75
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movl $0x1, 0x54(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x1554c
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x15574
leaq 0xf8(%rsp), %r14
leaq 0xc0(%rsp), %rbp
leaq 0x150(%rsp), %r15
leaq 0xf0(%rsp), %rbx
movq %rbp, %rdi
callq 0x155be
testb %al, %al
jne 0x9402
movq %rbp, %rdi
callq 0x155ac
movq %rax, %r13
movq %rax, %rdi
callq 0x110c6
testb %al, %al
jne 0x9371
leaq 0x58(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x7b86
movq 0x30(%r13), %rax
movq 0x18(%rax), %rsi
movq (%rsi), %rax
movq %rbx, %rdi
movq %r12, %rdx
callq *0x20(%rax)
movq 0x30(%r13), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x12a64
movq %rbx, %rdi
callq 0x12826
movq 0x30(%r13), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0xc596
movq 0x30(%r13), %rdi
callq 0x156a0
movl %eax, %r15d
leaq 0x54(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x133ee
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x2, %rdx
movq %rdx, %xmm1
punpckldq 0xd652(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xd65a(%rip), %xmm1     # 0x166f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movslq %r15d, %rdx
movq 0x70(%rsp), %rsi
movq (%rsi), %rsi
xorps %xmm1, %xmm1
cvtss2sd (%rsi,%rdx,4), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsi,%rdx,4)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
cmpq %rsi, %rdx
je 0x90dd
movq %rsi, 0x38(%rsp)
movq %rsi, %rdx
movq 0x10(%rsp), %rdi
cmpq %rdi, 0x18(%rsp)
je 0x90ee
movq %rdi, 0x18(%rsp)
cmpq %rax, %rcx
je 0x91a5
movq %rbp, %r12
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x30(%r13), %rcx
movq 0x18(%rcx), %rsi
movl (%rax,%r15), %edx
movq (%rsi), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
xorl %esi, %esi
callq 0x11528
movq 0x30(%r13), %rax
movq 0x58(%rsp), %rdx
addq %r15, %rdx
ucomisd 0x8(%rax), %xmm0
jae 0x9154
movq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rsi
je 0x916a
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rax)
jmp 0x916f
movq 0x38(%rsp), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rsi
jne 0x9147
callq 0x9f8a
movq %rbx, %rdi
callq 0x12826
incq %rbp
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
addq $0x4, %r15
cmpq %rbp, %rcx
ja 0x90ff
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r12, %rbp
movq %rbx, %rdi
leaq 0xf(%rsp), %rcx
callq 0x9dc2
movq 0x100(%rsp), %rax
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rcx
movq 0x40(%rsp), %rsi
movq %rsi, 0x100(%rsp)
movapd 0xf0(%rsp), %xmm0
movq %rdi, 0xf0(%rsp)
movq %rcx, 0xf8(%rsp)
movapd %xmm0, 0x30(%rsp)
movq %rax, 0x40(%rsp)
testq %rdi, %rdi
je 0x9202
subq %rdi, %rsi
callq 0x3210
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
leaq 0xf(%rsp), %rcx
callq 0x9dc2
movq 0x100(%rsp), %rax
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rsi
movq %rsi, 0x100(%rsp)
movapd 0xf0(%rsp), %xmm0
movq %rdi, 0xf0(%rsp)
movq %rcx, 0xf8(%rsp)
movapd %xmm0, 0x10(%rsp)
movq %rax, 0x20(%rsp)
testq %rdi, %rdi
je 0x9269
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x110d8
movq %rax, %r15
leaq 0x90(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7b86
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x73dc
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x92ae
movl %eax, 0x58(%r15)
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x92cb
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x110d8
movq %rbp, %rdi
movq %rax, %rsi
callq 0x15574
movq %r13, %rdi
callq 0x110de
movq %rax, %r15
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7b86
movq %r15, %rdi
leaq 0x78(%rsp), %rsi
callq 0x73dc
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x931d
movl %eax, 0x58(%r15)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x9337
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x110de
movq %rbp, %rdi
movq %rax, %rsi
callq 0x15574
leaq 0x150(%rsp), %r15
movq %r15, %rdi
callq 0xc430
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x9371
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
xorps %xmm0, %xmm0
movaps %xmm0, 0x150(%rsp)
movq $0x0, 0x160(%rsp)
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x7b86
movq %r13, %rdi
movq %r12, %rsi
callq 0x73dc
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x2, %rax
movl 0x58(%r13), %ecx
cmpq %rcx, %rax
jbe 0x93bf
movl %eax, 0x58(%r13)
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x93dc
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x8fd3
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x8fd3
leaq 0xc0(%rsp), %rdi
callq 0x1555c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9426
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x943d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x951f
movq %rax, %rbx
jmp 0x956c
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x959a
movq 0xe8(%rsp), %rsi
jmp 0x9592
jmp 0x9526
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x953b
movq 0x88(%rsp), %rsi
jmp 0x94be
jmp 0x9526
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x953b
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x953b
jmp 0x951f
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x12826
jmp 0x9548
movq %rax, %rbx
jmp 0x9548
jmp 0x9526
movq %rax, %rbx
jmp 0x9508
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x9508
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x955f
movq 0x160(%rsp), %rsi
jmp 0x9557
movq %rax, %rbx
jmp 0x955f
jmp 0x9526
movq %rax, %rbx
jmp 0x953b
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x12826
leaq 0x150(%rsp), %rdi
callq 0xc430
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x955f
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xc0(%rsp), %rdi
callq 0x1555c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9583
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x959a
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x3320