// File: /workspace/github_cpp_makefile_star2_O2/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 $0xe8, %rsp
movq %rcx, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
movq %rdi, %rbx
movq %rsi, -0x38(%rbp)
movslq 0x4(%rsi), %r14
leaq -0x70(%rbp), %rdi
leaq -0x42(%rbp), %rdx
xorl %esi, %esi
callq 0x4b42
incq %r14
leaq -0x70(%rbp), %rdx
leaq -0x41(%rbp), %rcx
movq %rbx, -0x30(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4b94
leaq -0x70(%rbp), %rdi
callq 0x2632
xorl %eax, %eax
leaq -0xb0(%rbp), %r15
cmpl $0x14, %eax
je 0x361d
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rcx
xorl %edi, %edi
movq -0x38(%rbp), %rax
movq 0x2d0(%rax), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rdi, %rax
jbe 0x3612
movq %rdi, -0x80(%rbp)
imulq $0x18, %rdi, %rax
movq %rax, -0x40(%rbp)
pushq $0x2
popq %rax
movq %rax, -0x58(%rbp)
pushq $0x1
popq %r14
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rdx
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x2, %rsi
cmpq %r14, %rsi
jbe 0x3606
cmpl $0x0, (%rax,%r14,4)
js 0x35ef
je 0x3606
movq -0x58(%rbp), %r13
movq %r14, -0x50(%rbp)
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x35ef
movslq (%rax,%r13,4), %rcx
movq -0x30(%rbp), %rdx
movq (%rdx), %rsi
testq %rcx, %rcx
je 0x3480
imulq $0x18, %rcx, %rdx
movq 0x8(%rsi,%rdx), %rdi
cmpq (%rsi,%rdx), %rdi
je 0x35ef
testl %ecx, %ecx
js 0x3566
testl %ecx, %ecx
je 0x3546
movslq (%rax,%r14,4), %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
movq %r15, %rdi
callq 0x4c16
movq %r15, %r12
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movslq (%rax,%r13,4), %rax
imulq $0x18, %rax, %rsi
movq -0x90(%rbp), %rax
addq (%rax), %rsi
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
callq 0x4c16
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x36ae
movq %r13, -0x98(%rbp)
movq -0x38(%rbp), %r13
movq 0x2c8(%r13), %rax
movq %r14, %rcx
movq -0x40(%rbp), %r14
movq (%rax,%r14), %rax
movslq (%rax,%rcx,4), %rax
imulq $0x18, %rax, %rdi
movq -0x30(%rbp), %rax
addq (%rax), %rdi
movq %rbx, %rsi
callq 0x54e4
movq %rbx, %rdi
callq 0x2632
movq %r15, %rdi
callq 0x2632
movq %r12, %rdi
callq 0x2632
movq 0x2c8(%r13), %rax
movq -0x98(%rbp), %r13
movq (%rax,%r14), %rax
movslq (%rax,%r13,4), %rsi
decq %rsi
movq -0x88(%rbp), %rdi
callq 0x4bf4
movq %r12, %r15
testq %rdx, (%rax)
movq -0x50(%rbp), %r14
jne 0x3546
jmp 0x35ef
movslq (%rax), %rdx
imulq $0x18, %rdx, %rdx
movq 0x8(%rsi,%rdx), %rdi
cmpq (%rsi,%rdx), %rdi
je 0x337b
movslq (%rax,%r14,4), %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
leaq -0xc8(%rbp), %rdi
callq 0x4c16
movq -0x38(%rbp), %rax
movq %rax, %r14
movq 0x2c8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movslq (%rax), %rax
imulq $0x18, %rax, %rsi
movq -0x30(%rbp), %rax
addq (%rax), %rsi
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
callq 0x4c16
leaq -0x70(%rbp), %rbx
movq %rbx, %rdi
leaq -0xc8(%rbp), %r15
movq %r15, %rdx
movq %r12, %rcx
callq 0x36ae
movq 0x2c8(%r14), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movq -0x50(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
imulq $0x18, %rax, %rdi
movq -0x30(%rbp), %rax
addq (%rax), %rdi
movq %rbx, %rsi
callq 0x54e4
movq %rbx, %rdi
callq 0x2632
movq %r12, %rdi
callq 0x2632
movq %r15, %rdi
callq 0x2632
leaq -0xb0(%rbp), %r15
movq -0x50(%rbp), %r14
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rdx
incq %r13
jmp 0x3357
movslq (%rax,%r14,4), %rax
imulq $0x18, %rax, %rax
addq %rax, %rsi
leaq -0x110(%rbp), %rbx
movq %rbx, %rdi
callq 0x4c16
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movl (%rax,%r13,4), %eax
movl %eax, %edx
negl %edx
cmovsl %eax, %edx
movq %rbx, %rsi
callq 0x3230
movl %eax, %r12d
movq %rbx, %rdi
callq 0x2632
testb %r12b, %r12b
jne 0x35ef
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx), %rax
movslq (%rax,%r14,4), %rcx
imulq $0x18, %rcx, %rdi
movq -0x30(%rbp), %rcx
addq (%rcx), %rdi
movl (%rax,%r13,4), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movl %ecx, -0x70(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x52cc
incq %r14
movq -0x38(%rbp), %rax
movq 0x2c8(%rax), %rcx
incq -0x58(%rbp)
jmp 0x331e
movq -0x80(%rbp), %rdi
incq %rdi
jmp 0x32e8
movq -0x78(%rbp), %rax
incl %eax
jmp 0x32ce
movq -0x30(%rbp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x2632
jmp 0x36a5
movq %rax, %r14
jmp 0x36a5
jmp 0x3696
jmp 0x3696
jmp 0x3696
movq %rax, %r14
jmp 0x3660
movq %rax, %r14
leaq -0xf8(%rbp), %rdi
callq 0x2632
leaq -0xc8(%rbp), %rdi
callq 0x2632
jmp 0x3699
jmp 0x3696
movq %rax, %r14
jmp 0x3684
movq %rax, %r14
leaq -0xe0(%rbp), %rdi
callq 0x2632
movq -0x30(%rbp), %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2632
jmp 0x369d
movq %rax, %r14
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x257e
movq %r14, %rdi
callq 0x22c0
nop