// File: /workspace/github_cpp_makefile_star2_O2/kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::closure(xbytes::lr_state&)
void xbytes::closure(lr_state& s)
{
	while(true)
	{
		int change_count = 0;
		for(int i = 0; i < s.terms.size(); ++i)
		{
			term* t = s.terms[i];
			if(t->is_completed) continue;
			if(t->dot >= t->r->rights.size()) continue;
			if(t->r->rights[t->dot]->type == ST_TERMINAL) continue;

			symbol* ss = t->r->rights[t->dot];
			for(int j = 0; j < ss->rules.size(); ++j)
			{				
				term tt;
				tt.r = ss->rules[j];
				tt.dot = 0;

				if(t->forwards.size() != 0)
				{
					for(int m = 0; m < t->forwards.size(); ++m)
					{
						for(int n = 0; n < t->forwards[m]->first_set.size(); ++n)
						{
							tt.forwards.push_back(t->forwards[m]->first_set[n]);
							change_count += add_term(s, tt);
							tt.forwards.clear();
						}
					}
				}
				if(t->dot < t->r->rights.size() - 1)
				{
					for(int m = 0; m < t->r->rights[t->dot+1]->first_set.size(); ++m)
					{
						tt.forwards.push_back(t->r->rights[t->dot+1]->first_set[m]);
						change_count += add_term(s, tt);
						tt.forwards.clear();
					}
				}
			}

			if(!change_count) t->is_completed = true;
		}

		if(!change_count) break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, -0x30(%rbp)
xorl %edx, %edx
xorl %r13d, %r13d
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rdx, %rcx
jbe 0x5053
movq %rdx, -0x68(%rbp)
movq (%rax,%rdx,8), %r12
cmpb $0x0, 0x28(%r12)
jne 0x5074
movslq 0x8(%r12), %rax
movq (%r12), %rdx
movq 0x30(%rdx), %rcx
movq 0x38(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
cmpq %rax, %rdx
jbe 0x5074
movq (%rcx,%rax,8), %rax
movq %rax, -0x70(%rbp)
cmpl $0x1, 0x48(%rax)
je 0x5074
xorl %r14d, %r14d
movq -0x70(%rbp), %rcx
movq 0x50(%rcx), %rax
movq 0x58(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x5066
leaq -0x50(%rbp), %rcx
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
movq (%rax,%r14,8), %rax
movq %rax, -0x60(%rbp)
andl $0x0, -0x58(%rbp)
movq 0x10(%r12), %rax
movq 0x18(%r12), %rcx
cmpq %rax, %rcx
je 0x4fc2
movq %r14, -0x78(%rbp)
xorl %ebx, %ebx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x4fbe
xorl %r15d, %r15d
xorl %r14d, %r14d
movq (%rax,%rbx,8), %rcx
movq 0x70(%rcx), %rsi
movq 0x78(%rcx), %rcx
subq %rsi, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x4fb4
addq %r15, %rsi
leaq -0x50(%rbp), %rdi
callq 0x7050
movq -0x30(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x5204
movq -0x50(%rbp), %rcx
cmpq %rcx, -0x48(%rbp)
je 0x4fa3
movq %rcx, -0x48(%rbp)
addl %eax, %r13d
incq %r14
movq 0x10(%r12), %rax
addq $0x8, %r15
jmp 0x4f64
incq %rbx
movq 0x18(%r12), %rcx
jmp 0x4f52
movq -0x78(%rbp), %r14
movslq 0x8(%r12), %rax
movq (%r12), %rdx
movq 0x30(%rdx), %rcx
movq 0x38(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
decq %rdx
cmpq %rax, %rdx
jbe 0x5042
xorl %r15d, %r15d
xorl %ebx, %ebx
cltq
movq 0x8(%rcx,%rax,8), %rax
movq 0x70(%rax), %rsi
movq 0x78(%rax), %rax
subq %rsi, %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x5042
addq %r15, %rsi
leaq -0x50(%rbp), %rdi
callq 0x7050
movq -0x30(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x5204
movq -0x50(%rbp), %rcx
cmpq %rcx, -0x48(%rbp)
je 0x5029
movq %rcx, -0x48(%rbp)
addl %eax, %r13d
incq %rbx
movq (%r12), %rcx
movl 0x8(%r12), %eax
movq 0x30(%rcx), %rcx
addq $0x8, %r15
jmp 0x4fe7
leaq -0x50(%rbp), %rdi
callq 0x8154
incq %r14
jmp 0x4f06
xorl %edx, %edx
testl %r13d, %r13d
movl $0x0, %r13d
jne 0x4ea0
jmp 0x5080
testl %r13d, %r13d
jne 0x5074
movb $0x1, 0x28(%r12)
xorl %r13d, %r13d
movq -0x68(%rbp), %rdx
incq %rdx
jmp 0x4ea0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5091
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x8154
movq %r14, %rdi
callq 0x2380
nop