// File: /workspace/github_cpp_makefile_star2_O2/0asa[P]TTree-source/TrueBestFirstStack.cpp
// Function: TrueBestFirstStack::push(Node*, std::vector<unsigned int, std::allocator<unsigned int>>&)
void TrueBestFirstStack::push(Node* n, std::vector<unsigned int> &cand) {
	Scorer sc(db);
	std::vector<unsigned int> lsleft;
	std::vector<unsigned int> lsright;
	std::vector<unsigned int> set = n->getLS();
	std::vector<unsigned int> kcand;
	if (k > 0)
		kcand = Sampler::random(cand,k);
	else
		kcand = cand; 
	ScoreInfo si = sc.getBestScore(set,kcand);
	//fprintf(stderr,"TBF score: %f\n",si.score);
	//db->getLRSet(si,set,lsleft,lsright);
	double total = 0.0;
	for (int i = 0 ; i < set.size() ; ++i) {
		total += db->getWeight(set[i]);
	}
	n->setTest(si);
	if (si.score*total > 0.0) {
	db->getLRSet(si,set,lsleft,lsright);
	Node *left  = new Node();	left->setParent(n);
	left->setLS(lsleft);	n->setLeft(left);	
	Node *right = new Node();	right->setParent(n);
	right->setLS(lsright);	n->setRight(right);
	
		std::vector<double>::iterator it;
		std::vector< Node* >::iterator itn;
		for( it = values.begin(), itn = s.begin() ; it != values.end(); it++, itn++ )    {
			if (si.score*total <= *it) 
				break;
		}
		values.insert(it,si.score*total);
		//for (int i = 0 ; i < values.size() ; ++i)
		//	printf("%f|",values[i]);
		//printf("\n");
		n->setId(nbpush++);
		s.insert(itn,n);
		
		
	}
	
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0x78(%rsp)
movq 0x18(%rdi), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x10648
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movapd %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x6c64
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movl 0x38(%rbx), %edx
testl %edx, %edx
je 0x126ae
leaq 0xb0(%rsp), %rdi
movq %r15, %rsi
callq 0x88a6
leaq 0x10(%rsp), %rdi
leaq 0xb0(%rsp), %r15
movq %r15, %rsi
callq 0x68a8
movq %r15, %rdi
callq 0x6886
jmp 0x126bb
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x634c
leaq 0xb0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0xa79a
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0x18(%rbx), %rdx
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x1271e
movl (%rax,%rsi,4), %edi
movq 0x8(%rdx), %r8
movsd 0x8(%rsp), %xmm0
addsd (%r8,%rdi,8), %xmm0
movsd %xmm0, 0x8(%rsp)
incq %rsi
jmp 0x126fb
leaq 0xb0(%rsp), %rsi
movq %r14, %rdi
callq 0xe518
movsd 0xd8(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x12893
movq 0x18(%rbx), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x40(%rsp), %r8
callq 0xb54c
pushq $0x60
popq %rdi
callq 0x3200
movq %rax, %r15
movq %rax, %rdi
callq 0xe460
movq %r15, %rdi
movq %r14, %rsi
callq 0xe5d4
leaq 0x98(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x6c64
leaq 0x98(%rsp), %rsi
movq %r15, %rdi
callq 0x8884
leaq 0x98(%rsp), %rdi
callq 0x6886
movq %r14, %rdi
movq %r15, %rsi
callq 0xe5da
pushq $0x60
popq %rdi
callq 0x3200
movq %rax, %r15
movq %rax, %rdi
callq 0xe460
movq %r15, %rdi
movq %r14, %rsi
callq 0xe5d4
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x6c64
leaq 0x80(%rsp), %rsi
movq %r15, %rdi
callq 0x8884
leaq 0x80(%rsp), %rdi
callq 0x6886
movq %r14, %rdi
movq %r15, %rsi
callq 0xe5e0
leaq 0x20(%rbx), %rdi
movq (%rbx), %r15
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rax
movsd 0x8(%rsp), %xmm0
mulsd 0xd8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpq %rax, %rsi
je 0x1285a
movsd (%rsi), %xmm0
ucomisd 0x8(%rsp), %xmm0
jae 0x1285a
addq $0x8, %rsi
addq $0x8, %r15
jmp 0x1283f
leaq 0xe0(%rsp), %rdx
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rdx)
callq 0x129f8
leaq 0xb97c(%rip), %rax      # 0x1e1f4
movl (%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, (%rax)
movl %ecx, 0x50(%r14)
leaq 0x78(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6d7a
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x28(%rsp), %rdi
callq 0x6886
leaq 0x40(%rsp), %rdi
callq 0x6886
leaq 0x60(%rsp), %rdi
callq 0x6886
leaq 0xe8(%rsp), %rdi
callq 0x1068c
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %r15
retq
jmp 0x12919
jmp 0x12919
jmp 0x12919
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x128f5
jmp 0x128fc
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6886
jmp 0x1291c
movq %rax, %rbx
pushq $0x60
popq %rsi
movq %r15, %rdi
callq 0x3210
jmp 0x1291c
jmp 0x12919
jmp 0x12919
movq %rax, %rbx
jmp 0x12930
jmp 0x12919
jmp 0x12919
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6886
leaq 0x28(%rsp), %rdi
callq 0x6886
leaq 0x40(%rsp), %rdi
callq 0x6886
leaq 0x60(%rsp), %rdi
callq 0x6886
leaq 0xe8(%rsp), %rdi
callq 0x1068c
movq %rbx, %rdi
callq 0x3330
nop