// File: /workspace/github_cpp_makefile_star2_O3/neubig[P]egret/Egret/src/Forest-Berkeley.cpp
// Function: genNewNode_byLabel_constrained_berkeley(BerkeleyRuleSet const&, Label&, Label&, Node&, DecodeType)
Node& genNewNode_byLabel_constrained_berkeley(const BerkeleyRuleSet& ruleSet,Label& label1, Label& label2, Node& n3, DecodeType decodetype)
{
	int lc=label1.state(),lcsub=label1.subState(),rc=label2.state(),rcsub=label2.subState();
	
	const AllowStateInfo& asi=n3.allowStateInfo();
	const vector<pair<int,vector<int> > >& allowStateAndSubStates=asi.allowStateAndSubStates();

	for(int i=0;(size_t)i<allowStateAndSubStates.size();i++)
	{
		int pr=allowStateAndSubStates[i].first;
		const BerkeleyBinaryRule* rule=ruleSet.getBinaryRuleByRule(lc,rc,pr);
		if(rule==NULL)continue;

		const vector<int>& subStates=allowStateAndSubStates[i].second;
		for(int j=0;(size_t)j<subStates.size();j++)
		{
			int prsub=subStates[j];
	
				double ruleScore=rule->getScore(lcsub,rcsub,prsub);
				if(ruleScore>-1E10)
				{
					Label label;
					int _start=(int)min(label1.start(),label2.start());
					int _stop=(int)max(label1.stop(),label2.stop());
					assert(_start==n3.start()&&_stop==n3.stop());

					label.init(ruleSet.state2term(pr),_start,_stop,pr,prsub);
					
					if(n3.find(label.nt())==n3.end())
						n3[label.nt()]=label;
					
					if(decodetype==VITERBI)
						n3[label.nt()].addChildPair_viterbi(&label1,&label2,ruleScore);
					else if(decodetype==IO)
						// MAKE SURE THE RULESCORE IS IN NORMAL FORM
						n3[label.nt()].addChildPair_io(&label1,&label2,ruleScore);
				}
		}		
	}
	return n3;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movl %r8d, %ebp
movq %rdi, %r14
movslq 0x10c(%rsi), %r12
movq %rsi, 0x18(%rsp)
movslq 0x110(%rsi), %rax
movq %rax, 0xa8(%rsp)
movslq 0x10c(%rdx), %r13
movq %rdx, 0x20(%rsp)
movslq 0x110(%rdx), %rax
movq %rax, 0xa0(%rsp)
movq %rcx, 0x10(%rsp)
leaq 0x60(%rcx), %rdi
callq 0x3793e
movq (%rax), %rdi
movq %rax, 0x70(%rsp)
movq 0x8(%rax), %rcx
cmpq %rdi, %rcx
je 0x1e5c1
leaq 0x298(%r14), %rax
movq %rax, 0x88(%rsp)
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movsd 0x21f4c(%rip), %xmm0    # 0x400d0
movl %ebp, 0x2c(%rsp)
movq %r14, 0x68(%rsp)
movq %r12, 0x60(%rsp)
movq %r13, 0x58(%rsp)
movq %rax, %rbx
shlq $0x5, %rbx
movslq (%rdi,%rbx), %r15
movq 0x1d8(%r14), %rdx
leaq (%r12,%r12,2), %rsi
movq (%rdx,%rsi,8), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
movq (%rdx,%rsi,8), %rdx
movq (%rdx,%r15,8), %r8
testq %r8, %r8
je 0x1e5ab
addq %rdi, %rbx
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
cmpq %rdx, %rsi
je 0x1e5ab
movq %rax, 0x78(%rsp)
xorl %edi, %edi
movq %r8, 0x90(%rsp)
movslq (%rdx,%rdi,4), %rbp
movq (%r8), %rax
movq 0xa8(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movq 0xa0(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%rbp,8), %xmm1
movsd %xmm1, 0x30(%rsp)
ucomisd %xmm0, %xmm1
jbe 0x1e575
movq %rdi, 0x98(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x1fe68
movq 0x18(%rsp), %rax
movl 0x48(%rax), %r12d
movl 0x4c(%rax), %eax
movq 0x20(%rsp), %rdx
movl 0x48(%rdx), %ecx
movl 0x4c(%rdx), %r14d
cmpl %r12d, %ecx
cmovll %ecx, %r12d
cmpl %r14d, %eax
cmovgl %eax, %r14d
movq 0x10(%rsp), %rax
cmpl 0xb0(%rax), %r12d
jne 0x1e5d8
cmpl 0xb4(%rax), %r14d
jne 0x1e5d8
leaq 0xb0(%rsp), %rdi
movq 0x88(%rsp), %rsi
movl %r15d, %edx
callq 0xb6e8
movq %r15, %r13
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %r15
movq %r15, %rdi
leaq 0x22bfc(%rip), %rdx     # 0x40eb6
movq %rdx, %rsi
callq 0xb7d0
movq %r15, (%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
movl %r12d, %edx
movl %r14d, %ecx
movq %r13, %r15
movl %r15d, %r8d
movl %ebp, %r9d
callq 0x1ffc8
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1e306
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1e32b
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x21d54
cmpq 0x80(%rsp), %rax
jne 0x1e455
movq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rbp
movb 0xd0(%rsp), %al
movb %al, (%rbp)
leaq 0x8(%rbp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x3150
leaq 0x28(%rbp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x3150
leaq 0xd8(%rsp), %rcx
movb 0x48(%rcx), %al
movb %al, 0x50(%rbp)
movq 0x40(%rcx), %rax
movq %rax, 0x48(%rbp)
leaq 0x58(%rbp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x20524
leaq 0x70(%rbp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x20524
leaq 0x88(%rbp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x213d0
leaq 0xd8(%rsp), %rax
movupd 0xb0(%rax), %xmm0
movupd %xmm0, 0xb8(%rbp)
leaq 0xc8(%rbp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x208ac
leaq 0xd8(%rsp), %rax
movupd 0xd8(%rax), %xmm0
movupd %xmm0, 0xe0(%rbp)
movq %rbp, %rdi
addq $0xf0, %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x2123a
leaq 0xd8(%rsp), %rcx
movl 0x108(%rcx), %eax
movl %eax, 0x110(%rbp)
movq 0x100(%rcx), %rax
movq %rax, 0x108(%rbp)
movl 0x2c(%rsp), %eax
cmpl $0x1, %eax
je 0x1e48e
testl %eax, %eax
jne 0x1e4ba
movq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x30(%rsp), %xmm0
callq 0x2d056
jmp 0x1e4ba
movq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x30(%rsp), %xmm0
xorl %ecx, %ecx
callq 0x2d63e
leaq 0x1c0(%rsp), %rdi
callq 0x1cee0
movq 0x198(%rsp), %rdi
testq %rdi, %rdi
je 0x1e4e4
movq 0x1a8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
leaq 0x158(%rsp), %rdi
callq 0x1cf88
leaq 0x140(%rsp), %rdi
callq 0x1cf34
leaq 0x128(%rsp), %rdi
callq 0x1cf34
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x1e530
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e555
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
movsd 0x21b6b(%rip), %xmm0    # 0x400d0
movq 0x90(%rsp), %r8
movq 0x98(%rsp), %rdi
incq %rdi
movq %rsi, %rax
subq %rdx, %rax
sarq $0x2, %rax
cmpq %rdi, %rax
ja 0x1e1f0
movq 0x70(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rcx
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %r12
movq 0x58(%rsp), %r13
movq 0x78(%rsp), %rax
incq %rax
movq %rcx, %rdx
subq %rdi, %rdx
sarq $0x5, %rdx
cmpq %rax, %rdx
ja 0x1e197
movq 0x10(%rsp), %rax
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21dbe(%rip), %rdi     # 0x4039d
leaq 0x21ddc(%rip), %rsi     # 0x403c2
leaq 0x21df3(%rip), %rcx     # 0x403e0
movl $0xbc, %edx
callq 0x31a0
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1e61b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1e61b
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1e647
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1e647
jmp 0x1e644
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2025c
movq %rbx, %rdi
callq 0x3530