// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rdi, 0x30(%rsp)
movq 0x108(%rsi), %rax
subq 0x100(%rsi), %rax
shrq $0x2, %rax
movq %rax, 0x18(%rsp)
testl %eax, %eax
jle 0x1b4eb
movq %rdx, %r9
movq %rsi, %r12
movq 0x108(%rdx), %rdx
subq 0x100(%r9), %rdx
shrq $0x2, %rdx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, 0x18(%rsp)
movq %rdx, 0x20(%rsp)
andq %rax, %rdx
movq %rdx, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
movsd 0x25e30(%rip), %xmm2    # 0x410d0
xorpd %xmm3, %xmm3
movl %r8d, 0x14(%rsp)
movq %r13, 0x48(%rsp)
movq %r9, 0x40(%rsp)
cmpl $0x0, 0x20(%rsp)
jle 0x1b4d3
movq 0x100(%r12), %rax
movq 0x8(%rsp), %rcx
movslq (%rax,%rcx,4), %rdi
leaq (%rdi,%rdi,2), %rax
movq %rax, 0x38(%rsp)
xorl %ecx, %ecx
movq %rdi, 0x50(%rsp)
movq 0x100(%r9), %rax
movq %rcx, 0x58(%rsp)
movslq (%rax,%rcx,4), %r11
movq 0x30(%rsp), %rax
movq 0x208(%rax), %rax
movq 0x38(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
leaq (%r11,%r11,2), %rdx
movq (%rcx,%rdx,8), %rax
cmpq %rax, 0x8(%rcx,%rdx,8)
je 0x1b4c0
leaq (%rcx,%rdx,8), %r14
xorl %r15d, %r15d
movq (%rax,%r15,8), %rax
testq %rax, %rax
je 0x1b4a6
movq (%rax), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
movsd (%rcx), %xmm4
ucomisd %xmm2, %xmm4
jbe 0x1b4a6
movslq 0x78(%rax), %rbx
cmpl $0x1, %r8d
je 0x1b41c
testl %r8d, %r8d
jne 0x1b4a6
movq 0xd0(%r12), %rax
ucomisd (%rax,%rdi,8), %xmm3
ja 0x1b377
movq 0xd0(%r9), %rax
ucomisd (%rax,%r11,8), %xmm3
jbe 0x1b3df
movl $0x3, %edx
movq 0x3ac6d(%rip), %rbp     # 0x55ff0
movq %rbp, %rdi
leaq 0x268c2(%rip), %rsi     # 0x41c4f
movq %r11, %r13
movsd %xmm4, 0x60(%rsp)
callq 0x3350
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movsd 0x60(%rsp), %xmm4
movq %r13, %r11
movq 0x50(%rsp), %rdi
xorpd %xmm3, %xmm3
movq 0x40(%rsp), %r9
movq 0x48(%rsp), %r13
movq 0xd0(%r13), %rax
leaq (%rax,%rbx,8), %rax
ucomisd (%rax), %xmm3
jbe 0x1b3f7
movq $0x0, (%rax)
leaq (,%rdi,8), %rcx
addq 0xd0(%r12), %rcx
movq %r9, %rdx
movq %r11, %rsi
movl 0x14(%rsp), %r8d
movsd 0x25cb6(%rip), %xmm2    # 0x410d0
jmp 0x1b486
movq 0xe8(%r13), %rcx
ucomisd (%rcx,%rbx,8), %xmm3
ja 0x1b4a6
movq 0xe8(%r12), %rdx
ucomisd (%rdx,%rdi,8), %xmm3
jbe 0x1b441
movq $0x0, (%rdx,%rdi,8)
movq 0xe8(%r9), %rax
leaq (%rax,%r11,8), %rax
ucomisd (%rax), %xmm3
jbe 0x1b459
movq $0x0, (%rax)
leaq (%rcx,%rbx,8), %rcx
movsd (%rcx), %xmm0
movq 0xd0(%r9), %rsi
mulsd (%rsi,%r11,8), %xmm0
mulsd %xmm4, %xmm0
movsd (%rdx,%rdi,8), %xmm1
maxsd %xmm0, %xmm1
movsd %xmm1, (%rdx,%rdi,8)
movq %r12, %rdx
movq %rdi, %rsi
movsd (%rcx), %xmm0
movq 0xd0(%rdx), %rcx
mulsd (%rcx,%rsi,8), %xmm0
mulsd %xmm0, %xmm4
movsd (%rax), %xmm0
maxsd %xmm4, %xmm0
movsd %xmm0, (%rax)
incq %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x1b31e
movq 0x58(%rsp), %rcx
incq %rcx
cmpq 0x28(%rsp), %rcx
jne 0x1b2df
movq 0x8(%rsp), %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
cmpq 0x18(%rsp), %rcx
jne 0x1b2b3
movq %r13, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop