// File: /workspace/github_cpp_makefile_star2_O1/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 $0x120, %rsp            # imm = 0x120
movq %rdx, %r15
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
movq 0x18(%rdi), %rsi
leaq 0xf8(%rsp), %r14
movq %r14, %rdi
callq 0x135c8
xorl %eax, %eax
movq %rax, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq %rax, 0x60(%rsp)
movapd %xmm0, 0x50(%rsp)
movq 0x8(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x7b1c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x38(%rbx), %edx
testl %edx, %edx
je 0x15896
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x9ca2
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movapd 0x90(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
testq %rdi, %rdi
je 0x15877
subq %rdi, %rsi
callq 0x3210
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x158a3
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x158a3
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x7392
movq 0x100(%rsp), %rax
addq 0x108(%rsp), %r14
testb $0x1, %al
je 0x158bf
movq (%r14), %rcx
movq -0x1(%rcx,%rax), %rax
leaq 0x90(%rsp), %rdi
leaq 0x38(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rsi
callq *%rax
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
subq %rax, %rcx
je 0x15911
sarq $0x2, %rcx
movq 0x18(%rbx), %rdx
movq 0x8(%rdx), %rdx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
movl (%rax,%rsi,4), %edi
addsd (%rdx,%rdi,8), %xmm0
incq %rsi
cmpq %rsi, %rcx
jne 0x158ff
jmp 0x15915
xorpd %xmm0, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x11114
movsd 0xb8(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x15af4
movq 0x18(%rbx), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x70(%rsp), %rcx
leaq 0x50(%rsp), %r8
callq 0xd616
movl $0x60, %edi
callq 0x3200
movq %rax, %r14
movq %rax, %rdi
callq 0x1103c
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x111d8
leaq 0xd8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x7b1c
leaq 0xd8(%rsp), %rsi
movq %r14, %rdi
callq 0x7392
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0x159c6
movl %eax, 0x58(%r14)
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x159e3
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x111de
movl $0x60, %edi
callq 0x3200
movq %rax, %r14
movq %rax, %rdi
callq 0x1103c
movq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x111d8
leaq 0xc0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x7b1c
leaq 0xc0(%rsp), %rsi
movq %r14, %rdi
callq 0x7392
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movl 0x58(%r14), %ecx
cmpq %rcx, %rax
jbe 0x15a4c
movl %eax, 0x58(%r14)
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x15a69
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x111e4
leaq 0x20(%rbx), %rdi
movq (%rbx), %r14
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rax
cmpq %rax, %rsi
je 0x15ab0
movsd 0xb8(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movsd (%rsi), %xmm1
ucomisd %xmm0, %xmm1
jae 0x15ab0
addq $0x8, %rsi
addq $0x8, %r14
cmpq %rax, %rsi
jne 0x15a99
movsd 0x30(%rsp), %xmm0
mulsd 0xb8(%rsp), %xmm0
leaq 0xf0(%rsp), %rdx
movsd %xmm0, (%rdx)
callq 0x15ce6
leaq 0x8(%rsp), %rdx
movq (%rdx), %rax
leaq 0xa70d(%rip), %rcx      # 0x201ec
movl (%rcx), %esi
leal 0x1(%rsi), %edi
movl %edi, (%rcx)
movl %esi, 0x50(%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7c30
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15b0b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x15b22
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x15b39
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x15b53
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xf8(%rsp), %rdi
callq 0x1361e
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r14
popq %r15
retq
jmp 0x15bcb
jmp 0x15bcb
jmp 0x15bcb
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x15bce
movq 0xd0(%rsp), %rsi
jmp 0x15ba7
jmp 0x15bac
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x15bce
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
jmp 0x15bb7
movq %rax, %rbx
movl $0x60, %esi
movq %r14, %rdi
callq 0x3210
jmp 0x15bce
jmp 0x15bcb
jmp 0x15bcb
movq %rax, %rbx
jmp 0x15bfc
jmp 0x15bcb
jmp 0x15bcb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15be5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x15bfc
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x15c13
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x15c2d
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xf8(%rsp), %rdi
callq 0x1361e
movq %rbx, %rdi
callq 0x3320