// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r12
movq 0x390(%rdi), %rcx
xorl %eax, %eax
leaq 0x30(%rsp), %rdi
movq %rax, 0x10(%rdi)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rdi)
movq %rax, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movslq %ecx, %r14
movq %r14, %rsi
callq 0xf2d4
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xf2d4
cmpl $0x0, 0x8(%rsp)
jle 0x25517
movq %r12, 0x58(%rsp)
movq %r15, 0x60(%rsp)
movabsq $-0x3dfd5fa0e0000000, %r12 # imm = 0xC202A05F20000000
leaq 0x50(%rsp), %r13
leaq 0x10(%rsp), %r14
movq 0x8(%rsp), %rax
movl %eax, %r15d
testl %ebp, %ebp
je 0x25313
movq %r12, 0x50(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x25332
movq %r12, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x2534c
movq %r12, 0x50(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x2533f
movq %r12, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2534c
movq %r14, %rdi
movq %r13, %rdx
callq 0xf936
jmp 0x2534c
leaq 0x30(%rsp), %rdi
movq %r13, %rdx
callq 0xf936
decl %r15d
jne 0x252f0
cmpl $0x0, 0x8(%rsp)
movq 0x60(%rsp), %r13
movq 0x58(%rsp), %rax
jle 0x25517
movq 0xe8(%rbx), %rcx
movq 0x1f0(%rax), %rdx
movq 0x8(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %esi, %esi
xorpd %xmm0, %xmm0
cmpl $0x1, %ebp
jne 0x25394
ucomisd (%rcx,%rsi,8), %xmm0
ja 0x25457
leaq (,%rsi,8), %rdi
movq 0xe8(%rbx), %r8
addq %rdi, %r8
movq 0x10(%rsp), %r9
movq 0xd0(%rbx), %r10
addq 0x30(%rsp), %rdi
movq %rdx, %r11
xorl %r14d, %r14d
cmpq %r14, %rsi
je 0x2543f
movq (%r11), %r15
movq (%r15,%rsi,8), %r15
testq %r15, %r15
je 0x2543f
movq (%r15), %r15
movq (%r15), %r15
movsd (%r15), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x2543f
testl %ebp, %ebp
je 0x25406
cmpl $0x1, %ebp
jne 0x2543f
movsd (%r8), %xmm2
ucomisd %xmm2, %xmm0
ja 0x2543f
movsd (%r9), %xmm3
ucomisd %xmm3, %xmm0
movq %r9, %r15
movq %r8, %r12
ja 0x25421
jmp 0x25432
movsd (%r10), %xmm2
ucomisd %xmm2, %xmm0
ja 0x2543f
movsd (%rdi), %xmm3
ucomisd %xmm3, %xmm0
movq %rdi, %r15
movq %r10, %r12
jbe 0x25432
movq $0x0, (%r15)
movsd (%r12), %xmm2
xorpd %xmm3, %xmm3
mulsd %xmm2, %xmm1
maxsd %xmm1, %xmm3
movsd %xmm3, (%r15)
incq %r14
addq $0x8, %r9
addq $0x8, %r10
addq $0x18, %r11
cmpq %r14, %rax
jne 0x253bd
incq %rsi
cmpq %rax, %rsi
jne 0x25384
cmpl $0x0, 0x8(%rsp)
jle 0x25517
movq 0xd0(%rbx), %rcx
movq 0xe8(%rbx), %rdx
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %rdi
xorl %r8d, %r8d
movq %rcx, %r9
movq %rdi, %r10
testl %ebp, %ebp
je 0x2549e
cmpl $0x1, %ebp
jne 0x254b0
movq %rdx, %r9
movq %rsi, %r10
movsd (%r10,%r8,8), %xmm0
maxsd (%r9,%r8,8), %xmm0
movsd %xmm0, (%r9,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x25489
cmpl $0x0, 0x8(%rsp)
setle %al
testl %ebp, %ebp
setne %cl
orb %al, %cl
jne 0x25517
movq 0x8(%rsp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rsp)
xorl %r14d, %r14d
xorpd %xmm1, %xmm1
movq 0xd0(%rbx), %rax
movsd (%rax,%r14,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x2550d
movl 0xb0(%rbx), %esi
movl 0xb4(%rbx), %edx
movq %r13, %rdi
movl %r14d, %ecx
callq 0x1a3a6
xorpd %xmm1, %xmm1
incq %r14
cmpq %r14, 0x8(%rsp)
jne 0x254df
movsd 0x1ac69(%rip), %xmm0    # 0x40188
xorpd %xmm1, %xmm1
xorpd %xmm2, %xmm2
movq %rbx, %rdi
callq 0x370ce
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x25546
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2555d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25574
jmp 0x25574
jmp 0x25574
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2558e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x255a5
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
movq %rbx, %rdi
callq 0x3530
nop