// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, 0xe0(%rsp)
movq 0x18(%rdi), %rsi
leaq 0xf0(%rsp), %r15
movq %r15, %rdi
callq 0x1354c
xorl %eax, %eax
movq %rax, 0x70(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq %rax, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x7b86
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x38(%rbx), %edx
testl %edx, %edx
je 0x15805
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x9cca
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movapd 0x80(%rsp), %xmm0
movapd %xmm0, 0x10(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
testq %rdi, %rdi
je 0x15812
subq %rdi, %rsi
callq 0x3210
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x15812
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
jmp 0x15812
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x73dc
movq 0xf8(%rsp), %rax
addq 0x100(%rsp), %r15
testb $0x1, %al
je 0x1582e
movq (%r15), %rcx
movq -0x1(%rcx,%rax), %rax
leaq 0x80(%rsp), %rdi
leaq 0x28(%rsp), %rdx
leaq 0x10(%rsp), %rcx
movq %r15, %rsi
callq *%rax
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %rcx
subq %rax, %rcx
je 0x15880
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 0x1586e
jmp 0x15884
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x80(%rsp), %rsi
movq %r14, %rdi
callq 0x110e4
movsd 0xa8(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x15a58
movq 0x18(%rbx), %rdi
leaq 0x80(%rsp), %rsi
leaq 0x28(%rsp), %rdx
leaq 0x60(%rsp), %rcx
leaq 0x40(%rsp), %r8
callq 0xd636
movl $0x60, %edi
callq 0x3200
movq %rax, %r15
movq %rax, %rdi
callq 0x11008
movq %r15, %rdi
movq %r14, %rsi
callq 0x111a8
leaq 0xc8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x7b86
leaq 0xc8(%rsp), %rsi
movq %r15, %rdi
callq 0x73dc
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x15931
movl %eax, 0x58(%r15)
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x1594e
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r14, %rdi
movq %r15, %rsi
callq 0x111ae
movl $0x60, %edi
callq 0x3200
movq %rax, %r15
movq %rax, %rdi
callq 0x11008
movq %r15, %rdi
movq %r14, %rsi
callq 0x111a8
leaq 0xb0(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7b86
leaq 0xb0(%rsp), %rsi
movq %r15, %rdi
callq 0x73dc
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x2, %rax
movl 0x58(%r15), %ecx
cmpq %rcx, %rax
jbe 0x159b3
movl %eax, 0x58(%r15)
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x159d0
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq %r14, %rdi
movq %r15, %rsi
callq 0x111b4
leaq 0x20(%rbx), %rdi
movq (%rbx), %r14
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rax
movsd 0x8(%rsp), %xmm0
mulsd 0xa8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cmpq %rax, %rsi
je 0x15a1a
movsd (%rsi), %xmm0
ucomisd 0x8(%rsp), %xmm0
jae 0x15a1a
addq $0x8, %rsi
addq $0x8, %r14
jmp 0x159ff
leaq 0xe8(%rsp), %rdx
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rdx)
callq 0x15c46
leaq 0xe0(%rsp), %rdx
movq (%rdx), %rax
leaq 0xa7a9(%rip), %rcx      # 0x201ec
movl (%rcx), %esi
leal 0x1(%rsi), %edi
movl %edi, (%rcx)
movl %esi, 0x50(%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7c9a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15a6f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x15a86
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15a9d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15ab4
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xf0(%rsp), %rdi
callq 0x13590
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x15b2e
jmp 0x15b2e
jmp 0x15b2e
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x15b31
movq 0xc0(%rsp), %rsi
jmp 0x15b0a
jmp 0x15b0f
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x15b31
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
jmp 0x15b1a
movq %rax, %rbx
movl $0x60, %esi
movq %r15, %rdi
callq 0x3210
jmp 0x15b31
jmp 0x15b2e
jmp 0x15b2e
movq %rax, %rbx
jmp 0x15b5f
jmp 0x15b2e
jmp 0x15b2e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15b48
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x15b5f
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x15b76
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x15b8d
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x3210
leaq 0xf0(%rsp), %rdi
callq 0x13590
movq %rbx, %rdi
callq 0x3320