// File: /workspace/github_cpp_makefile_star2_O2/neubig[P]egret/Egret/src/Forest-Berkeley-ruleByParent.cpp
// Function: genUnaryNode_withoutLabel_initLevel_berkeley(BerkeleyRuleSet const&, Node&, IorO, ExtentInfo&)
bool genUnaryNode_withoutLabel_initLevel_berkeley(const BerkeleyRuleSet& ruleSet, Node& node, IorO iot, ExtentInfo& extentInfo)
{
		const BerkeleyStateInfoOfOneLevel& bsio=ruleSet.bsio();
		int numOfState=(int)bsio.numOfState();

vector<double> temp_iScore,temp_oScore;
temp_iScore.clear();
temp_oScore.clear();
temp_iScore.reserve(numOfState);
temp_oScore.reserve(numOfState);
for(int i=0;i<numOfState;i++)
{
	if(iot==inside)
		temp_iScore.push_back(-1E10);
	else
		temp_oScore.push_back(-1E10);
}

		for(int pr=0;pr<numOfState;pr++)
		{
			if(iot==outside)
			{
				if(node.oScore(pr)<0)continue;
			}
			for(int ch=0;ch<numOfState;ch++)	
			{
				const BerkeleyUnaryRule* rule=ruleSet.getUnaryRuleByRule(ch,pr);
				if(rule==NULL)continue;
				if(ch==pr)continue;
				double ruleScore=rule->getScore(0,0);
				if(ruleScore>0)
				{
					if(iot==inside)
					{
						if(node.iScore(ch)<0)continue;
						//if(node.iScore(pr)<0)node.iScore(pr)=0;
						//node.iScore(pr)=max(node.iScore(ch)*ruleScore,node.iScore(pr));
						if(temp_iScore[pr]<0)temp_iScore[pr]=0;
						temp_iScore[pr]=max(node.iScore(ch)*ruleScore,temp_iScore[pr]);
					}
					else if(iot==outside)
					{
						if(node.oScore(pr)<0)continue;
						//if(node.oScore(ch)<0)node.oScore(ch)=0;
						//node.oScore(ch)=max(node.oScore(pr)*ruleScore,node.oScore(ch));
						if(temp_oScore[ch]<0)temp_oScore[ch]=0;
						temp_oScore[ch]=max(node.oScore(pr)*ruleScore,temp_oScore[ch]);
					}
				}
			}
		}
		for(int i=0;i<numOfState;i++)
		{
			if(iot==inside)
				node.iScore(i)=max(node.iScore(i),temp_iScore[i]);
			else if(iot==outside)
				node.oScore(i)=max(node.oScore(i),temp_oScore[i]);
		}

		if(iot==inside)
		for(int i=0;i<numOfState;i++)
		{
			if(node.iScore(i)>0)
			{
				extentInfo.update(node.start(),node.stop(),i);
			}
		}
		
	node.set_allowState_withoutLabel_for_initialLevel(1,0,0);
	//cout<<"allow State:"<<endl;
	//asi.print(cout);
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x48(%rsp)
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, 0x50(%rsp)
movq 0x390(%rdi), %r15
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movapd %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movapd %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movslq %r15d, %r14
movq %r14, %rsi
callq 0xc0e8
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xc0e8
xorl %eax, %eax
testl %r15d, %r15d
cmovgl %r15d, %eax
movabsq $-0x3dfd5fa0e0000000, %r12 # imm = 0xC202A05F20000000
leaq 0x8(%rsp), %r13
leaq 0x10(%rsp), %r14
movl %eax, 0x4(%rsp)
movl %eax, %r15d
subl $0x1, %r15d
jb 0x1dfbe
testl %ebp, %ebp
je 0x1dfaa
movq %r12, 0x8(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xc764
jmp 0x1df8e
movq %r12, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0xc764
jmp 0x1df8e
movq 0xe8(%rbx), %rax
movl 0x4(%rsp), %r12d
leaq (%r12,%r12,2), %rcx
xorl %edx, %edx
xorpd %xmm0, %xmm0
xorl %esi, %esi
cmpq %r12, %rsi
je 0x1e0bd
cmpl $0x1, %ebp
jne 0x1dff4
ucomisd (%rax,%rsi,8), %xmm0
jbe 0x1dff4
incq %rsi
addq $0x3, %rdx
jmp 0x1dfd6
movq 0x50(%rsp), %rdi
movq 0x1f0(%rdi), %rdi
leaq (,%rsi,8), %r8
movq 0xe8(%rbx), %r9
addq %r8, %r9
movq 0x10(%rsp), %r10
movq 0xd0(%rbx), %r11
addq 0x30(%rsp), %r8
xorl %r14d, %r14d
cmpq %r14, %rcx
je 0x1dfeb
cmpq %r14, %rdx
je 0x1e0ac
movq (%rdi,%r14,8), %r15
movq (%r15,%rsi,8), %r15
testq %r15, %r15
je 0x1e0ac
movq (%r15), %r15
movq (%r15), %r15
movsd (%r15), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1e0ac
testl %ebp, %ebp
je 0x1e075
cmpl $0x1, %ebp
jne 0x1e0ac
movsd (%r9), %xmm2
ucomisd %xmm2, %xmm0
ja 0x1e0ac
movsd (%r10), %xmm3
ucomisd %xmm3, %xmm0
movq %r10, %r15
movq %r9, %r13
ja 0x1e091
jmp 0x1e09f
movsd (%r11), %xmm2
ucomisd %xmm2, %xmm0
ja 0x1e0ac
movsd (%r8), %xmm3
ucomisd %xmm3, %xmm0
movq %r8, %r15
movq %r11, %r13
jbe 0x1e09f
andq $0x0, (%r15)
movsd (%r13), %xmm2
xorpd %xmm3, %xmm3
mulsd %xmm2, %xmm1
maxsd %xmm1, %xmm3
movsd %xmm3, (%r15)
addq $0x3, %r14
addq $0x8, %r11
addq $0x8, %r10
jmp 0x1e026
movq 0xd0(%rbx), %rax
movq 0xe8(%rbx), %rcx
movq 0x10(%rsp), %rdx
movq 0x30(%rsp), %rsi
xorl %edi, %edi
cmpq %rdi, %r12
je 0x1e108
movq %rax, %r8
movq %rsi, %r9
testl %ebp, %ebp
je 0x1e0f1
cmpl $0x1, %ebp
jne 0x1e103
movq %rcx, %r8
movq %rdx, %r9
movsd (%r9,%rdi,8), %xmm0
maxsd (%r8,%rdi,8), %xmm0
movsd %xmm0, (%r8,%rdi,8)
incq %rdi
jmp 0x1e0d7
testl %ebp, %ebp
movq 0x48(%rsp), %r15
je 0x1e14d
movsd 0x1406f(%rip), %xmm0    # 0x32188
xorpd %xmm1, %xmm1
xorps %xmm2, %xmm2
movq %rbx, %rdi
callq 0x2afc6
leaq 0x10(%rsp), %rdi
callq 0x6122
leaq 0x30(%rsp), %rdi
callq 0x6122
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
xorpd %xmm1, %xmm1
cmpq %r14, %r12
je 0x1e111
movq 0xd0(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1e187
movl 0xb0(%rbx), %esi
movl 0xb4(%rbx), %edx
movq %r15, %rdi
movl %r14d, %ecx
callq 0x154a2
xorpd %xmm1, %xmm1
incq %r14
jmp 0x1e154
jmp 0x1e192
jmp 0x1e192
jmp 0x1e192
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6122
leaq 0x30(%rsp), %rdi
callq 0x6122
movq %rbx, %rdi
callq 0x34f0
nop