// File: /workspace/github_cpp_makefile_star2_O1/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 0x7b1c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7392
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0x8f2e
movl %eax, 0x58(%rbx)
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8f4b
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movl $0x1, 0x6c(%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 0x155dc
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x15604
leaq 0xf8(%rsp), %r14
leaq 0xc0(%rsp), %rbp
leaq 0x78(%rsp), %r12
leaq 0x150(%rsp), %r15
leaq 0xf0(%rsp), %rbx
movq %rbp, %rdi
callq 0x1564e
testb %al, %al
jne 0x93db
movq %rbp, %rdi
callq 0x1563c
movq %rax, %r13
movq %rax, %rdi
callq 0x110f6
testb %al, %al
jne 0x9355
leaq 0x50(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x7b1c
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 0x12abe
movq %rbx, %rdi
callq 0x1288e
movq 0x30(%r13), %rax
movsd 0x8(%rax), %xmm0
movq %r15, %rdi
callq 0xc58e
movq 0x30(%r13), %rdi
callq 0x15732
movl %eax, %r15d
leaq 0x6c(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x1346c
movq 0x58(%rsp), %rax
subq 0x50(%rsp), %rax
sarq $0x2, %rax
movq %rax, %xmm1
punpckldq 0xd67d(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xd685(%rip), %xmm1     # 0x166f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movslq %r15d, %rax
movq 0x70(%rsp), %rcx
movq (%rcx), %rcx
xorps %xmm1, %xmm1
cvtss2sd (%rcx,%rax,4), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rcx,%rax,4)
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x90ac
movq %rax, 0x38(%rsp)
movq %rbp, %r12
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x90c0
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rax
cmpq %rax, 0x58(%rsp)
je 0x916e
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 0x11558
movq 0x30(%r13), %rax
movq 0x50(%rsp), %rdx
addq %r15, %rdx
ucomisd 0x8(%rax), %xmm0
jae 0x912a
movq 0x18(%rsp), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rsi
je 0x9140
movl (%rdx), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, (%rax)
jmp 0x9145
movq 0x38(%rsp), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rsi
jne 0x911d
callq 0x9f7a
movq %rbx, %rdi
callq 0x1288e
incq %rbp
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
addq $0x4, %r15
cmpq %rbp, %rcx
ja 0x90d5
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbx, %rdi
leaq 0xf(%rsp), %rcx
callq 0x9da0
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
movq %r12, %rbp
je 0x91d8
subq %rdi, %rsi
callq 0x3210
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
leaq 0xf(%rsp), %rcx
callq 0x9da0
leaq 0x78(%rsp), %r12
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 0x9244
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x11108
movq %rax, %r15
leaq 0xa8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7b1c
movq %r15, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x7392
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x9289
movl %eax, 0x58(%r15)
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x92a6
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x11108
movq %rbp, %rdi
movq %rax, %rsi
callq 0x15604
movq %r13, %rdi
callq 0x1110e
movq %rax, %r15
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7b1c
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
callq 0x7392
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x92fe
movl %eax, 0x58(%r15)
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x931b
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r13, %rdi
callq 0x1110e
movq %rbp, %rdi
movq %rax, %rsi
callq 0x15604
leaq 0x150(%rsp), %r15
movq %r15, %rdi
callq 0xc428
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9355
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
xorps %xmm0, %xmm0
movaps %xmm0, 0x150(%rsp)
movq $0x0, 0x160(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x7b1c
movq %r13, %rdi
movq %r12, %rsi
callq 0x7392
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x2, %rax
movl 0x58(%r13), %ecx
cmpq %rcx, %rax
jbe 0x939b
movl %eax, 0x58(%r13)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x93b5
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x8fae
movq 0x160(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x8fae
leaq 0xc0(%rsp), %rdi
callq 0x155ec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x93ff
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9416
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 0x94f8
movq %rax, %rbx
jmp 0x9545
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x9573
movq 0xe8(%rsp), %rsi
jmp 0x956b
jmp 0x94ff
movq %rax, %rbx
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x9514
movq 0xa0(%rsp), %rsi
jmp 0x949a
jmp 0x94ff
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x9514
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x9514
jmp 0x94f8
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1288e
jmp 0x9521
movq %rax, %rbx
jmp 0x9521
jmp 0x94ff
movq %rax, %rbx
jmp 0x94e1
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x94e1
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x150(%rsp), %rdi
testq %rdi, %rdi
je 0x9538
movq 0x160(%rsp), %rsi
jmp 0x9530
movq %rax, %rbx
jmp 0x9538
jmp 0x94ff
movq %rax, %rbx
jmp 0x9514
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1288e
leaq 0x150(%rsp), %rdi
callq 0xc428
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x9538
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xc0(%rsp), %rdi
callq 0x155ec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x955c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x9573
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x3320
nop