// File: /workspace/github_cpp_makefile_star2_O3/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 0x1354c
leaq 0xe8(%rsp), %rdi
callq 0x134e0
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 0x1554c
leaq 0xa0(%rsp), %rdi
movq %r14, %rsi
callq 0x7b86
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0x73dc
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0xbdb4
movl %eax, 0x58(%rbx)
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xbdd1
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xd0(%rsp), %rdi
movq %rbx, %rsi
callq 0x15574
leaq 0xd0(%rsp), %r15
leaq 0xb8(%rsp), %r12
leaq 0x140(%rsp), %r13
leaq 0x48(%rsp), %rbp
movq %r15, %rdi
callq 0x155be
testb %al, %al
jne 0xc085
movq %r15, %rdi
callq 0x155ac
movq %rax, %rbx
movq %rax, %rdi
callq 0x110c6
testb %al, %al
jne 0xbfff
movq %rbx, %rdi
callq 0x111c4
movl %eax, 0x104(%rsp)
movq %rbx, %rdi
callq 0x111ce
movsd %xmm0, 0x108(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x7b86
movl 0x104(%rsp), %ecx
movsd 0x108(%rsp), %xmm0
movq %r13, %rdi
leaq 0x118(%rsp), %rsi
movq %rbp, %rdx
callq 0x13f82
leaq 0xc(%rsp), %rdi
movq %r13, %rsi
callq 0x133ee
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
sarq $0x2, %rax
movq %rax, %xmm1
punpckldq 0xa841(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa849(%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 0xd636
movq %rbx, %rdi
callq 0x110d8
movq %rax, %r14
leaq 0x88(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7b86
movq %r14, %rdi
leaq 0x88(%rsp), %rsi
callq 0x73dc
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0xbf44
movl %eax, 0x58(%r14)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xbf61
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x110d8
movq %r15, %rdi
movq %rax, %rsi
callq 0x15574
movq %rbx, %rdi
callq 0x110de
movq %rax, %r14
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7b86
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
callq 0x73dc
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0xbfb3
movl %eax, 0x58(%r14)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xbfcd
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %rbx, %rdi
callq 0x110de
movq %r15, %rdi
movq %rax, %rsi
callq 0x15574
movq %r13, %rdi
callq 0xc430
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xbfff
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 0x7b86
movq %rbx, %rdi
movq %r12, %rsi
callq 0x73dc
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movl 0x58(%rbx), %ecx
cmpq %rcx, %rax
jbe 0xc042
movl %eax, 0x58(%rbx)
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0xc05f
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xbdfe
movq 0x150(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0xbdfe
leaq 0xd0(%rsp), %rdi
callq 0x1555c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc0a9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc0c0
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x13590
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 0xc1bd
movq 0xb0(%rsp), %rsi
jmp 0xc1b5
movq %rax, %rbx
jmp 0xc1ca
movq %rax, %rbx
jmp 0xc1f8
jmp 0xc191
movq %rax, %rbx
jmp 0xc1a6
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0xc199
movq 0x80(%rsp), %rsi
jmp 0xc14b
jmp 0xc191
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xc199
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0xc199
movq %rax, %rbx
jmp 0xc17a
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0xc17a
movq 0xc8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x140(%rsp), %rdi
testq %rdi, %rdi
je 0xc1bd
movq 0x150(%rsp), %rsi
jmp 0xc1b5
movq %rax, %rbx
jmp 0xc1bd
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xc430
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0xc1bd
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xd0(%rsp), %rdi
callq 0x1555c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xc1e1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xc1f8
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0x118(%rsp), %rdi
callq 0x13590
movq %rbx, %rdi
callq 0x3320
nop