// File: /workspace/github_cpp_makefile_star2_O3/neubig[P]egret/Egret/src/Forest-Berkeley.cpp
// Function: genNewNode_byLabel_unconstrained_berkeley(BerkeleyRuleSet const&, Label&, Label&, Node&, DecodeType)
Node& genNewNode_byLabel_unconstrained_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 vector<BerkeleyBinaryRule*>& rules=ruleSet.getBinaryRulesByChilds(lc,rc);
	for(int i=0;(size_t)i<rules.size();i++)
	{
		BerkeleyBinaryRule* rule=rules[i];
		if(rule==NULL)continue;

		int prNumSubState=rule->parentNumSubState();
		int parentState=rule->parentState();

		for(int prsub=0;prsub<prNumSubState;prsub++)
		{
			double ruleScore=rule->getScore(lcsub,rcsub,prsub);
			if(ruleScore>-1E10)
			{
				string label_nt=ruleSet.state2term(parentState)+"_"+intToString(prsub);
				if(n3.find(label_nt)==n3.end())
				{
					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(parentState),_start,_stop,parentState,prsub);

					n3[label.nt()]=label;
				}
				// MAKE SURE THE RULESCORE IS IN NORMAL FORM
				if(decodetype==VITERBI)
					n3[label_nt].addChildPair_viterbi(&label1,&label2,ruleScore);
				else if(decodetype==IO)
					//n3[label.nt()].addChildPair_io_berkeley(&label1,&label2,ruleScore,io);
					n3[label_nt].addChildPair_io(&label1,&label2,ruleScore);
					//cout<<label11.nt()<<label31.nt()<<label21.nt()<<endl;
			}	
		}
	}

	return n3;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rcx, %r12
movq %rsi, 0x18(%rsp)
movslq 0x10c(%rsi), %rax
movq %rdx, 0x20(%rsp)
movslq 0x10c(%rdx), %rcx
movq %rdi, 0x48(%rsp)
movq 0x208(%rdi), %rdx
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rdx
leaq (%rcx,%rcx,2), %rsi
movq (%rdx,%rsi,8), %rax
movq 0x8(%rdx,%rsi,8), %rcx
cmpq %rax, %rcx
je 0x1ec8b
leaq (%rdx,%rsi,8), %rdx
movq %rdx, 0xc0(%rsp)
movq 0x20(%rsp), %rdx
movslq 0x110(%rdx), %rbx
movq 0x18(%rsp), %rdx
movslq 0x110(%rdx), %rsi
addq $0x298, 0x48(%rsp)      # imm = 0x298
leaq 0xb0(%rsp), %r15
leaq 0x8(%r12), %rdx
movq %rdx, 0xd8(%rsp)
xorl %edi, %edi
leaq 0x110(%rsp), %r13
movl %r8d, 0x54(%rsp)
movq %r12, 0x10(%rsp)
movq %rsi, 0xd0(%rsp)
movq (%rax,%rdi,8), %rdx
testq %rdx, %rdx
je 0x1ec75
movslq 0x84(%rdx), %r9
movq %r9, 0xe8(%rsp)
testq %r9, %r9
jle 0x1ec75
movq %rdi, 0xc8(%rsp)
movl 0x78(%rdx), %r12d
xorl %r14d, %r14d
movq %rdx, 0xe0(%rsp)
movq (%rdx), %rax
leaq (%rsi,%rsi,2), %rcx
movq (%rax,%rcx,8), %rax
leaq (%rbx,%rbx,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, 0x58(%rsp)
ucomisd 0x2195d(%rip), %xmm0    # 0x400d0
jbe 0x1ec48
leaq 0xa0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl %r12d, %edx
callq 0xb6e8
leaq 0x120(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x6afc
movq %r13, %rdi
leaq 0x219e8(%rip), %rsi     # 0x401ab
callq 0x3570
leaq 0x60(%rsp), %rdi
movl %r14d, %esi
callq 0x3fc3c
movq 0x110(%rsp), %rcx
movl $0xf, %edi
leaq 0x120(%rsp), %rax
cmpq %rax, %rcx
je 0x1e7f7
movq 0x120(%rsp), %rdi
movq 0x118(%rsp), %r8
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x1e82b
movl $0xf, %edi
leaq 0x70(%rsp), %r9
cmpq %r9, %rsi
je 0x1e826
movq 0x70(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x1e835
movq %r13, %rdi
callq 0x30d0
jmp 0x1e843
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3330
leaq 0x38(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x1e868
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x1e870
movupd (%rcx), %xmm0
movupd %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1e8a9
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x1e8ce
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1e8eb
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x21d54
cmpq 0xd8(%rsp), %rax
jne 0x1ebbd
movq %r13, %rdi
callq 0x1fe68
movq 0x18(%rsp), %rax
movl 0x48(%rax), %r15d
movl 0x4c(%rax), %eax
movq 0x20(%rsp), %rdx
movl 0x48(%rdx), %ecx
movl 0x4c(%rdx), %ebp
cmpl %r15d, %ecx
cmovll %ecx, %r15d
cmpl %ebp, %eax
cmovgl %eax, %ebp
movq 0x10(%rsp), %rax
cmpl 0xb0(%rax), %r15d
jne 0x1eca0
cmpl 0xb4(%rax), %ebp
jne 0x1eca0
leaq 0xf0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl %r12d, %edx
callq 0xb6e8
movl %r12d, %r13d
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x80(%rsp), %r12
movq %r12, %rdi
leaq 0x2252b(%rip), %rdx     # 0x40eb6
movq %rdx, %rsi
callq 0xb7d0
movq %r12, (%rsp)
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
movl %r15d, %edx
movl %ebp, %ecx
movl %r13d, %r12d
movl %r13d, %r8d
movl %r14d, %r9d
callq 0x1ffc8
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1e9df
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1ea04
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x10(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x1fdec
movq %rax, %r15
movb 0x110(%rsp), %al
movb %al, (%r15)
leaq 0x8(%r15), %rdi
leaq 0x118(%rsp), %rsi
callq 0x3150
leaq 0x28(%r15), %rdi
leaq 0x138(%rsp), %rsi
callq 0x3150
leaq 0x120(%rsp), %rcx
movb 0x40(%rcx), %al
movb %al, 0x50(%r15)
movq 0x38(%rcx), %rax
movq %rax, 0x48(%r15)
leaq 0x58(%r15), %rdi
leaq 0x168(%rsp), %rsi
callq 0x20524
leaq 0x70(%r15), %rdi
leaq 0x180(%rsp), %rsi
callq 0x20524
leaq 0x88(%r15), %rdi
leaq 0x198(%rsp), %rsi
callq 0x213d0
leaq 0x120(%rsp), %rax
movupd 0xa8(%rax), %xmm0
movupd %xmm0, 0xb8(%r15)
leaq 0xc8(%r15), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x208ac
leaq 0x120(%rsp), %rax
movupd 0xd0(%rax), %xmm0
movupd %xmm0, 0xe0(%r15)
movq %r15, %rdi
addq $0xf0, %rdi
leaq 0x200(%rsp), %rsi
callq 0x2123a
leaq 0x120(%rsp), %rcx
movl 0x100(%rcx), %eax
movl %eax, 0x110(%r15)
movq 0xf8(%rcx), %rax
movq %rax, 0x108(%r15)
leaq 0x200(%rsp), %rdi
callq 0x1cee0
movq 0x1d8(%rsp), %rdi
testq %rdi, %rdi
je 0x1eb3c
movq 0x1e8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
leaq 0x198(%rsp), %rdi
callq 0x1cf88
leaq 0x180(%rsp), %rdi
callq 0x1cf34
leaq 0x168(%rsp), %rdi
callq 0x1cf34
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
leaq 0xb0(%rsp), %r15
je 0x1eb90
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
leaq 0x110(%rsp), %r13
je 0x1ebbd
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32e0
movl 0x54(%rsp), %eax
cmpl $0x1, %eax
je 0x1ebf3
testl %eax, %eax
jne 0x1ec1c
movq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x58(%rsp), %xmm0
callq 0x2d056
jmp 0x1ec1c
movq 0x10(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1fdec
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x58(%rsp), %xmm0
xorl %ecx, %ecx
callq 0x2d63e
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1ec38
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xd0(%rsp), %rsi
movq 0xe0(%rsp), %rdx
incq %r14
cmpq %r14, 0xe8(%rsp)
jne 0x1e74c
movq 0xc0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq 0x10(%rsp), %r12
movq 0xc8(%rsp), %rdi
incq %rdi
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rdi, %rdx
ja 0x1e710
movq %r12, %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x216f6(%rip), %rdi     # 0x4039d
leaq 0x21714(%rip), %rsi     # 0x403c2
leaq 0x21798(%rip), %rcx     # 0x4044d
movl $0xe6, %edx
callq 0x31a0
movq %rax, %rbx
jmp 0x1ecec
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1ecec
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1ed8a
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1ed8a
jmp 0x1ed82
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1ed3f
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1ed3f
jmp 0x1ed3c
movq %rax, %rbx
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x1ed6b
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1ed6b
jmp 0x1ed82
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1edb3
movq 0xb0(%rsp), %rsi
jmp 0x1edab
movq %rax, %rbx
jmp 0x1ed97
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x2025c
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1edb3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32e0
movq %rbx, %rdi
callq 0x3530