// File: /workspace/github_cpp_makefile_star2_O2/0asa[P]TTree-source/ClassicTree.cpp
// Function: ClassicTree::learnnbf()
double ClassicTree::learnnbf() { 
	clock_t clock_start = clock();
	Scorer s(db);
	std::vector<unsigned int> lsleft;
	std::vector<unsigned int> lsright;
	
	
	Stack stack;
	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.getBestScore(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
			}
		}
	}	
	createProbsInLeaf();
	return (clock() - clock_start);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rdi, %r14
callq 0x3140
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rsi
leaq 0x100(%rsp), %rdi
callq 0x10648
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movapd %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x12418
pushq $0x60
popq %rdi
callq 0x3200
movq %rax, %r15
movq %rax, %rdi
callq 0xe460
movq %r15, 0x50(%r14)
movq 0x20(%r14), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x6c64
leaq 0xb8(%rsp), %rsi
movq %r15, %rdi
callq 0x8884
leaq 0xb8(%rsp), %rdi
callq 0x6886
movq 0x50(%r14), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1242a
leaq 0xa0(%rsp), %r15
leaq 0x88(%rsp), %r12
movq %r15, %rdi
callq 0x12460
testb %al, %al
jne 0x905f
movl 0x14(%r14), %eax
cmpl 0x18(%r14), %eax
jge 0x905f
movq %r15, %rdi
callq 0x1244e
movq %rax, %rbx
movq %r12, %rdi
movq %rax, %rsi
callq 0x6c64
movq 0x90(%rsp), %rax
subq 0x88(%rsp), %rax
sarq $0x2, %rax
movslq 0x10(%r14), %rcx
cmpq %rcx, %rax
jb 0x9052
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movl 0x58(%r14), %edx
testl %edx, %edx
je 0x8e19
movq 0x30(%r14), %rsi
leaq 0x128(%rsp), %rbp
movq %rbp, %rdi
callq 0x88a6
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x68a8
movq %rbp, %rdi
callq 0x6886
jmp 0x8e32
movq 0x30(%r14), %rsi
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x634c
leaq 0x128(%rsp), %rbp
movq %rbp, %rdi
leaq 0x100(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0xa79a
movsd 0x150(%rsp), %xmm0
ucomisd 0xa8a7(%rip), %xmm0     # 0x13700
jbe 0x9048
movq 0x8(%r14), %rdi
leaq 0x128(%rsp), %r13
movq %r13, %rsi
movq %r12, %rdx
leaq 0x50(%rsp), %rcx
leaq 0x30(%rsp), %r8
callq 0xb54c
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe518
pushq $0x60
popq %rdi
callq 0x3200
movq %rax, %r13
movq %rax, %rdi
callq 0xe460
movq %r13, %rdi
movq %rbx, %rsi
callq 0xe5d4
movl 0x54(%rbx), %eax
incl %eax
movl %eax, 0x54(%r13)
leaq 0xe8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x6c64
movq %r13, %rdi
leaq 0xe8(%rsp), %rbp
movq %rbp, %rsi
callq 0x8884
movq %rbp, %rdi
callq 0x6886
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe5da
movq %r15, %rdi
movq %r13, %rsi
callq 0x1242a
pushq $0x60
popq %rdi
callq 0x3200
movq %rax, %r13
movq %rax, %rdi
callq 0xe460
movq %r13, %rdi
movq %rbx, %rsi
callq 0xe5d4
movl 0x54(%rbx), %eax
incl %eax
movl %eax, 0x54(%r13)
leaq 0xd0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x6c64
movq %r13, %rdi
leaq 0xd0(%rsp), %rbp
movq %rbp, %rsi
callq 0x8884
movq %rbp, %rdi
callq 0x6886
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe5e0
movq %r15, %rdi
movq %r13, %rsi
callq 0x1242a
movl 0x54(%rbx), %eax
incl %eax
cmpl %eax, 0x15c(%r14)
jae 0x8f74
movl %eax, 0x15c(%r14)
incl 0x14(%r14)
andq $0x0, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
pushq $0x2
popq %rsi
leaq 0x68(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x6cb2
movq 0x88(%rsp), %rcx
movq 0x90(%rsp), %rax
subq %rcx, %rax
sarq $0x2, %rax
movq 0x8(%r14), %rdx
movq 0x70(%rsp), %rsi
xorl %edi, %edi
cmpq %rdi, %rax
je 0x8fe4
movl (%rcx,%rdi,4), %r8d
movq 0x8(%rdx), %r9
movq 0x28(%rdx), %r10
movsd (%r9,%r8,8), %xmm0
movswq (%r10,%r8,2), %r8
addsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rsi,%r8,8)
incq %rdi
jmp 0x8fb7
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movq %rax, %xmm1
punpckldq 0xa6de(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xa6e6(%rip), %xmm1     # 0x136f0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
xorl %eax, %eax
cmpq %rax, %rdx
je 0x9030
movsd (%rcx,%rax,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rax,8)
incq %rax
jmp 0x9018
movq %rbx, %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0xe640
movq %rbx, %rdi
callq 0x6de4
leaq 0x10(%rsp), %rdi
callq 0x6886
movq %r12, %rdi
callq 0x6886
jmp 0x8d7e
movq %r14, %rdi
callq 0x918e
callq 0x3140
subq 0x8(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x12424
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0x50(%rsp), %rdi
callq 0x6886
leaq 0x100(%rsp), %rdi
callq 0x1068c
movsd 0x8(%rsp), %xmm0
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x9153
movq %rax, %rbx
pushq $0x60
popq %rsi
movq %r15, %rdi
callq 0x3210
jmp 0x9158
movq %rax, %rbx
jmp 0x9165
jmp 0x913e
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x6de4
jmp 0x9141
jmp 0x913e
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0x9114
jmp 0x911b
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x6886
jmp 0x9141
movq %rax, %rbx
pushq $0x60
popq %rsi
movq %r13, %rdi
callq 0x3210
jmp 0x9141
jmp 0x9137
jmp 0x913e
jmp 0x913e
jmp 0x913e
jmp 0x9137
jmp 0x9137
movq %rax, %rbx
jmp 0x9158
jmp 0x913e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x88(%rsp), %rdi
callq 0x6886
leaq 0xa0(%rsp), %rdi
callq 0x12424
leaq 0x30(%rsp), %rdi
callq 0x6886
leaq 0x50(%rsp), %rdi
callq 0x6886
leaq 0x100(%rsp), %rdi
callq 0x1068c
movq %rbx, %rdi
callq 0x3330