// File: neubig[P]egret/Egret/src/Forest.cpp
// Function: genUnaryNode_viterbi(ListRuleSet&, Node&)
bool genUnaryNode_viterbi(RuleSet& ruleSet,Node& node)
{
	bool mark=false;
	vector<string> ntPool;
	map<string,int> ntMap;
	ntPool.clear();
	ntMap.clear();
	node.setUnaryInOrder(ruleSet,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];
		pair<RuleSet::RSIter,RuleSet::RSIter> iterPair=ruleSet.query(rightPart);
		for(RuleSet::RSIter iter=iterPair.first;iter!=iterPair.second;iter++)
		{
			string leftPart=iter->second.left;
			if(node.find(leftPart)==node.end())
			{
				if(ntMap.find(leftPart)==ntMap.end())
					ntPool.push_back(leftPart);
				Label newLabel;
				newLabel.init(leftPart,oldLb.start(),oldLb.stop());
				node[leftPart]=newLabel;
			}
			double ruleScore=log(iter->second.prob);
			//jout<<"\n"<<leftPart<<"--->add Child: "<<rightPart<<endl;
			node[leftPart].addChild_viterbi(&oldLb,ruleScore);
			mark=true;
		}
	}
	return mark;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x8340
leaq -0x60(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x25300
movq -0x290(%rbp), %rdi
callq 0x8360
movq -0x298(%rbp), %rdi
callq 0x34100
movq -0x290(%rbp), %rdx
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x77990
jmp 0x5b5f5
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x87f0
movq %rax, %rcx
movq -0x2a0(%rbp), %rax
cmpq %rcx, %rax
jae 0x5b66a
movslq -0x70(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x8810
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x1d350
movq %rax, -0x2a8(%rbp)
jmp 0x5b641
movq -0x2a8(%rbp), %rax
movl $0x1, (%rax)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x5b5fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5bad7
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x87f0
movq %rax, %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x5baab
movslq -0x74(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x8810
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x4160
jmp 0x5b6b6
movq -0x10(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4b350
movq %rax, -0x2b8(%rbp)
jmp 0x5b6cf
movq -0x2b8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4160
jmp 0x5b6fd
movq -0x2c0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x89570
movq %rdx, -0x2d0(%rbp)
movq %rax, -0x2c8(%rbp)
jmp 0x5b720
movq -0x2d0(%rbp), %rax
movq -0x2c8(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4728
movq -0xb0(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0xb0(%rbp), %rsi
addq $0x8, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x5e510
testb $0x1, %al
jne 0x5b776
jmp 0x5ba83
leaq -0xd8(%rbp), %rdi
callq 0x5e540
movq %rax, %rsi
addq $0x20, %rsi
leaq -0xf8(%rbp), %rdi
callq 0x4160
jmp 0x5b797
movq -0x10(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4b7a0
movq %rax, -0x2d8(%rbp)
jmp 0x5b7b0
movq -0x2d8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4b7f0
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x4b770
testb $0x1, %al
jne 0x5b7ea
jmp 0x5b9f7
leaq -0x60(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x5e700
movq %rax, -0x2e0(%rbp)
jmp 0x5b803
movq -0x2e0(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x1d570
movq %rax, -0x118(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x1d540
testb $0x1, %al
jne 0x5b83a
jmp 0x5b88d
leaq -0x30(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x37000
jmp 0x5b84c
jmp 0x5b88d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5ba9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4728
jmp 0x5ba9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5ba75
leaq -0x230(%rbp), %rdi
callq 0x4b470
jmp 0x5b89b
leaq -0x250(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4160
jmp 0x5b8b0
movq -0xa0(%rbp), %rdi
callq 0x4b730
movl %eax, -0x2e4(%rbp)
jmp 0x5b8c4
movq -0xa0(%rbp), %rdi
callq 0x4b750
movl %eax, -0x2e8(%rbp)
jmp 0x5b8d8
leaq -0x271(%rbp), %rdi
movq %rdi, -0x2f0(%rbp)
callq 0x4660
movq -0x2f0(%rbp), %rdx
leaq 0x3555d(%rip), %rsi     # 0x90e56
leaq -0x270(%rbp), %rdi
callq 0x1c730
jmp 0x5b907
movl -0x2e8(%rbp), %ecx
movl -0x2e4(%rbp), %edx
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
leaq -0x270(%rbp), %r8
callq 0x5e570
jmp 0x5b92f
leaq -0x270(%rbp), %rdi
callq 0x4728
leaq -0x271(%rbp), %rdi
callq 0x43f0
leaq -0x250(%rbp), %rdi
callq 0x4728
movq -0x10(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4b350
movq %rax, -0x2f8(%rbp)
jmp 0x5b96c
movq -0x2f8(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x4b820
jmp 0x5b981
leaq -0x230(%rbp), %rdi
callq 0x46ba0
jmp 0x5b9f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5b9e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5b9dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x5b9d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x4728
leaq -0x271(%rbp), %rdi
callq 0x43f0
leaq -0x250(%rbp), %rdi
callq 0x4728
leaq -0x230(%rbp), %rdi
callq 0x46ba0
jmp 0x5ba75
leaq -0xd8(%rbp), %rdi
callq 0x5e540
movsd 0x60(%rax), %xmm0
callq 0x4300
movsd %xmm0, -0x280(%rbp)
movq -0x10(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x4b350
movq %rax, -0x300(%rbp)
jmp 0x5ba2e
movq -0x300(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movsd -0x280(%rbp), %xmm0
callq 0x68010
jmp 0x5ba4b
movb $0x1, -0x11(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4728
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
callq 0x5e5d0
movq %rax, -0x288(%rbp)
jmp 0x5b756
leaq -0xf8(%rbp), %rdi
callq 0x4728
jmp 0x5ba9d
leaq -0x98(%rbp), %rdi
callq 0x4728
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x5b671
leaq -0x98(%rbp), %rdi
callq 0x4728
jmp 0x5bad7
movb -0x11(%rbp), %al
movb %al, -0x301(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x25780
leaq -0x30(%rbp), %rdi
callq 0x8830
movb -0x301(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x25780
leaq -0x30(%rbp), %rdi
callq 0x8830
movq -0x68(%rbp), %rdi
callq 0x4650
nopw %cs:(%rax,%rax)