// File: 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:
subq $0x268, %rsp            # imm = 0x268
movq %rdi, 0x260(%rsp)
movq %rsi, 0x258(%rsp)
movq %rdx, 0x250(%rsp)
movq 0x260(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x50(%rax), %rax
movq %rax, 0x248(%rsp)
leaq 0x244(%rsp), %rdi
callq 0xcdf0
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0x218(%rsp), %rdi
callq 0x26d90
jmp 0x16183
leaq 0x1d8(%rsp), %rdi
callq 0x26ba0
jmp 0x16192
leaq 0x1c0(%rsp), %rdi
callq 0x67b0
leaq 0x1a8(%rsp), %rdi
callq 0x67b0
leaq 0x190(%rsp), %rdi
callq 0x2d660
jmp 0x161bb
movq 0x248(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x250(%rsp), %rsi
leaq 0x178(%rsp), %rdi
callq 0xcbb0
jmp 0x161df
movq 0x78(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x12260
jmp 0x161f3
leaq 0x178(%rsp), %rdi
callq 0x6830
movq 0x248(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0x2d680
jmp 0x16217
jmp 0x16219
leaq 0x190(%rsp), %rdi
callq 0x2d720
movb %al, 0x77(%rsp)
jmp 0x1622c
movb 0x77(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1623b
jmp 0x166aa
leaq 0x190(%rsp), %rdi
callq 0x2d6d0
movq %rax, 0x68(%rsp)
jmp 0x1624f
movq 0x68(%rsp), %rax
movq %rax, 0x248(%rsp)
movq 0x248(%rsp), %rdi
callq 0x21aa0
movb %al, 0x67(%rsp)
jmp 0x1626f
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0x165fe
jmp 0x1627d
movq 0x248(%rsp), %rdi
callq 0x21cd0
movl %eax, 0x60(%rsp)
jmp 0x16290
movl 0x60(%rsp), %eax
movl %eax, 0x1f4(%rsp)
movq 0x248(%rsp), %rdi
callq 0x21cf0
movsd %xmm0, 0x58(%rsp)
jmp 0x162b0
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x1f8(%rsp)
movq 0x248(%rsp), %rdi
callq 0xcba0
movq %rax, 0x50(%rsp)
jmp 0x162d3
movq 0x50(%rsp), %rsi
leaq 0x160(%rsp), %rdi
callq 0xcbb0
jmp 0x162e7
movl 0x1f4(%rsp), %ecx
movsd 0x1f8(%rsp), %xmm0
leaq 0xe8(%rsp), %rdi
leaq 0x218(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x281a0
jmp 0x16316
leaq 0x244(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x26a40
movsd %xmm0, 0x48(%rsp)
jmp 0x16333
leaq 0x160(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x8bf0
movq %rax, %xmm0
movaps 0x1a3ff(%rip), %xmm1    # 0x30750
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1a403(%rip), %xmm1    # 0x30760
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0x258(%rsp), %rdi
movslq 0x1f4(%rsp), %rsi
callq 0x12680
movsd 0x48(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
movq 0x40(%rsp), %rdx
movq %rax, %rcx
movq 0x80(%rsp), %rax
movss (%rcx), %xmm1
cvtss2sd %xmm1, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rcx)
movq 0x8(%rax), %rdi
leaq 0x1d8(%rsp), %rsi
leaq 0x1c0(%rsp), %rcx
leaq 0x1a8(%rsp), %r8
callq 0x19420
jmp 0x163de
movq 0x248(%rsp), %rdi
callq 0x21af0
movq %rax, 0x30(%rsp)
jmp 0x163f2
leaq 0xd0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0xcbb0
jmp 0x16409
movq 0x30(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x12260
jmp 0x1641d
leaq 0xd0(%rsp), %rdi
callq 0x6830
movq 0x248(%rsp), %rdi
callq 0x21af0
movq %rax, 0x28(%rsp)
jmp 0x1643e
movq 0x28(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0x2d680
jmp 0x16452
movq 0x248(%rsp), %rdi
callq 0x21b00
movq %rax, 0x20(%rsp)
jmp 0x16466
leaq 0xb8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0xcbb0
jmp 0x1647d
movq 0x20(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x12260
jmp 0x16491
leaq 0xb8(%rsp), %rdi
callq 0x6830
movq 0x248(%rsp), %rdi
callq 0x21b00
movq %rax, 0x18(%rsp)
jmp 0x164b2
movq 0x18(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0x2d680
jmp 0x164c6
leaq 0xe8(%rsp), %rdi
callq 0x16d70
leaq 0x160(%rsp), %rdi
callq 0x6830
jmp 0x165fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x16741
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x16734
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x1670d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x16700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0x6830
jmp 0x16700
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x165ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x165df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6830
jmp 0x165df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x6830
leaq 0xe8(%rsp), %rdi
callq 0x16d70
leaq 0x160(%rsp), %rdi
callq 0x6830
jmp 0x16700
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x67b0
movq 0x8(%rsp), %rsi
movq 0x248(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xcbb0
jmp 0x16631
movq 0x10(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x12260
jmp 0x16645
leaq 0x88(%rsp), %rdi
callq 0x6830
leaq 0xa0(%rsp), %rdi
callq 0x6830
jmp 0x16219
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
jmp 0x1669b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x210(%rsp)
movl %eax, 0x20c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x6830
leaq 0xa0(%rsp), %rdi
callq 0x6830
jmp 0x16700
leaq 0x190(%rsp), %rdi
callq 0x2d670
leaq 0x1a8(%rsp), %rdi
callq 0x6830
leaq 0x1c0(%rsp), %rdi
callq 0x6830
leaq 0x1d8(%rsp), %rdi
callq 0x12640
leaq 0x218(%rsp), %rdi
callq 0x26e10
leaq 0x244(%rsp), %rdi
callq 0xd410
addq $0x268, %rsp            # imm = 0x268
retq
leaq 0x190(%rsp), %rdi
callq 0x2d670
leaq 0x1a8(%rsp), %rdi
callq 0x6830
leaq 0x1c0(%rsp), %rdi
callq 0x6830
leaq 0x1d8(%rsp), %rdi
callq 0x12640
leaq 0x218(%rsp), %rdi
callq 0x26e10
leaq 0x244(%rsp), %rdi
callq 0xd410
movq 0x210(%rsp), %rdi
callq 0x33e0
nopl (%rax,%rax)