// File: 0asa[P]TTree-source/ClassicTree.cpp
// Function: ClassicTree::learntbf()
double ClassicTree::learntbf() { 
	clock_t clock_start = clock();
	Scorer s(db);
	std::vector<unsigned int> lsleft;
	std::vector<unsigned int> lsright;
	TrueBestFirstStack stack(db);
	stack.setK(k);
	root = new Node();	root->setLS((*ls));	stack.push(root, (*cand));

	while (!stack.empty() && complexity < maxcomplexity) {
		Node *n = stack.pop();
		std::vector<unsigned int> set = n->getLS();
	
		if (set.size() >= nmin && !n->isLeaf()) { // !isLeaf() because of the TBF !
			stack.push(n->getLeft(), (*cand));
			stack.push(n->getRight(), (*cand));
			complexity++;
		} 
	}
	stack.clearStack();
	createProbsInLeaf();
	return (clock() - clock_start);
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x50(%rsp)
callq 0x3180
movq %rax, %rcx
movq 0x50(%rsp), %rax
movq %rcx, 0x138(%rsp)
movq 0x8(%rax), %rsi
leaq 0x110(%rsp), %rdi
callq 0x26d90
leaq 0xf8(%rsp), %rdi
callq 0x67b0
leaq 0xe0(%rsp), %rdi
callq 0x67b0
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x2dc30
jmp 0x14994
movq 0x50(%rsp), %rax
movl 0x58(%rax), %esi
leaq 0xa0(%rsp), %rdi
callq 0x2dcb0
jmp 0x149ab
movl $0x60, %edi
callq 0x3270
movq %rax, 0x48(%rsp)
jmp 0x149bc
movq 0x48(%rsp), %rdi
callq 0x21960
jmp 0x149c8
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0x50(%rax)
movq 0x20(%rax), %rsi
movq 0x50(%rax), %rax
movq %rax, 0x40(%rsp)
leaq 0x78(%rsp), %rdi
callq 0xcbb0
jmp 0x149ef
movq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x12260
jmp 0x14a00
leaq 0x78(%rsp), %rdi
callq 0x6830
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rdx
movq 0x50(%rax), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x2dda0
jmp 0x14a26
jmp 0x14a28
leaq 0xa0(%rsp), %rdi
callq 0x2d720
movb %al, 0x3f(%rsp)
jmp 0x14a3b
movb 0x3f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3e(%rsp)
jne 0x14a5e
jmp 0x14a4c
movq 0x50(%rsp), %rcx
movl 0x14(%rcx), %eax
cmpl 0x18(%rcx), %eax
setl %al
movb %al, 0x3e(%rsp)
movb 0x3e(%rsp), %al
testb $0x1, %al
jne 0x14a6b
jmp 0x14c03
leaq 0xa0(%rsp), %rdi
callq 0x2dcd0
movq %rax, 0x30(%rsp)
jmp 0x14a7f
movq 0x30(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rdi
callq 0xcba0
movq %rax, 0x28(%rsp)
jmp 0x14a9a
movq 0x28(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0xcbb0
jmp 0x14aab
leaq 0x58(%rsp), %rdi
callq 0x8bf0
movq 0x50(%rsp), %rcx
movslq 0x10(%rcx), %rcx
cmpq %rcx, %rax
jb 0x14bf4
movq 0x70(%rsp), %rdi
callq 0x21aa0
movb %al, 0x27(%rsp)
jmp 0x14ad7
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x14bf4
jmp 0x14ae5
movq 0x70(%rsp), %rdi
callq 0x21af0
movq %rax, 0x18(%rsp)
jmp 0x14af6
movq 0x18(%rsp), %rsi
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rdx
leaq 0xa0(%rsp), %rdi
callq 0x2dda0
jmp 0x14b13
movq 0x70(%rsp), %rdi
callq 0x21b00
movq %rax, 0x10(%rsp)
jmp 0x14b24
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rax
movq 0x30(%rax), %rdx
leaq 0xa0(%rsp), %rdi
callq 0x2dda0
jmp 0x14b41
movq 0x50(%rsp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x14bf4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x14c85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0x14c78
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x14c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x6830
jmp 0x14c78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x6830
jmp 0x14c78
leaq 0x58(%rsp), %rdi
callq 0x6830
jmp 0x14a28
leaq 0xa0(%rsp), %rdi
callq 0x2e470
jmp 0x14c12
movq 0x50(%rsp), %rdi
callq 0x13dc0
jmp 0x14c1e
callq 0x3180
subq 0x138(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2dc80
leaq 0xe0(%rsp), %rdi
callq 0x6830
leaq 0xf8(%rsp), %rdi
callq 0x6830
leaq 0x110(%rsp), %rdi
callq 0x26e10
movsd 0x8(%rsp), %xmm0
addq $0x148, %rsp            # imm = 0x148
retq
leaq 0xa0(%rsp), %rdi
callq 0x2dc80
leaq 0xe0(%rsp), %rdi
callq 0x6830
leaq 0xf8(%rsp), %rdi
callq 0x6830
leaq 0x110(%rsp), %rdi
callq 0x26e10
movq 0x98(%rsp), %rdi
callq 0x33e0
nopl (%rax)