// File: /workspace/github_cpp_makefile_star2_O1/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, 0x68(%rsp)
movq 0x50(%rdi), %rbx
movl $0x1, 0xc(%rsp)
movq %rdi, 0x60(%rsp)
movq 0x8(%rdi), %rsi
leaq 0x118(%rsp), %rdi
callq 0x135c8
leaq 0xe8(%rsp), %rdi
callq 0x1355c
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x155dc
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x7b1c
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0x7392
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0xbdac
movl %eax, 0x58(%rbx)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xbdc9
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x15604
leaq 0xd0(%rsp), %r15
leaq 0xb8(%rsp), %r12
leaq 0x140(%rsp), %r13
leaq 0x48(%rsp), %rbp
movq %r15, %rdi
callq 0x1564e
testb %al, %al
jne 0xc07d
movq %r15, %rdi
callq 0x1563c
movq %rax, %rbx
movq %rax, %rdi
callq 0x110f6
testb %al, %al
jne 0xbff7
movq %rbx, %rdi
callq 0x111f4
movl %eax, 0x104(%rsp)
movq %rbx, %rdi
callq 0x111fe
movsd %xmm0, 0x108(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x7b1c
movl 0x104(%rsp), %ecx
movsd 0x108(%rsp), %xmm0
movq %r13, %rdi
leaq 0x118(%rsp), %rsi
movq %rbp, %rdx
callq 0x14006
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
callq 0x1346c
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
sarq $0x2, %rax
movq %rax, %xmm1
punpckldq 0xa849(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa851(%rip), %xmm1     # 0x166f0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movslq 0x104(%rsp), %rax
movq 0x68(%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 0x60(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0xe8(%rsp), %rsi
movq %rbp, %rdx
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0xd616
movq %rbx, %rdi
callq 0x11108
movq %rax, %r14
leaq 0x88(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7b1c
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x7392
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0xbf3c
movl %eax, 0x58(%r14)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xbf59
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x11108
movq %r15, %rdi
movq %rax, %rsi
callq 0x15604
movq %rbx, %rdi
callq 0x1110e
movq %rax, %r14
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7b1c
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0x7392
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0xbfab
movl %eax, 0x58(%r14)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xbfc5
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x1110e
movq %r15, %rdi
movq %rax, %rsi
callq 0x15604
movq %r13, %rdi
callq 0xc428
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xbff7
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
xorps %xmm0, %xmm0
movaps %xmm0, 0x140(%rsp)
movq $0x0, 0x150(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x7b1c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7392
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0xc03a
movl %eax, 0x58(%rbx)
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0xc057
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xbdf6
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0xbdf6
leaq 0xd0(%rsp), %rdi
callq 0x155ec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc0a1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc0b8
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x1361e
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xc1b5
movq 0xb0(%rsp), %rsi
jmp 0xc1ad
movq %rax, %rbx
jmp 0xc1c2
movq %rax, %rbx
jmp 0xc1f0
jmp 0xc189
movq %rax, %rbx
jmp 0xc19e
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xc191
movq 0x80(%rsp), %rsi
jmp 0xc143
jmp 0xc189
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xc191
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0xc191
movq %rax, %rbx
jmp 0xc172
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0xc172
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xc1b5
movq 0x150(%rsp), %rsi
jmp 0xc1ad
movq %rax, %rbx
jmp 0xc1b5
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xc428
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xc1b5
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xd0(%rsp), %rdi
callq 0x155ec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc1d9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc1f0
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x1361e
movq %rbx, %rdi
callq 0x3320
nop