// File: neubig[P]egret/Egret/src/Forest-Berkeley-2.cpp
// Function: genUnaryNode_withoutLabel_initLevel_berkeley(BerkeleyRuleSet const&, Node&, IorO)
bool genUnaryNode_withoutLabel_initLevel_berkeley(const BerkeleyRuleSet& ruleSet, Node& node, IorO iot)
{
/*
	const vector<int>& asi=node.set_allowState_withoutLabel_for_initialLevel(1,0,0);
	
	for(int chIter=0;chIter<asi.size();chIter++)
	{
		int ch=asi[chIter];
		//cerr<<"ch:"<<ch<<endl;
		const vector<BerkeleyUnaryRule*> rules=ruleSet.getUnaryRulesByChild(ch);
		for(int ruleIter=0;ruleIter<rules.size();ruleIter++)
		{
			BerkeleyUnaryRule* rule=rules[ruleIter];
			if(rule==NULL)continue;
			int pr=rule->parentState();
			if(ch==pr)continue;
			double ruleScore=rule->getScore(0,0);
			if(ruleScore>0)
			{
				if(iot==inside)
				{
					if(node.iScore(ch)<0)cerr<<"bug"<<endl;
					if(node.iScore(pr)<0)node.iScore(pr)=0;
					node.iScore(pr)+=node.iScore(ch)*ruleScore;
				}
				else if(iot==outside)
				{
					if(node.oScore(pr)<0)continue;
					if(node.oScore(ch)<0)node.oScore(ch)=0;
					node.oScore(ch)+=node.oScore(pr)*ruleScore;
				}
			}
		}
	}
*/

		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]);
		}

	node.set_allowState_withoutLabel_for_initialLevel(1,0,0);
	//cout<<"allow State:"<<endl;
	//asi.print(cout);
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x45690
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa270
movl %eax, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x21880
leaq -0x58(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x21880
movq -0xb0(%rbp), %rdi
callq 0x218a0
movq -0xb8(%rbp), %rdi
callq 0x218a0
movq -0xb0(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x21930
jmp 0x42209
movslq -0x24(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x21930
jmp 0x42218
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4229b
cmpl $0x0, -0x14(%rbp)
jne 0x4226f
movabsq $-0x3dfd5fa0e0000000, %rax # imm = 0xC202A05F20000000
movq %rax, -0x70(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x21a30
jmp 0x4224a
jmp 0x4228e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xd760
leaq -0x40(%rbp), %rdi
callq 0xd760
jmp 0x426dd
movabsq $-0x3dfd5fa0e0000000, %rax # imm = 0xC202A05F20000000
movq %rax, -0x78(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x21a30
jmp 0x4228c
jmp 0x4228e
jmp 0x42290
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x4221f
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x42563
cmpl $0x1, -0x14(%rbp)
jne 0x422e0
movq -0x10(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x456b0
movq %rax, -0xc0(%rbp)
jmp 0x422c9
movq -0xc0(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x422de
jmp 0x42555
jmp 0x422e0
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x42553
movq -0x8(%rbp), %rdi
movl -0x80(%rbp), %esi
movl -0x7c(%rbp), %edx
callq 0x456e0
movq %rax, -0xc8(%rbp)
jmp 0x4230b
movq -0xc8(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, -0x88(%rbp)
jne 0x42328
jmp 0x42545
movl -0x80(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jne 0x42335
jmp 0x42545
movq -0x88(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x45710
movsd %xmm0, -0xd0(%rbp)
jmp 0x4234f
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x42543
cmpl $0x0, -0x14(%rbp)
jne 0x4245c
movq -0x10(%rbp), %rdi
movl -0x80(%rbp), %esi
callq 0x45750
movq %rax, -0xd8(%rbp)
jmp 0x42393
movq -0xd8(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x423a8
jmp 0x42545
movslq -0x7c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa180
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x423d2
movslq -0x7c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa180
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
movl -0x80(%rbp), %esi
callq 0x45750
movq %rax, -0xe0(%rbp)
jmp 0x423e7
movq -0xe0(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x90(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa180
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x45780
movq %rax, -0xe8(%rbp)
jmp 0x4242b
movq -0xe8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf0(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa180
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x42541
cmpl $0x1, -0x14(%rbp)
jne 0x4253f
movq -0x10(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x456b0
movq %rax, -0xf8(%rbp)
jmp 0x4247b
movq -0xf8(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x42490
jmp 0x42545
movslq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa180
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x424ba
movslq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa180
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rdi
movl -0x7c(%rbp), %esi
callq 0x456b0
movq %rax, -0x100(%rbp)
jmp 0x424cf
movq -0x100(%rbp), %rax
movsd (%rax), %xmm0
movsd -0x90(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movslq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa180
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x45780
movq %rax, -0x108(%rbp)
jmp 0x42513
movq -0x108(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x110(%rbp)
movslq -0x80(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa180
movsd -0x110(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x42541
jmp 0x42543
jmp 0x42545
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x422e7
jmp 0x42555
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x422a2
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x426a5
cmpl $0x0, -0x14(%rbp)
jne 0x42609
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x45750
movq %rax, -0x118(%rbp)
jmp 0x4259e
movslq -0xa4(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xa180
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x45780
movq %rax, -0x120(%rbp)
jmp 0x425c6
movq -0x120(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x45750
movq %rax, -0x128(%rbp)
jmp 0x425f1
movq -0x128(%rbp), %rax
movsd -0x130(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x4268f
cmpl $0x1, -0x14(%rbp)
jne 0x4268d
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x456b0
movq %rax, -0x138(%rbp)
jmp 0x42627
movslq -0xa4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xa180
movq -0x138(%rbp), %rdi
movq %rax, %rsi
callq 0x45780
movq %rax, -0x140(%rbp)
jmp 0x4264f
movq -0x140(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x10(%rbp), %rdi
movl -0xa4(%rbp), %esi
callq 0x456b0
movq %rax, -0x148(%rbp)
jmp 0x4267a
movq -0x148(%rbp), %rax
movsd -0x150(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x4268f
jmp 0x42691
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x4256d
movq -0x10(%rbp), %rdi
movsd 0x4dab7(%rip), %xmm0    # 0x90168
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq 0x79cf0
jmp 0x426be
leaq -0x58(%rbp), %rdi
callq 0xd760
leaq -0x40(%rbp), %rdi
callq 0xd760
movb $0x1, %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x4650
nopw %cs:(%rax,%rax)