// File: /workspace/github_cpp_makefile_star2_O1/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
movl %r8d, 0x54(%rsp)
movq %rcx, 0x8(%rsp)
movq %rsi, 0x18(%rsp)
movslq 0x10c(%rsi), %rax
movq %rdx, 0x20(%rsp)
movslq 0x10c(%rdx), %rdx
movq %rdi, 0x48(%rsp)
movq 0x208(%rdi), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rcx
leaq (%rdx,%rdx,2), %rdx
movq (%rcx,%rdx,8), %rax
cmpq %rax, 0x8(%rcx,%rdx,8)
je 0x1f2d8
leaq (%rcx,%rdx,8), %rcx
movq %rcx, 0xc0(%rsp)
movq 0x20(%rsp), %rcx
movslq 0x110(%rcx), %r12
movq 0x18(%rsp), %rcx
movslq 0x110(%rcx), %rbx
addq $0x298, 0x48(%rsp)      # imm = 0x298
leaq 0xb0(%rsp), %r15
movq 0x8(%rsp), %rcx
addq $0x8, %rcx
movq %rcx, 0xd8(%rsp)
xorl %edx, %edx
leaq 0x110(%rsp), %r13
leaq 0x80(%rsp), %rbp
movq %rbx, 0xd0(%rsp)
movq %rdx, 0xc8(%rsp)
movq (%rax,%rdx,8), %rdx
testq %rdx, %rdx
je 0x1f2ae
movslq 0x84(%rdx), %rsi
testq %rsi, %rsi
jle 0x1f2ae
movl 0x78(%rdx), %eax
movl %eax, 0x14(%rsp)
xorl %r14d, %r14d
movq %rdx, 0xe8(%rsp)
movq %rsi, 0xe0(%rsp)
movq (%rdx), %rax
leaq (%rbx,%rbx,2), %rcx
movq (%rax,%rcx,8), %rax
leaq (%r12,%r12,2), %rcx
movq (%rax,%rcx,8), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm0, 0x78(%rsp)
ucomisd 0x2230c(%rip), %xmm0    # 0x410d0
jbe 0x1f2a2
leaq 0xa0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0xb792
leaq 0x120(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x6a88
movq %r13, %rdi
leaq 0x22396(%rip), %rsi     # 0x411ab
callq 0x3570
leaq 0x58(%rsp), %rdi
movl %r14d, %esi
callq 0x4092c
movq 0x110(%rsp), %rcx
movl $0xf, %esi
leaq 0x120(%rsp), %rax
cmpq %rax, %rcx
je 0x1ee49
movq 0x120(%rsp), %rsi
movq 0x118(%rsp), %r8
movq 0x60(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x1ee7a
movl $0xf, %esi
leaq 0x68(%rsp), %rdi
cmpq %rdi, 0x58(%rsp)
je 0x1ee75
movq 0x68(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x1ee89
movq 0x58(%rsp), %rsi
movq %r13, %rdi
callq 0x30d0
jmp 0x1ee97
leaq 0x58(%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 0x1eebc
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x1eec4
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 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1eefd
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x1ef22
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1ef3f
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x223b8
cmpq 0xd8(%rsp), %rax
jne 0x1f20f
movq %rbp, %rbx
movq %r13, %rdi
callq 0x204bc
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 0x8(%rsp), %rax
cmpl 0xb0(%rax), %r15d
jne 0x1f2ef
cmpl 0xb4(%rax), %ebp
jne 0x1f2ef
leaq 0xf0(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl 0x14(%rsp), %edx
callq 0xb792
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rbx, %r13
movq %rbx, %rdi
leaq 0x22ebb(%rip), %rdx     # 0x41e96
movq %rdx, %rsi
callq 0xb8a2
movq %r13, (%rsp)
leaq 0x110(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
movl %r15d, %edx
movl %ebp, %ecx
movl 0x14(%rsp), %r8d
movl %r14d, %r9d
callq 0x2061c
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1f02e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1f053
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x8(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x20440
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 0x20b88
leaq 0x70(%r15), %rdi
leaq 0x180(%rsp), %rsi
callq 0x20b88
leaq 0x88(%r15), %rdi
leaq 0x198(%rsp), %rsi
callq 0x21a40
leaq 0x120(%rsp), %rax
movupd 0xa8(%rax), %xmm0
movupd %xmm0, 0xb8(%r15)
leaq 0xc8(%r15), %rdi
leaq 0x1d8(%rsp), %rsi
callq 0x20ef0
leaq 0x120(%rsp), %rax
movupd 0xd0(%rax), %xmm0
movupd %xmm0, 0xe0(%r15)
movq %r15, %rdi
addq $0xf0, %rdi
leaq 0x200(%rsp), %rsi
callq 0x218ca
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 0x1d4e6
movq 0x1d8(%rsp), %rdi
testq %rdi, %rdi
je 0x1f18b
movq 0x1e8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32e0
leaq 0x198(%rsp), %rdi
callq 0x1d582
leaq 0x180(%rsp), %rdi
callq 0x1d534
leaq 0x168(%rsp), %rdi
callq 0x1d534
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
leaq 0xb0(%rsp), %r15
movq %rbx, %rbp
je 0x1f1e2
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
leaq 0x110(%rsp), %r13
je 0x1f20f
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32e0
movl 0x54(%rsp), %eax
cmpl $0x1, %eax
je 0x1f245
testl %eax, %eax
jne 0x1f26e
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x20440
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x78(%rsp), %xmm0
callq 0x2d83e
jmp 0x1f26e
movq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x20440
movq %rax, %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movsd 0x78(%rsp), %xmm0
xorl %ecx, %ecx
callq 0x2deca
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1f28a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xd0(%rsp), %rbx
movq 0xe8(%rsp), %rdx
movq 0xe0(%rsp), %rsi
incq %r14
cmpq %r14, %rsi
jne 0x1ed9d
movq 0xc8(%rsp), %rdx
incq %rdx
movq 0xc0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rdx, %rcx
ja 0x1ed5e
movq 0x8(%rsp), %rax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22095(%rip), %rdi     # 0x4138b
leaq 0x220b3(%rip), %rsi     # 0x413b0
leaq 0x22137(%rip), %rcx     # 0x4143b
movl $0xe6, %edx
callq 0x31a0
movq %rax, %rbx
jmp 0x1f33b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1f33b
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32e0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1f3d9
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1f3d9
jmp 0x1f3d1
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1f38e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1f38e
jmp 0x1f38b
movq %rax, %rbx
movq 0x110(%rsp), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x1f3ba
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x32e0
jmp 0x1f3ba
jmp 0x1f3d1
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1f402
movq 0xb0(%rsp), %rsi
jmp 0x1f3fa
movq %rax, %rbx
jmp 0x1f3e6
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x208b0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1f402
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32e0
movq %rbx, %rdi
callq 0x3530