// File: /workspace/github_cpp_makefile_star2_O2/0asa[P]TTree-source/ClassicTree.cpp
// Function: ClassicTree::computeVimp(std::vector<float, std::allocator<float>>&, std::vector<unsigned int, std::allocator<unsigned int>>&)
void ClassicTree::computeVimp(std::vector<float> &vim, std::vector<unsigned int> &set) {
	Node* n = root;
	Score sc;
	Scorer s(db);
	ScoreInfo si;
	std::vector<unsigned int> left;
	std::vector<unsigned int> right;
	Stack stack;
	n->setLS(set); // pushing the set on which we want to compute the variable importances
	stack.push(n);
	while (!stack.empty()) {
		n = stack.pop();
		if (!n->isLeaf()) {
			si.attribute = n->getAtt();
			si.threshold = n->getTh();
			std::vector<unsigned int> ss = n->getLS();
			ContingencyTable ct = s.getContingencyTable(ss,si.attribute,si.threshold);
			vim[si.attribute] += sc.getMutualInfo(ct) * ss.size();
			db->getLRSet(si,ss,left,right); // compute left and right partition
			//fprintf(stderr,"ATT: %d %f %f %d %d %d\n",si.attribute,si.threshold,sc.getMutualInfo(ct),ss.size(),left.size(),right.size());
			// push left and right
			n->getLeft()->setLS(left); stack.push(n->getLeft());
			n->getRight()->setLS(right); stack.push(n->getRight());			
		}
		// empty set inside parent node
		std::vector<unsigned int> empty;
		n->setLS(empty);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdx, %r14
movq %rsi, 0x50(%rsp)
movq 0x50(%rdi), %rbx
movl $0x1, 0xc(%rsp)
movq %rdi, 0x48(%rsp)
movq 0x8(%rdi), %rsi
leaq 0xd0(%rsp), %rdi
callq 0x10648
leaq 0xa0(%rsp), %rdi
callq 0x105b4
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x12418
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x6c64
leaq 0x88(%rsp), %rsi
movq %rbx, %rdi
callq 0x8884
leaq 0x88(%rsp), %rdi
callq 0x6886
leaq 0x70(%rsp), %rdi
movq %rbx, %rsi
callq 0x1242a
leaq 0x70(%rsp), %r15
leaq 0x140(%rsp), %r13
leaq 0x128(%rsp), %rbp
leaq 0x110(%rsp), %r12
movq %r15, %rdi
callq 0x12460
testb %al, %al
jne 0xa652
movq %r15, %rdi
callq 0x1244e
movq %rax, %rbx
movq %rax, %rdi
callq 0xe4fa
testb %al, %al
jne 0xa60b
movq %rbx, %rdi
callq 0xe5f0
movl %eax, 0xbc(%rsp)
movq %rbx, %rdi
callq 0xe5fa
movsd %xmm0, 0xc0(%rsp)
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6c64
movl 0xbc(%rsp), %ecx
movsd 0xc0(%rsp), %xmm0
movq %r13, %rdi
leaq 0xd0(%rsp), %rsi
movq %r14, %rdx
callq 0x10f0e
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
callq 0x104d4
movq 0x60(%rsp), %rax
subq 0x58(%rsp), %rax
sarq $0x2, %rax
movq %rax, %xmm1
punpckldq 0x91c8(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x91d0(%rip), %xmm1     # 0x136f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movslq 0xbc(%rsp), %rax
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
cvtss2sd (%rcx,%rax,4), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rcx,%rax,4)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x58(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0xb54c
movq %rbx, %rdi
callq 0xe50c
movq %rax, %r14
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x6c64
movq %r14, %rdi
movq %rbp, %r14
movq %rbp, %rsi
callq 0x8884
movq %r14, %rdi
callq 0x6886
movq %rbx, %rdi
callq 0xe50c
movq %r15, %rdi
movq %rax, %rsi
callq 0x1242a
movq %rbx, %rdi
callq 0xe512
movq %rax, %r14
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x6c64
movq %r14, %rdi
movq %r12, %r14
movq %r12, %rsi
callq 0x8884
movq %r14, %rdi
callq 0x6886
movq %rbx, %rdi
callq 0xe512
movq %r15, %rdi
movq %rax, %rsi
callq 0x1242a
movq %r13, %rdi
callq 0xa982
leaq 0x58(%rsp), %rdi
callq 0x6886
xorps %xmm0, %xmm0
movaps %xmm0, 0x140(%rsp)
andq $0x0, 0x150(%rsp)
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x6c64
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8884
movq %r14, %rdi
callq 0x6886
movq %r13, %rdi
callq 0x6886
jmp 0xa472
leaq 0x70(%rsp), %rdi
callq 0x12424
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0xd0(%rsp), %rdi
callq 0x1068c
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0xa70a
movq %rax, %rbx
jmp 0xa719
movq %rax, %rbx
jmp 0xa72d
jmp 0xa6f0
movq %rax, %rbx
jmp 0xa705
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0xa6ca
jmp 0xa6f0
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x6886
jmp 0xa6f8
movq %rax, %rbx
jmp 0xa6e6
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x6886
leaq 0x140(%rsp), %rdi
jmp 0xa70a
movq %rax, %rbx
jmp 0xa70f
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xa982
leaq 0x58(%rsp), %rdi
callq 0x6886
leaq 0x70(%rsp), %rdi
callq 0x12424
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0xd0(%rsp), %rdi
callq 0x1068c
movq %rbx, %rdi
callq 0x3330