// File: 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:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x210(%rsp)
movq %rsi, 0x208(%rsp)
movq %rdx, 0x200(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x18(%rax), %rsi
leaq 0x1d8(%rsp), %rdi
callq 0x26d90
leaq 0x1c0(%rsp), %rdi
callq 0x67b0
leaq 0x1a8(%rsp), %rdi
callq 0x67b0
movq 0x208(%rsp), %rdi
callq 0xcba0
movq %rax, 0x68(%rsp)
jmp 0x2de0b
movq 0x68(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0xcbb0
jmp 0x2de1f
leaq 0x168(%rsp), %rdi
callq 0x67b0
movq 0x60(%rsp), %rax
cmpl $0x0, 0x38(%rax)
jbe 0x2deac
movq 0x60(%rsp), %rax
movq 0x200(%rsp), %rsi
movl 0x38(%rax), %edx
leaq 0x150(%rsp), %rdi
callq 0x122d0
jmp 0x2de56
leaq 0x168(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x6800
leaq 0x150(%rsp), %rdi
callq 0x6830
jmp 0x2dec5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x2e432
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x2e418
movq 0x200(%rsp), %rsi
leaq 0x168(%rsp), %rdi
callq 0x90f0
jmp 0x2dec3
jmp 0x2dec5
leaq 0x120(%rsp), %rdi
leaq 0x1d8(%rsp), %rsi
leaq 0x190(%rsp), %rdx
leaq 0x168(%rsp), %rcx
callq 0x168e0
jmp 0x2deec
xorps %xmm0, %xmm0
movsd %xmm0, 0x118(%rsp)
movl $0x0, 0x114(%rsp)
movslq 0x114(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x8bf0
movq %rax, %rcx
movq 0x58(%rsp), %rax
cmpq %rcx, %rax
jae 0x2dfa8
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x48(%rsp)
movslq 0x114(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0xcd80
movq 0x48(%rsp), %rdi
movl (%rax), %esi
callq 0xcd50
movsd %xmm0, 0x50(%rsp)
jmp 0x2df61
movsd 0x50(%rsp), %xmm0
addsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x118(%rsp)
movl 0x114(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x114(%rsp)
jmp 0x2df03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x2e40b
movq 0x208(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x21b10
jmp 0x2dfbf
movsd 0x148(%rsp), %xmm0
mulsd 0x118(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x2e3b5
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x120(%rsp), %rsi
leaq 0x190(%rsp), %rdx
leaq 0x1c0(%rsp), %rcx
leaq 0x1a8(%rsp), %r8
callq 0x19420
jmp 0x2e00e
movl $0x60, %edi
callq 0x3270
movq %rax, 0x40(%rsp)
jmp 0x2e01f
movq 0x40(%rsp), %rdi
callq 0x21960
jmp 0x2e02b
movq 0x40(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rdi
movq 0x208(%rsp), %rsi
callq 0x21c50
jmp 0x2e04f
movq 0x108(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0xcbb0
jmp 0x2e073
movq 0x38(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x12260
jmp 0x2e087
leaq 0xf0(%rsp), %rdi
callq 0x6830
movq 0x208(%rsp), %rdi
movq 0x108(%rsp), %rsi
callq 0x21c70
jmp 0x2e0ab
movl $0x60, %edi
callq 0x3270
movq %rax, 0x30(%rsp)
jmp 0x2e0bc
movq 0x30(%rsp), %rdi
callq 0x21960
jmp 0x2e0c8
movq 0x30(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
movq 0x208(%rsp), %rsi
callq 0x21c50
jmp 0x2e0ec
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0xcbb0
jmp 0x2e110
movq 0x28(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x12260
jmp 0x2e124
leaq 0xd0(%rsp), %rdi
callq 0x6830
movq 0x208(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x21c90
jmp 0x2e148
leaq 0xc8(%rsp), %rdi
callq 0xce10
leaq 0xc0(%rsp), %rdi
callq 0xce30
movq 0x60(%rsp), %rdi
addq $0x20, %rdi
callq 0xade0
movq 0x60(%rsp), %rdi
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xc8(%rsp)
callq 0xce50
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x60(%rsp), %rdi
addq $0x20, %rdi
callq 0xae10
movq %rax, 0xa8(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xce80
testb $0x1, %al
jne 0x2e1de
jmp 0x2e2ed
movsd 0x148(%rsp), %xmm0
mulsd 0x118(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0xcec0
movsd 0x20(%rsp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jb 0x2e2b8
jmp 0x2e2ed
movq 0x40(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x2e40b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x6830
jmp 0x2e40b
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
movl $0x60, %esi
callq 0x3280
jmp 0x2e40b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x6830
jmp 0x2e40b
jmp 0x2e2ba
leaq 0xc8(%rsp), %rdi
xorl %esi, %esi
callq 0xced0
movq %rax, 0xa0(%rsp)
leaq 0xc0(%rsp), %rdi
xorl %esi, %esi
callq 0xcf10
movq %rax, 0x98(%rsp)
jmp 0x2e1aa
movq 0x60(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x10(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xd170
movq 0x10(%rsp), %rdi
movsd 0x148(%rsp), %xmm0
movsd 0x118(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x88(%rsp)
movq 0x90(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x2e580
movq %rax, 0x18(%rsp)
jmp 0x2e350
movq 0x18(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x208(%rsp), %rdi
leaq 0x12ee8(%rip), %rax     # 0x41254
movl (%rax), %esi
movl %esi, %ecx
incl %ecx
movl %ecx, (%rax)
callq 0xcb80
jmp 0x2e37b
leaq 0x78(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xd3d0
movq 0x60(%rsp), %rdi
movq 0x78(%rsp), %rsi
leaq 0x208(%rsp), %rdx
callq 0xd1b0
movq %rax, 0x8(%rsp)
jmp 0x2e3ab
movq 0x8(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x12640
leaq 0x168(%rsp), %rdi
callq 0x6830
leaq 0x190(%rsp), %rdi
callq 0x6830
leaq 0x1a8(%rsp), %rdi
callq 0x6830
leaq 0x1c0(%rsp), %rdi
callq 0x6830
leaq 0x1d8(%rsp), %rdi
callq 0x26e10
addq $0x218, %rsp            # imm = 0x218
retq
leaq 0x120(%rsp), %rdi
callq 0x12640
leaq 0x168(%rsp), %rdi
callq 0x6830
leaq 0x190(%rsp), %rdi
callq 0x6830
leaq 0x1a8(%rsp), %rdi
callq 0x6830
leaq 0x1c0(%rsp), %rdi
callq 0x6830
leaq 0x1d8(%rsp), %rdi
callq 0x26e10
movq 0x188(%rsp), %rdi
callq 0x33e0
nopw %cs:(%rax,%rax)