// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %rax
movq %rdi, 0x30(%rsp)
movq 0x108(%rsi), %rcx
subq 0x100(%rsi), %rcx
shrq $0x2, %rcx
movq %rcx, 0x18(%rsp)
testl %ecx, %ecx
jle 0x1ae70
movq %rdx, %r10
movq %rsi, %rbp
movq 0x108(%rdx), %rsi
subq 0x100(%rdx), %rsi
shrq $0x2, %rsi
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andq %rcx, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
andq %rcx, %rsi
movq %rsi, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
movsd 0x254e6(%rip), %xmm2    # 0x400d0
xorpd %xmm3, %xmm3
movq %rax, 0x40(%rsp)
movl %r8d, 0x14(%rsp)
cmpl $0x0, 0x20(%rsp)
jle 0x1ae58
movq 0x100(%rbp), %rcx
movq 0x8(%rsp), %rdx
movslq (%rcx,%rdx,4), %r12
leaq (%r12,%r12,2), %rcx
movq %rcx, 0x38(%rsp)
xorl %edx, %edx
movq %r12, 0x48(%rsp)
movq 0x100(%r10), %rcx
movq %rdx, 0x50(%rsp)
movslq (%rcx,%rdx,4), %r13
movq 0x30(%rsp), %rcx
movq 0x208(%rcx), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx,8), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
movq (%rdx,%rsi,8), %r9
movq 0x8(%rdx,%rsi,8), %rcx
cmpq %r9, %rcx
je 0x1ae45
leaq (%rdx,%rsi,8), %rdx
movq %rdx, 0x58(%rsp)
xorl %r15d, %r15d
movq (%r9,%r15,8), %rdx
testq %rdx, %rdx
je 0x1ae2f
movq (%rdx), %rsi
movq (%rsi), %rsi
movq (%rsi), %rsi
movsd (%rsi), %xmm4
ucomisd %xmm2, %xmm4
jbe 0x1ae2f
movslq 0x78(%rdx), %r14
cmpl $0x1, %r8d
je 0x1ad98
testl %r8d, %r8d
jne 0x1ae2f
movq 0xd0(%rbp), %rcx
ucomisd (%rcx,%r12,8), %xmm3
ja 0x1acca
movq 0xd0(%r10), %rcx
ucomisd (%rcx,%r13,8), %xmm3
jbe 0x1ad40
movl $0x3, %edx
movq %r13, %rbx
movq 0x3a317(%rip), %r13     # 0x54ff0
movq %r13, %rdi
leaq 0x25f7c(%rip), %rsi     # 0x40c5f
movq %r10, %r12
movsd %xmm4, 0x60(%rsp)
callq 0x3350
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %r13, %rdi
movq %rbx, %r13
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movsd 0x60(%rsp), %xmm4
xorpd %xmm3, %xmm3
movsd 0x253a2(%rip), %xmm2    # 0x400d0
movl 0x14(%rsp), %r8d
movq %r12, %r10
movq 0x48(%rsp), %r12
movq 0x40(%rsp), %rax
movq 0xd0(%rax), %rdx
movsd (%rdx,%r14,8), %xmm0
ucomisd %xmm0, %xmm3
jbe 0x1ad5f
movq $0x0, (%rdx,%r14,8)
xorpd %xmm0, %xmm0
movq 0xd0(%rbp), %rcx
movsd (%rcx,%r12,8), %xmm1
movq 0xd0(%r10), %rcx
mulsd (%rcx,%r13,8), %xmm1
mulsd %xmm1, %xmm4
maxsd %xmm4, %xmm0
movsd %xmm0, (%rdx,%r14,8)
movq 0x58(%rsp), %rcx
movq (%rcx), %r9
movq 0x8(%rcx), %rcx
jmp 0x1ae2f
movq 0xe8(%rax), %rdx
ucomisd (%rdx,%r14,8), %xmm3
ja 0x1ae2f
movq 0xe8(%rbp), %rsi
movsd (%rsi,%r12,8), %xmm0
ucomisd %xmm0, %xmm3
jbe 0x1adca
movq $0x0, (%rsi,%r12,8)
xorpd %xmm0, %xmm0
movq 0xe8(%r10), %rdi
ucomisd (%rdi,%r13,8), %xmm3
jbe 0x1ade7
movq $0x0, (%rdi,%r13,8)
movsd (%rsi,%r12,8), %xmm0
movsd (%rdx,%r14,8), %xmm1
movq 0xd0(%r10), %rbx
mulsd (%rbx,%r13,8), %xmm1
mulsd %xmm4, %xmm1
maxsd %xmm1, %xmm0
movsd %xmm0, (%rsi,%r12,8)
movsd (%rdx,%r14,8), %xmm0
movq 0xd0(%rbp), %rdx
mulsd (%rdx,%r12,8), %xmm0
mulsd %xmm4, %xmm0
movsd (%rdi,%r13,8), %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, (%rdi,%r13,8)
incq %r15
movq %rcx, %rdx
subq %r9, %rdx
sarq $0x3, %rdx
cmpq %r15, %rdx
ja 0x1ac71
movq 0x50(%rsp), %rdx
incq %rdx
cmpq 0x28(%rsp), %rdx
jne 0x1ac23
movq 0x8(%rsp), %rdx
incq %rdx
movq %rdx, 0x8(%rsp)
cmpq 0x18(%rsp), %rdx
jne 0x1abf8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop