// File: 0asa[P]TTree-source/ClassicTree.cpp
// Function: ClassicTree::learnET()
double ClassicTree::learnET() {
	clock_t clock_start = clock();
	Scorer s(db);
	std::vector<unsigned int> lsleft;
	std::vector<unsigned int> lsright;
	RandomStack stack; // IMPORTANT FOR TTREES WITH INTERNAL ET
	root = new Node();	root->setLS((*ls));	stack.push(root);
	while (!stack.empty() && complexity < maxcomplexity) {
		Node *n = stack.pop();
		std::vector<unsigned int> set = n->getLS();
		if (set.size() >= nmin) {
			std::vector<unsigned int> kcand;
			if (k > 0)
				kcand = Sampler::random((*cand),k);
			else
				kcand = (*cand); 
			ScoreInfo si = s.getRandScore(set,kcand);
			if (si.score > 0) {
				db->getLRSet(si,set,lsleft,lsright);
				n->setTest(si);
				Node *left  = new Node();	left->setParent(n);
				left->setDepth(n->getDepth()+1); // 09-07-2012
				left->setLS(lsleft);	n->setLeft(left);	stack.push(left);
				Node *right = new Node();	right->setParent(n);
				right->setDepth(n->getDepth()+1); // 09-07-2012
				right->setLS(lsright);	n->setRight(right);	stack.push(right);
				if (maxdepth < n->getDepth()+1) { maxdepth = n->getDepth()+1; }
				complexity++;
				// BEGIN-02-08-2012 : all nmin at once
				// need to attach vote at each node
				std::vector<double> vote(2,0.0);
				for (int i = 0 ; i < set.size() ; ++i)
					vote[db->getOutput(set[i])] += db->getWeight(set[i]);
				for (int i = 0 ; i < vote.size() ; ++i) 
					vote[i] /= set.size();
				n->setVote(vote);
				// END-02-08-2012
				//#ifdef NOLSFORTT // LS STORAGE ANNULATION
				std::vector<unsigned int> ls_null; n->setLS(ls_null);
				//#endif
			}
		}
	}
	// Clearing sets
	std::vector<unsigned int>().swap(lsleft);
	std::vector<unsigned int>().swap(lsright);
	createProbsInLeaf();
	return (clock() - clock_start);
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %rdi, 0x300(%rsp)
movq 0x300(%rsp), %rax
movq %rax, 0xf8(%rsp)
callq 0x3180
movq %rax, %rcx
movq 0xf8(%rsp), %rax
movq %rcx, 0x2f8(%rsp)
movq 0x8(%rax), %rsi
leaq 0x2d0(%rsp), %rdi
callq 0x26d90
leaq 0x2b8(%rsp), %rdi
callq 0x67b0
leaq 0x2a0(%rsp), %rdi
callq 0x67b0
leaq 0x288(%rsp), %rdi
callq 0x23980
jmp 0x14d31
movl $0x60, %edi
callq 0x3270
movq %rax, 0xf0(%rsp)
jmp 0x14d45
movq 0xf0(%rsp), %rdi
callq 0x21960
jmp 0x14d54
movq 0xf8(%rsp), %rax
movq 0xf0(%rsp), %rcx
movq %rcx, 0x50(%rax)
movq 0x20(%rax), %rsi
movq 0x50(%rax), %rax
movq %rax, 0xe8(%rsp)
leaq 0x260(%rsp), %rdi
callq 0xcbb0
jmp 0x14d87
movq 0xe8(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x12260
jmp 0x14d9e
leaq 0x260(%rsp), %rdi
callq 0x6830
movq 0xf8(%rsp), %rax
movq 0x50(%rax), %rsi
leaq 0x288(%rsp), %rdi
callq 0x239a0
jmp 0x14dc6
jmp 0x14dc8
leaq 0x288(%rsp), %rdi
callq 0x2d720
movb %al, 0xe7(%rsp)
jmp 0x14dde
movb 0xe7(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xe6(%rsp)
jne 0x14e0d
jmp 0x14df5
movq 0xf8(%rsp), %rcx
movl 0x14(%rcx), %eax
cmpl 0x18(%rcx), %eax
setl %al
movb %al, 0xe6(%rsp)
movb 0xe6(%rsp), %al
testb $0x1, %al
jne 0x14e1d
jmp 0x156c7
leaq 0x288(%rsp), %rdi
callq 0x2d6d0
movq %rax, 0xd8(%rsp)
jmp 0x14e34
movq 0xd8(%rsp), %rax
movq %rax, 0x258(%rsp)
movq 0x258(%rsp), %rdi
callq 0xcba0
movq %rax, 0xd0(%rsp)
jmp 0x14e5b
movq 0xd0(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xcbb0
jmp 0x14e72
leaq 0x240(%rsp), %rdi
callq 0x8bf0
movq 0xf8(%rsp), %rcx
movslq 0x10(%rcx), %rcx
cmpq %rcx, %rax
jb 0x156b5
leaq 0x228(%rsp), %rdi
callq 0x67b0
movq 0xf8(%rsp), %rax
cmpl $0x0, 0x58(%rax)
jbe 0x14f94
movq 0xf8(%rsp), %rax
movq 0x30(%rax), %rsi
movl 0x58(%rax), %edx
leaq 0x210(%rsp), %rdi
callq 0x122d0
jmp 0x14ed1
leaq 0x228(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x6800
leaq 0x210(%rsp), %rdi
callq 0x6830
jmp 0x14fb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x157cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x157bf
movq 0xf0(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x157bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x6830
jmp 0x157bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x15696
movq 0xf8(%rsp), %rax
movq 0x30(%rax), %rsi
leaq 0x228(%rsp), %rdi
callq 0x90f0
jmp 0x14faf
jmp 0x14fb1
leaq 0x1e0(%rsp), %rdi
leaq 0x2d0(%rsp), %rsi
leaq 0x240(%rsp), %rdx
leaq 0x228(%rsp), %rcx
callq 0x16980
jmp 0x14fd8
movsd 0x208(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1566d
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x1e0(%rsp), %rsi
leaq 0x240(%rsp), %rdx
leaq 0x2b8(%rsp), %rcx
leaq 0x2a0(%rsp), %r8
callq 0x19420
jmp 0x15021
movq 0x258(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x21b10
jmp 0x15038
movl $0x60, %edi
callq 0x3270
movq %rax, 0xc8(%rsp)
jmp 0x1504c
movq 0xc8(%rsp), %rdi
callq 0x21960
jmp 0x1505b
movq 0xc8(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq 0x1d8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x21c50
jmp 0x15082
movq 0x1d8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x258(%rsp), %rdi
callq 0x12630
movl %eax, 0xc4(%rsp)
jmp 0x150a8
movq 0xb8(%rsp), %rdi
movl 0xc4(%rsp), %esi
incl %esi
callq 0x12610
jmp 0x150c0
movq 0x1d8(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0x1c0(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0xcbb0
jmp 0x150e7
movq 0xb0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x12260
jmp 0x150fe
leaq 0x1c0(%rsp), %rdi
callq 0x6830
movq 0x258(%rsp), %rdi
movq 0x1d8(%rsp), %rsi
callq 0x21c70
jmp 0x15122
movq 0x1d8(%rsp), %rsi
leaq 0x288(%rsp), %rdi
callq 0x239a0
jmp 0x15139
movl $0x60, %edi
callq 0x3270
movq %rax, 0xa8(%rsp)
jmp 0x1514d
movq 0xa8(%rsp), %rdi
callq 0x21960
jmp 0x1515c
movq 0xa8(%rsp), %rax
movq %rax, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rdi
movq 0x258(%rsp), %rsi
callq 0x21c50
jmp 0x15183
movq 0x1b8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x258(%rsp), %rdi
callq 0x12630
movl %eax, 0xa4(%rsp)
jmp 0x151a9
movq 0x98(%rsp), %rdi
movl 0xa4(%rsp), %esi
incl %esi
callq 0x12610
jmp 0x151c1
movq 0x1b8(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0xcbb0
jmp 0x151e8
movq 0x90(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x12260
jmp 0x151ff
leaq 0x1a0(%rsp), %rdi
callq 0x6830
movq 0x258(%rsp), %rdi
movq 0x1b8(%rsp), %rsi
callq 0x21c90
jmp 0x15223
movq 0x1b8(%rsp), %rsi
leaq 0x288(%rsp), %rdi
callq 0x239a0
jmp 0x1523a
movq 0xf8(%rsp), %rax
movl 0x15c(%rax), %eax
movl %eax, 0x88(%rsp)
movq 0x258(%rsp), %rdi
callq 0x12630
movl %eax, 0x8c(%rsp)
jmp 0x15265
movl 0x88(%rsp), %eax
movl 0x8c(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jae 0x1536c
movq 0x258(%rsp), %rdi
callq 0x12630
movl %eax, 0x84(%rsp)
jmp 0x15294
movq 0xf8(%rsp), %rax
movl 0x84(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, 0x15c(%rax)
jmp 0x1536c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x15689
movq 0xc8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x15689
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x6830
jmp 0x15689
movq 0xa8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x15689
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0x6830
jmp 0x15689
movq 0xf8(%rsp), %rax
movl 0x14(%rax), %ecx
incl %ecx
movl %ecx, 0x14(%rax)
movq $0x0, 0x180(%rsp)
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xccb0
movq 0x78(%rsp), %rcx
leaq 0x188(%rsp), %rdi
movl $0x2, %esi
leaq 0x180(%rsp), %rdx
callq 0xccc0
jmp 0x153bb
leaq 0x17f(%rsp), %rdi
callq 0xcd40
movl $0x0, 0x178(%rsp)
movslq 0x178(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x240(%rsp), %rdi
callq 0x8bf0
movq %rax, %rcx
movq 0x70(%rsp), %rax
cmpq %rcx, %rax
jae 0x154ea
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x60(%rsp)
movslq 0x178(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xcd80
movq 0x60(%rsp), %rdi
movl (%rax), %esi
callq 0xcd50
movsd %xmm0, 0x68(%rsp)
jmp 0x15438
movq 0xf8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
movslq 0x178(%rsp), %rsi
leaq 0x240(%rsp), %rdi
callq 0xcd80
movq 0x50(%rsp), %rdi
movl (%rax), %esi
callq 0xcdc0
movw %ax, 0x5e(%rsp)
jmp 0x15471
movw 0x5e(%rsp), %ax
movswq %ax, %rsi
leaq 0x188(%rsp), %rdi
callq 0xcda0
movsd 0x68(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x153d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x17f(%rsp), %rdi
callq 0xcd40
jmp 0x15689
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x1565e
movl $0x0, 0x174(%rsp)
movslq 0x174(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x188(%rsp), %rdi
callq 0xab40
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x15593
leaq 0x240(%rsp), %rdi
callq 0x8bf0
movq %rax, %xmm0
movaps 0x1b21b(%rip), %xmm1    # 0x30750
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1b21f(%rip), %xmm1    # 0x30760
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, 0x40(%rsp)
movslq 0x174(%rsp), %rsi
leaq 0x188(%rsp), %rdi
callq 0xcda0
movsd 0x40(%rsp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x174(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x174(%rsp)
jmp 0x154f5
movq 0x258(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x21dd0
jmp 0x155aa
leaq 0x158(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x67b0
movq 0x30(%rsp), %rsi
movq 0x258(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x140(%rsp), %rdi
callq 0xcbb0
jmp 0x155dd
movq 0x38(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x12260
jmp 0x155f1
leaq 0x140(%rsp), %rdi
callq 0x6830
leaq 0x158(%rsp), %rdi
callq 0x6830
leaq 0x188(%rsp), %rdi
callq 0xcaa0
jmp 0x1566d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
jmp 0x15651
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x280(%rsp)
movl %eax, 0x27c(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x6830
leaq 0x158(%rsp), %rdi
callq 0x6830
leaq 0x188(%rsp), %rdi
callq 0xcaa0
jmp 0x15689
leaq 0x1e0(%rsp), %rdi
callq 0x12640
leaq 0x228(%rsp), %rdi
callq 0x6830
jmp 0x156b5
leaq 0x1e0(%rsp), %rdi
callq 0x12640
leaq 0x228(%rsp), %rdi
callq 0x6830
leaq 0x240(%rsp), %rdi
callq 0x6830
jmp 0x157bf
leaq 0x240(%rsp), %rdi
callq 0x6830
jmp 0x14dc8
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x120(%rsp)
movq $0x0, 0x130(%rsp)
leaq 0x120(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x67b0
movq 0x8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x12590
movq 0x8(%rsp), %rdi
callq 0x6830
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x100(%rsp)
movq $0x0, 0x110(%rsp)
leaq 0x100(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x67b0
movq 0x28(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x12590
movq 0x28(%rsp), %rdi
callq 0x6830
movq 0xf8(%rsp), %rdi
callq 0x13dc0
jmp 0x15767
callq 0x3180
subq 0x2f8(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, (%rsp)
leaq 0x288(%rsp), %rdi
callq 0x23990
leaq 0x2a0(%rsp), %rdi
callq 0x6830
leaq 0x2b8(%rsp), %rdi
callq 0x6830
leaq 0x2d0(%rsp), %rdi
callq 0x26e10
movsd (%rsp), %xmm0
addq $0x308, %rsp            # imm = 0x308
retq
leaq 0x288(%rsp), %rdi
callq 0x23990
leaq 0x2a0(%rsp), %rdi
callq 0x6830
leaq 0x2b8(%rsp), %rdi
callq 0x6830
leaq 0x2d0(%rsp), %rdi
callq 0x26e10
movq 0x280(%rsp), %rdi
callq 0x33e0