// File: neubig[P]egret/Egret/src/Forest-Berkeley-2.cpp
// Function: genNewNode_withoutLabel_initLevel_berkeley(BerkeleyRuleSet const&, Node&, Node&, Node&, IorO)
Node& genNewNode_withoutLabel_initLevel_berkeley(const BerkeleyRuleSet& ruleSet,Node& n1, Node& n2, Node& n3, IorO iot)
{
	const vector<int>& asi1_inVector=n1.allowState();
	const vector<int>& asi2_inVector=n2.allowState();
	int lcSize=(int)asi1_inVector.size();
	int rcSize=(int)asi2_inVector.size();
	//if(n3.stop()-n3.start()<3)
	//	cout<<n3.start()<<" "<<n3.stop()<<" : "<<lcSize<<","<<rcSize<<" "<<ruleSet.numOfState()<<endl;
	for(int lcIter=0; lcIter<lcSize;lcIter++)
	{
		int lc=asi1_inVector[lcIter];
		for(int rcIter=0;rcIter<rcSize;rcIter++)
		{
			int rc=asi2_inVector[rcIter];
			
			//cerr<<"child pair:"<<lc<<","<<rc<<endl;
			
			const vector<BerkeleyBinaryRule*>& rules=ruleSet.getBinaryRulesByChilds(lc,rc);
			for(int i=0;(size_t)i<rules.size();i++)
			{
				BerkeleyBinaryRule* rule=rules[i];
				if(rule==NULL)continue;
				int pr=rule->parentState();
				double ruleScore=rule->getScore(0,0,0);
				if(ruleScore>-1E10)
				{
					if(iot==inside)
					{
						//cerr<<"\t parent:"<<pr<<endl;
						if(n1.iScore(lc)<0||n2.iScore(rc)<0)cerr<<"bug"<<endl;
						if(n3.iScore(pr)<0) n3.iScore(pr)=0;
						n3.iScore(pr)=max(n1.iScore(lc)*n2.iScore(rc)*ruleScore,n3.iScore(pr));
					}
					else if(iot==outside)
					{
						if(n3.oScore(pr)<0)continue;//cerr<<"bug2"<<endl;
						if(n1.oScore(lc)<0) n1.oScore(lc)=0;
						if(n2.oScore(rc)<0) n2.oScore(rc)=0;
						n1.oScore(lc)=max(n3.oScore(pr)*n2.iScore(rc)*ruleScore,n1.oScore(lc));
						n2.oScore(rc)=max(n3.oScore(pr)*n1.iScore(lc)*ruleScore,n2.oScore(rc));
					}
				}
			}	
		}
	}
	return n3;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0x457c0
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x457c0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x16990
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x16990
movl %eax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jge 0x42abc
movq -0x30(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x457e0
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x42aac
movq -0x38(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0x457e0
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x50(%rbp), %edx
callq 0x45800
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %rdi
callq 0x143b0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
jae 0x42a9c
movq -0x58(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0x8900
movq (%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x427ec
jmp 0x42a8e
movq -0x68(%rbp), %rdi
callq 0x9890
movl %eax, -0x6c(%rbp)
movq -0x68(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x45830
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
movsd 0x4d89f(%rip), %xmm1    # 0x900b8
ucomisd %xmm1, %xmm0
jbe 0x42a8c
cmpl $0x0, -0x24(%rbp)
jne 0x4291c
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x45750
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
ja 0x42857
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x45750
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x42879
movq 0x8c792(%rip), %rdi     # 0xceff0
leaq 0x4e3aa(%rip), %rsi     # 0x90c0f
callq 0x4380
movq %rax, %rdi
movq 0x8c744(%rip), %rsi     # 0xcefb8
callq 0x43d0
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x45750
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x428a1
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x45750
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x45750
movsd (%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x45750
movsd -0xa8(%rbp), %xmm0
mulsd (%rax), %xmm0
mulsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x45750
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x45780
movsd (%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x45750
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x42a8a
cmpl $0x1, -0x24(%rbp)
jne 0x42a88
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x456b0
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x42940
jmp 0x42a8e
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x456b0
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x42968
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x456b0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x456b0
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x42990
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x456b0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x456b0
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x45750
movsd -0xc8(%rbp), %xmm0
mulsd (%rax), %xmm0
mulsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x456b0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x45780
movsd (%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x456b0
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rdi
movl -0x6c(%rbp), %esi
callq 0x456b0
movsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
movl -0x48(%rbp), %esi
callq 0x45750
movsd -0xb8(%rbp), %xmm0
mulsd (%rax), %xmm0
mulsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x456b0
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x45780
movsd (%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x456b0
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x42a8a
jmp 0x42a8c
jmp 0x42a8e
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x427a5
jmp 0x42a9e
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4276d
jmp 0x42aae
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x42748
movq -0x20(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)