// File: /workspace/github_cpp_makefile_star2_O3/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, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, %r12
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 0x5e1a
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x385c
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x2c8(%r12), %rax
movq 0x2d0(%r12), %rdx
xorl %esi, %esi
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rdx, %rcx
movq %rsi, -0x68(%rbp)
cmpq %rax, %rcx
je 0x3cc1
xorl %r9d, %r9d
leaq (%r9,%r9,2), %r15
movq (%rax,%r15,8), %rcx
movq 0x8(%rax,%r15,8), %rsi
movq %rsi, %rdi
subq %rcx, %rdi
cmpq $0x5, %rdi
jb 0x3ca2
movq %r9, -0x70(%rbp)
movl $0x2, %r13d
movl $0x1, %r14d
cmpl $0x0, (%rcx,%r14,4)
js 0x3b75
je 0x3c8c
leaq 0x1(%r14), %rdx
subq %rcx, %rsi
sarq $0x2, %rsi
movq %rdx, -0x30(%rbp)
cmpq %rdx, %rsi
jbe 0x3c49
movq %r13, -0x38(%rbp)
movslq (%rcx,%r13,4), %rsi
movq -0x40(%rbp), %rdx
movq (%rdx), %rdx
testq %rsi, %rsi
je 0x3a48
leaq (%rsi,%rsi,2), %rax
movq 0x8(%rdx,%rax,8), %rdi
cmpq (%rdx,%rax,8), %rdi
je 0x3c45
testl %esi, %esi
js 0x3b80
movslq (%rcx,%r14,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rsi
leaq -0x98(%rbp), %rdi
callq 0x5ebc
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rax
movslq (%rax,%r13,4), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
movq -0x80(%rbp), %rax
addq (%rax), %rsi
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
callq 0x5ebc
leaq -0x60(%rbp), %rdi
leaq -0x98(%rbp), %rdx
movq %rbx, %rcx
callq 0x3d9c
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rax
movslq (%rax,%r14,4), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rdi
movq 0x10(%rcx,%rax,8), %rsi
movq -0x60(%rbp), %rdx
movq %rdx, (%rcx,%rax,8)
movq -0x58(%rbp), %rdx
movq %rdx, 0x8(%rcx,%rax,8)
movq -0x50(%rbp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
testq %rdi, %rdi
je 0x39b8
subq %rdi, %rsi
callq 0x21d0
movq -0xc8(%rbp), %rdi
testq %rdi, %rdi
je 0x39d3
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x39ee
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rcx
movslq (%rcx,%r13,4), %rcx
decq %rcx
leal 0x3f(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x6, %edx
movslq %edx, %rdx
shlq $0x3, %rdx
movq -0x78(%rbp), %rsi
addq (%rsi), %rdx
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
leaq 0x3f(%r8), %rsi
andq %rcx, %rsi
xorl %edi, %edi
cmpq %r8, %rsi
setbe %dil
movq -0x8(%rdx,%rdi,8), %rdx
btq %rcx, %rdx
jb 0x3b54
jmp 0x3c45
movslq (%rcx), %rdi
leaq (%rdi,%rdi,2), %rdi
movq 0x8(%rdx,%rdi,8), %r8
cmpq (%rdx,%rdi,8), %r8
je 0x3b41
movslq (%rcx,%r14,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x5ebc
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rax
movslq (%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
movq -0x40(%rbp), %rax
addq (%rax), %rsi
leaq -0xf8(%rbp), %rbx
movq %rbx, %rdi
callq 0x5ebc
leaq -0x60(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
movq %rbx, %rcx
callq 0x3d9c
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rax
movslq (%rax,%r14,4), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rdi
movq 0x10(%rcx,%rax,8), %rsi
movq -0x60(%rbp), %rdx
movq %rdx, (%rcx,%rax,8)
movq -0x58(%rbp), %rdx
movq %rdx, 0x8(%rcx,%rax,8)
movq -0x50(%rbp), %rdx
movq %rdx, 0x10(%rcx,%rax,8)
testq %rdi, %rdi
je 0x3b01
subq %rdi, %rsi
callq 0x21d0
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0x3b1c
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3b37
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x2c8(%r12), %rax
jmp 0x3b54
leaq (%rsi,%rsi,2), %rcx
movq 0x8(%rdx,%rcx,8), %rsi
cmpq (%rdx,%rcx,8), %rsi
je 0x3c45
incq %r13
movq (%rax,%r15,8), %rcx
movq 0x8(%rax,%r15,8), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
ja 0x38e5
jmp 0x3c45
incq %r14
movq %r14, %rdi
jmp 0x3c4d
movslq (%rcx,%r14,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x5ebc
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rcx
movl (%rcx,%r13,4), %edx
movl %edx, %eax
negl %eax
cmovsl %edx, %eax
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
subq %rdi, %rdx
je 0x3bdf
sarq $0x2, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %ecx, %ecx
cmpl %eax, (%rdi,%rcx,4)
je 0x3c36
incq %rcx
cmpq %rcx, %rdx
jne 0x3bd0
jmp 0x3be4
testq %rdi, %rdi
je 0x3c0a
movq -0xd0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rcx
movl (%rcx,%r13,4), %edx
movl %edx, %eax
negl %eax
cmovsl %edx, %eax
movslq (%rcx,%r14,4), %rcx
movq -0x40(%rbp), %rdx
movq (%rdx), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movl %eax, -0x60(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3c79
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x3c45
movq -0xd0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
movq 0x2c8(%r12), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rax,%r15,8), %rsi
movq %rsi, %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
incq %r13
movq %rdi, %r14
cmpq %rdi, %rdx
ja 0x38b8
jmp 0x3c8c
leaq -0x60(%rbp), %rdx
callq 0x6596
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rdi
jmp 0x3c4d
movq 0x2d0(%r12), %rdx
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq -0x70(%rbp), %r9
incq %r9
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x3, %rsi
imulq %r8, %rsi
movq %rdx, %rcx
cmpq %r9, %rsi
ja 0x388b
jmp 0x3cc4
movq %rax, %rcx
movq -0x68(%rbp), %rsi
incl %esi
cmpl $0x14, %esi
jne 0x387b
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 0x3d94
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x3d94
jmp 0x3d48
jmp 0x3d48
movq %rax, %r14
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0x3d33
movq -0xe8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x3d33
jmp 0x3d48
movq %rax, %r14
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3d8b
movq -0xa0(%rbp), %rsi
jmp 0x3d83
movq %rax, %r14
jmp 0x3d8b
movq %rax, %r14
jmp 0x3d70
movq %rax, %r14
movq -0xc8(%rbp), %rdi
testq %rdi, %rdi
je 0x3d70
movq -0xb8(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x3d8b
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x40(%rbp), %rdi
callq 0x2690
movq %r14, %rdi
callq 0x22e0