// File: /workspace/github_cpp_makefile_star2_O1/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
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, 0x48(%rsp)
movq 0x390(%rdi), %r12
xorl %eax, %eax
movq %rax, 0x30(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movapd %xmm0, (%rsp)
cmpq %rax, 0x28(%rsp)
je 0x2590a
movq $0x0, 0x28(%rsp)
movq (%rsp), %rax
cmpq %rax, 0x8(%rsp)
je 0x2591a
movq %rax, 0x8(%rsp)
movq %rcx, 0x50(%rsp)
movslq %r12d, %r15
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0xf41a
movq %rsp, %rdi
movq %r15, %rsi
callq 0xf41a
testl %r12d, %r12d
jle 0x259b2
movabsq $-0x3dfd5fa0e0000000, %r14 # imm = 0xC202A05F20000000
leaq 0x40(%rsp), %r13
movl %r12d, %r15d
testl %ebp, %ebp
je 0x25974
movq %r14, 0x40(%rsp)
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x25993
movq %r14, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x259ad
movq %r14, 0x40(%rsp)
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x259a0
movq %r14, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rsp)
jmp 0x259ad
movq %rsp, %rdi
movq %r13, %rdx
callq 0xfaa4
jmp 0x259ad
leaq 0x20(%rsp), %rdi
movq %r13, %rdx
callq 0xfaa4
decl %r15d
jne 0x25951
testl %r12d, %r12d
jle 0x25aa8
movq 0xe8(%rbx), %rax
movq 0x48(%rsp), %rcx
movq 0x1f0(%rcx), %rcx
movl %r12d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorpd %xmm0, %xmm0
cmpl $0x1, %ebp
jne 0x259ed
ucomisd (%rax,%rsi,8), %xmm0
ja 0x25a9c
leaq (,%rsi,8), %rdi
movq 0xe8(%rbx), %r8
addq %rdi, %r8
movq (%rsp), %r9
movq 0xd0(%rbx), %r10
addq 0x20(%rsp), %rdi
movq %rcx, %r11
xorl %r15d, %r15d
cmpq %r15, %rsi
je 0x25a84
movq (%r11), %r14
movq (%r14,%rsi,8), %r14
testq %r14, %r14
je 0x25a84
movq (%r14), %r14
movq (%r14), %r14
movsd (%r14), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x25a84
testl %ebp, %ebp
je 0x25a56
cmpl $0x1, %ebp
jne 0x25a84
ucomisd (%r8), %xmm0
ja 0x25a84
ucomisd (%r9), %xmm0
movq %r9, %r14
movq %r8, %r13
ja 0x25a69
jmp 0x25a70
ucomisd (%r10), %xmm0
ja 0x25a84
ucomisd (%rdi), %xmm0
movq %rdi, %r14
movq %r10, %r13
jbe 0x25a70
movq $0x0, (%r14)
mulsd (%r13), %xmm1
movsd (%r14), %xmm2
maxsd %xmm1, %xmm2
movsd %xmm2, (%r14)
incq %r15
addq $0x8, %r9
addq $0x8, %r10
addq $0x18, %r11
cmpq %r15, %rdx
jne 0x25a15
incq %rsi
cmpq %rdx, %rsi
jne 0x259dd
testl %r12d, %r12d
movq 0x50(%rsp), %r14
jle 0x25b04
movq 0xd0(%rbx), %rax
movq 0xe8(%rbx), %rcx
movq (%rsp), %rdx
movq 0x20(%rsp), %rsi
movl %r12d, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movq %rax, %r9
movq %rsi, %r10
testl %ebp, %ebp
je 0x25aea
cmpl $0x1, %ebp
jne 0x25afc
movq %rcx, %r9
movq %rdx, %r10
movsd (%r10,%r8,8), %xmm0
maxsd (%r9,%r8,8), %xmm0
movsd %xmm0, (%r9,%r8,8)
incq %r8
cmpq %r8, %rdi
jne 0x25ad5
testl %ebp, %ebp
sete %al
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x25b5a
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
xorl %r15d, %r15d
xorpd %xmm1, %xmm1
movq 0xd0(%rbx), %rax
movsd (%rax,%r15,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25b52
movl 0xb0(%rbx), %esi
movl 0xb4(%rbx), %edx
movq %r14, %rdi
movl %r15d, %ecx
callq 0x1aa3a
xorpd %xmm1, %xmm1
incq %r15
cmpq %r15, %r12
jne 0x25b24
movsd 0x1b626(%rip), %xmm0    # 0x41188
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %rbx, %rdi
callq 0x37c60
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25b88
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x25b9f
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25bb6
jmp 0x25bb6
jmp 0x25bb6
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25bcf
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x25be6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq %rbx, %rdi
callq 0x3530