// File: /workspace/github_cpp_makefile_star2_O1/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::get_follow(std::vector<bool, std::allocator<bool>>, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>)
vector<vector<int> > Grammar::get_follow(vector<bool> local_is_epsilon, vector<vector<int> > local_first_sets ) {
	vector<vector<int> > temp_follow(num_nonterminals + 1, vector<int>(0));
	int count = 0;

	while(count < 20) {

		for(int i = 0; i < full_rules.size(); i++) {
			for(int j = 1; j < full_rules[i].size(); j++) {
				// terminal 不存在follow集，退出
				if(full_rules[i][j] < 0) 
					continue;
				// nonterminal
				else if(full_rules[i][j] > 0) {

					for(int k = j + 1; k < full_rules[i].size(); k++) {
						// 
						if(full_rules[i][k] == 0 && temp_follow[full_rules[i][0]].size() != 0) {
							// 
							temp_follow[full_rules[i][j]] = _push_unique_elements(temp_follow[full_rules[i][j]], temp_follow[full_rules[i][0]]);

						} else if(temp_follow[full_rules[i][k]].size() == 0) break;

						// terminal
						else if(full_rules[i][k] < 0) {
							// push
							if(!_in_array(temp_follow[full_rules[i][j]], abs(full_rules[i][k]))) {
								temp_follow[full_rules[i][j]].push_back(abs(full_rules[i][k]));
							}
							break;
						}
						//  full_rules[i][k] - nontermail
						else if(full_rules[i][k] > 0) {
							// 
							temp_follow[full_rules[i][j]] = _push_unique_elements(temp_follow[full_rules[i][j]], local_first_sets[full_rules[i][k]]);

							if(local_is_epsilon[full_rules[i][k] - 1]) continue;
							else break;
						}
					}
				} else break;

			}
		}
		++count;
	}

	return temp_follow;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq %rsi, %r14
movslq 0x4(%rsi), %rsi
incq %rsi
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq -0x41(%rbp), %rcx
movq %rdi, -0x40(%rbp)
callq 0x5f18
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3895
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
xorl %eax, %eax
leaq -0x60(%rbp), %rbx
movq %r14, -0x38(%rbp)
movq %rax, -0x70(%rbp)
movq 0x2d0(%r14), %rax
cmpq 0x2c8(%r14), %rax
je 0x3d27
xorl %edx, %edx
movq 0x2c8(%r14), %rcx
movq %rdx, -0x78(%rbp)
leaq (%rdx,%rdx,2), %rdx
movq (%rcx,%rdx,8), %rax
movq %rdx, -0x30(%rbp)
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
cmpq $0x5, %rcx
jb 0x3cf7
movl $0x2, %ecx
movq %rcx, -0x68(%rbp)
movl $0x1, %r13d
cmpl $0x0, (%rax,%r13,4)
js 0x3cc8
movq -0x38(%rbp), %r14
je 0x3cf7
leaq 0x1(%r13), %rdx
movq 0x2c8(%r14), %rcx
movq -0x30(%rbp), %rsi
movq (%rcx,%rsi,8), %rax
movq 0x8(%rcx,%rsi,8), %rsi
subq %rax, %rsi
sarq $0x2, %rsi
cmpq %rdx, %rsi
jbe 0x3cc8
movq -0x30(%rbp), %rdx
leaq (%rcx,%rdx,8), %rcx
movq -0x68(%rbp), %r15
movslq (%rax,%r15,4), %rdx
testq %rdx, %rdx
je 0x3ab2
movq -0x40(%rbp), %rsi
movq (%rsi), %rsi
leaq (%rdx,%rdx,2), %rdi
movq 0x8(%rsi,%rdi,8), %r8
cmpq (%rsi,%rdi,8), %r8
je 0x3cc8
testl %edx, %edx
js 0x3bdb
testl %edx, %edx
je 0x3ba9
movq (%rcx), %rax
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x5fba
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax,%r15,4), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
movq -0x88(%rbp), %rax
addq (%rax), %rsi
leaq -0xd0(%rbp), %r14
movq %r14, %rdi
callq 0x5fba
movq %rbx, %rdi
leaq -0xa0(%rbp), %rdx
movq %r14, %rcx
callq 0x3e00
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
movq -0x40(%rbp), %rax
addq (%rax), %rdi
movq %rbx, %rsi
callq 0x6858
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3a19
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x3a34
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x3a4f
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax,%r15,4), %rax
leaq -0x1(%rax), %rcx
addq $0x3e, %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
shlq $0x3, %rax
movq -0x80(%rbp), %rdx
addq (%rdx), %rax
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
leaq 0x3f(%rdi), %rdx
andq %rcx, %rdx
xorl %esi, %esi
cmpq %rdi, %rdx
setbe %sil
movq -0x8(%rax,%rsi,8), %rax
btq %rcx, %rax
jb 0x3ba9
jmp 0x3cc8
movslq (%rax), %rdi
movq -0x40(%rbp), %rsi
movq (%rsi), %rsi
leaq (%rdi,%rdi,2), %rdi
movq 0x8(%rsi,%rdi,8), %r8
cmpq (%rsi,%rdi,8), %r8
je 0x3947
movq (%rcx), %rax
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x5fba
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
movq -0x40(%rbp), %rax
addq (%rax), %rsi
leaq -0xe8(%rbp), %r12
movq %r12, %rdi
callq 0x5fba
movq %rbx, %rdi
leaq -0xb8(%rbp), %rdx
movq %r12, %rcx
callq 0x3e00
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
movq -0x40(%rbp), %rax
addq (%rax), %rdi
movq %rbx, %rsi
callq 0x6858
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3b73
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x3b8e
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x3ba9
movq -0xa8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
incq %r15
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
leaq (%rax,%rcx,8), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r15, %rdx
ja 0x393a
jmp 0x3cc8
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rsi,%rax,8), %rsi
leaq -0x100(%rbp), %rdi
callq 0x5fba
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax,%r15,4), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rcx
subq %rdi, %rcx
je 0x3c5a
sarq $0x2, %rcx
cmpq $0x1, %rcx
movq %rcx, %rdx
adcq $0x0, %rdx
movb $0x1, %r14b
cmpl %eax, (%rdi)
je 0x3c5d
movl $0x1, %r8d
movq %r8, %rsi
cmpq %r8, %rdx
je 0x3c51
leaq 0x1(%rsi), %r8
cmpl %eax, (%rdi,%rsi,4)
jne 0x3c40
cmpq %rsi, %rcx
seta %r14b
jmp 0x3c5d
xorl %r14d, %r14d
testq %rdi, %rdi
je 0x3c71
movq -0xf0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
testb %r14b, %r14b
jne 0x3cc8
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq (%rax,%r13,4), %rcx
movq -0x40(%rbp), %rdx
movq (%rdx), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movl (%rax,%r15,4), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movl %eax, -0x60(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3cc0
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x3cc8
movq %rbx, %rdx
callq 0x665a
incq %r13
movq -0x38(%rbp), %r14
movq 0x2c8(%r14), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
incq -0x68(%rbp)
cmpq %r13, %rcx
ja 0x38f1
movq 0x2d0(%r14), %rax
subq 0x2c8(%r14), %rax
movq -0x78(%rbp), %rdx
incq %rdx
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rdx, %rax
ja 0x38b9
movq -0x70(%rbp), %rax
incl %eax
cmpl $0x14, %eax
jne 0x389f
movq -0x40(%rbp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x3df7
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x3df7
jmp 0x3dab
jmp 0x3dab
jmp 0x3dab
movq %rax, %r14
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0x3d96
movq -0xd8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x3d96
movq %rax, %r14
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0x3dee
movq -0xa8(%rbp), %rsi
jmp 0x3de6
movq %rax, %r14
jmp 0x3dee
movq %rax, %r14
jmp 0x3dd3
movq %rax, %r14
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x3dd3
movq -0xc0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x3dee
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x40(%rbp), %rdi
callq 0x2650
movq %r14, %rdi
callq 0x22e0
nop