// File: /workspace/github_cpp_makefile_star2_O3/neubig[P]egret/Egret/src/Forest-Berkeley.cpp
// Function: genUnaryNode_byLabel_unconstrained_berkeley(BerkeleyRuleSet const&, Node&, DecodeType)
bool genUnaryNode_byLabel_unconstrained_berkeley(const BerkeleyRuleSet& brSet, Node& node, DecodeType decodetype)
{
	bool mark=false;
	vector<string> ntPool;
	map<string,int> ntMap;
	ntPool.clear();
	ntMap.clear();
	node.setUnaryInOrder_berkeley(brSet,ntPool);

	for(int i=0;(size_t)i<ntPool.size();i++)
		ntMap[ntPool[i]]=1;

	for(int i=0;(size_t)i<ntPool.size();i++)
	{
		string rightPart=ntPool[i];
		//cout<<"here:"<<i<<","<<rightPart<<endl;
		Label& oldLb=node[rightPart];

		int state=oldLb.state();
		int chsub=oldLb.subState();
		
		const vector<BerkeleyUnaryRule*>& rules=brSet.getUnaryRulesByChild(state);
		const AllowStateInfo& asi=node.allowStateInfo();
		for(int k=0;(size_t)k<rules.size();k++)
		{
			BerkeleyUnaryRule* rule=rules[k];
			if(rule==NULL)continue;
			int chNumSubState=rule->childNumSubState();
			int prNumSubState=rule->parentNumSubState();
			int parentState=rule->parentState();

			if(!asi.inUse()||asi.isAllow(parentState))
			{
				for(int prsub=0;prsub<prNumSubState;prsub++)
				{
					if(!asi.inUse()||asi.isAllow(parentState,prsub))
					//for(int chsub=0;chsub<chNumSubState;chsub++)
					{
						double ruleScore=rule->getScore(chsub,prsub);
						if(ruleScore>-1E10)
						{
							Label label;
							label.init(brSet.state2term(parentState),oldLb.start(),oldLb.stop(),parentState,prsub);
							
							if(node.find(label.nt())==node.end())
								node[label.nt()]=label;
							
							if(decodetype==VITERBI)
							{   // MAKE SURE THE RULESCORE IS IN LOG FORM
								node[label.nt()].addChild_viterbi(&oldLb,ruleScore);
							}
							else if(decodetype==IO)
							{
								//node[label.nt()].addChild_io_berkeley(&oldLb,ruleScore,io);
								node[label.nt()].addChild_io(&oldLb,ruleScore);
							}
							mark=true;
						}
					}
				}
			}
		}
	}
	return mark;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %r15
xorpd %xmm0, %xmm0
leaq 0x20(%rsp), %rbx
movapd %xmm0, (%rbx)
xorl %eax, %eax
movq %rax, 0x10(%rbx)
leaq 0x210(%rsp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x208(%rsp), %rdi
callq 0x1517c
movq %r12, %r14
movq %r12, %rdi
movq %r15, 0x38(%rsp)
movq %r15, %rsi
movq %rbx, %rdx
callq 0x359e0
movl %ebp, 0x1c(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rax
cmpq %rsi, %rax
je 0x1da94
xorl %r15d, %r15d
leaq 0x208(%rsp), %rbx
xorl %r12d, %r12d
addq %r15, %rsi
movq %rbx, %rdi
callq 0xb866
movl $0x1, (%rax)
incq %r12
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rax
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
addq $0x20, %r15
cmpq %r12, %rcx
ja 0x1da63
cmpq %rsi, %rax
je 0x1df62
leaq 0x60(%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rax
addq $0x298, %rax            # imm = 0x298
movq %rax, 0xb8(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0xb0(%rsp)
xorl %r15d, %r15d
leaq 0x58(%rsp), %r12
xorl %ebx, %ebx
movq %r15, %rcx
shlq $0x5, %rcx
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq (%rsi,%rcx), %rax
movq 0x8(%rsi,%rcx), %rdx
addq %rax, %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x6afc
movq %r14, %rdi
movq %r12, %rsi
callq 0x1fdec
movq %r15, 0x98(%rsp)
movslq 0x10c(%rax), %rdx
movq 0x38(%rsp), %rcx
movq 0x220(%rcx), %rcx
leaq (%rdx,%rdx,2), %rdx
movq (%rcx,%rdx,8), %rsi
cmpq %rsi, 0x8(%rcx,%rdx,8)
je 0x1df1a
leaq (%rcx,%rdx,8), %rcx
movq %rcx, 0xa0(%rsp)
movq %rax, 0x10(%rsp)
movslq 0x110(%rax), %rax
movq %rax, 0xc0(%rsp)
xorl %r15d, %r15d
movq (%rsi,%r15,8), %r12
testq %r12, %r12
movq %r15, 0xa8(%rsp)
je 0x1def0
movl 0x58(%r12), %r13d
movl 0x60(%r12), %eax
cmpb $0x1, 0x90(%r14)
movq %rax, 0x50(%rsp)
jne 0x1dba1
movq 0x40(%rsp), %rdi
movl %r13d, %esi
callq 0x37944
cmpl $0x0, 0x50(%rsp)
setg %cl
andb %cl, %al
cmpb $0x1, %al
je 0x1dba9
jmp 0x1def0
testl %eax, %eax
jle 0x1def0
movq %r12, 0xc8(%rsp)
xorl %r12d, %r12d
cmpb $0x1, 0x90(%r14)
jne 0x1dbd6
movq 0x40(%rsp), %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x37986
testb %al, %al
je 0x1dee2
movq 0xc8(%rsp), %rax
movq (%rax), %rax
movq 0xc0(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x48(%rsp)
ucomisd 0x224cb(%rip), %xmm0    # 0x400d0
jbe 0x1dee2
leaq 0xf0(%rsp), %rdi
callq 0x1fe68
leaq 0xd0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
movl %r13d, %edx
callq 0xb6e8
movq 0x10(%rsp), %rax
movl 0x48(%rax), %ebx
movl 0x4c(%rax), %ebp
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %r15
movq %r15, %rdi
leaq 0x2325f(%rip), %rdx     # 0x40eb6
movq %rdx, %rsi
callq 0xb7d0
movq %r15, (%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
movl %ebx, %edx
movl %ebp, %ecx
movl %r13d, %r8d
movl %r12d, %r9d
callq 0x1ffc8
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1dca4
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x1dcc9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x32e0
movq %r14, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x21d54
cmpq 0xb0(%rsp), %rax
jne 0x1ddee
movq %r14, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rbx
movb 0xf0(%rsp), %al
movb %al, (%rbx)
leaq 0x8(%rbx), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x3150
leaq 0x28(%rbx), %rdi
leaq 0x118(%rsp), %rsi
callq 0x3150
leaq 0xf8(%rsp), %rcx
movb 0x48(%rcx), %al
movb %al, 0x50(%rbx)
movq 0x40(%rcx), %rax
movq %rax, 0x48(%rbx)
leaq 0x58(%rbx), %rdi
leaq 0x148(%rsp), %rsi
callq 0x20524
leaq 0x70(%rbx), %rdi
leaq 0x160(%rsp), %rsi
callq 0x20524
leaq 0x88(%rbx), %rdi
leaq 0x178(%rsp), %rsi
callq 0x213d0
leaq 0xf8(%rsp), %rax
movupd 0xb0(%rax), %xmm0
movupd %xmm0, 0xb8(%rbx)
leaq 0xc8(%rbx), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0x208ac
leaq 0xf8(%rsp), %rax
movupd 0xd8(%rax), %xmm0
movupd %xmm0, 0xe0(%rbx)
movq %rbx, %rdi
addq $0xf0, %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x2123a
leaq 0xf8(%rsp), %rcx
movl 0x108(%rcx), %eax
movl %eax, 0x110(%rbx)
movq 0x100(%rcx), %rax
movq %rax, 0x108(%rbx)
movl 0x1c(%rsp), %eax
cmpl $0x1, %eax
je 0x1de20
testl %eax, %eax
jne 0x1de45
movq %r14, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x10(%rsp), %rsi
movsd 0x48(%rsp), %xmm0
callq 0x2d28e
jmp 0x1de45
movq %r14, %rdi
leaq 0xf8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x10(%rsp), %rsi
movsd 0x48(%rsp), %xmm0
xorl %edx, %edx
callq 0x2d51a
leaq 0x1e0(%rsp), %rdi
callq 0x1cee0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x1de6f
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
leaq 0x178(%rsp), %rdi
callq 0x1cf88
leaq 0x160(%rsp), %rdi
callq 0x1cf34
leaq 0x148(%rsp), %rdi
callq 0x1cf34
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x1debb
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x1dee0
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x32e0
movb $0x1, %bl
incq %r12
cmpq %r12, 0x50(%rsp)
jne 0x1dbb4
movq 0xa8(%rsp), %r15
incq %r15
movq 0xa0(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rcx
subq %rsi, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x1db53
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1df36
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x98(%rsp), %r15
incq %r15
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r15, %rax
leaq 0x58(%rsp), %r12
ja 0x1dacf
jmp 0x1df64
xorl %ebx, %ebx
leaq 0x208(%rsp), %rdi
callq 0x10d92
leaq 0x20(%rsp), %rdi
callq 0x6186
andb $0x1, %bl
movl %ebx, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1df98
jmp 0x1df98
jmp 0x1dff7
movq %rax, %rbx
jmp 0x1e0b9
jmp 0x1dff7
jmp 0x1dff7
jmp 0x1dfff
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1dfd0
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1dfd0
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x1e002
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1e002
movq %rax, %rbx
jmp 0x1e09d
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x1cee0
movq 0x1b8(%rsp), %rdi
testq %rdi, %rdi
je 0x1e02c
movq 0x1c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
leaq 0x178(%rsp), %rdi
callq 0x1cf88
leaq 0x160(%rsp), %rdi
callq 0x1cf34
leaq 0x148(%rsp), %rdi
callq 0x1cf34
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x1e078
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x1e09d
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1e0b9
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32e0
leaq 0x208(%rsp), %rdi
callq 0x10d92
leaq 0x20(%rsp), %rdi
callq 0x6186
movq %rbx, %rdi
callq 0x3530