// File: /workspace/github_cpp_makefile_star2_O2/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::get_predict(std::vector<bool, std::allocator<bool>>, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>)
vector<vector<int> > Grammar::get_predict(vector<bool> local_is_epsilon, vector<vector<int> > local_first_sets, vector<vector<int> > local_follow_sets) {
	vector<vector<int> > temp_predict_sets(num_rules, vector<int>(0));
	
	for(int i = 0; i < full_rules.size(); i++) {
		for(int j = 1; j < full_rules[i].size(); j++) {
			if(full_rules[i][j] == 0) {
				// end
				// 把当前nonterminal的follow集唯一的追加到predict集中
				temp_predict_sets[i] = _push_unique_elements(temp_predict_sets[i], local_follow_sets[full_rules[i][0]]); // Only push unique elements into the vector
				break;

			// terminal
			} else if(full_rules[i][j] < 0) { 
				// push
				temp_predict_sets[i].push_back(abs(full_rules[i][j]));
				break;

			// nonterminal
			} else { 
				temp_predict_sets[i] = _push_unique_elements(temp_predict_sets[i], local_first_sets[full_rules[i][j]]); // Only push unique elements
				// 若导空则追加follow(当前nonterminal的根nonterminal)
				if(local_is_epsilon[full_rules[i][j] - 1]) {
					if(full_rules[i][j + 1] == 0) {
						temp_predict_sets[i] = _push_unique_elements(temp_predict_sets[i], local_follow_sets[full_rules[i][0]]);
						break;
					}
					continue;
				} else break;
			}
		}
	}

	return temp_predict_sets;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %r8, -0x50(%rbp)
movq %rcx, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq %rdi, %r14
movq %rsi, -0x48(%rbp)
movslq 0x8(%rsi), %rbx
leaq -0x98(%rbp), %rdi
leaq -0x3a(%rbp), %rdx
xorl %esi, %esi
callq 0x4b42
leaq -0x98(%rbp), %rdx
leaq -0x39(%rbp), %rcx
movq %r14, -0x30(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4b94
leaq -0x98(%rbp), %r14
movq %r14, %rdi
callq 0x2632
xorl %edi, %edi
leaq -0x68(%rbp), %r9
leaq -0xe0(%rbp), %r12
movq -0x30(%rbp), %rsi
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rcx
movq 0x2d0(%rax), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %r8
idivq %r8
cmpq %rdi, %rax
jbe 0x3a3c
movq %rdi, -0x70(%rbp)
imulq $0x18, %rdi, %r13
movq (%rcx,%r13), %rax
pushq $0x1
popq %r15
movq %r13, -0x38(%rbp)
movq 0x8(%rcx,%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
jbe 0x3a30
movl (%rax,%r15,4), %eax
testl %eax, %eax
je 0x398d
js 0x3a11
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rbx
addq %rbx, %rsi
movq %r9, %rdi
callq 0x4c16
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rax
movq (%rax,%rbx), %rax
movslq (%rax,%r15,4), %rax
imulq $0x18, %rax, %rsi
movq -0x80(%rbp), %rax
addq (%rax), %rsi
movq %r12, %rdi
callq 0x4c16
movq %r14, %rdi
movq %r12, %rbx
movq %r14, %r12
leaq -0x68(%rbp), %rdx
movq %rbx, %rcx
callq 0x36ae
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %r13
addq %r13, %rdi
movq %r12, %rsi
callq 0x54e4
movq %r12, %r14
movq %r12, %rdi
callq 0x2632
movq %rbx, %rdi
callq 0x2632
leaq -0x68(%rbp), %rdi
callq 0x2632
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rax
movq (%rax,%r13), %rax
movslq (%rax,%r15,4), %rsi
decq %rsi
movq -0x78(%rbp), %rdi
callq 0x4bf4
movq %rbx, %r12
testq %rdx, (%rax)
leaq -0x68(%rbp), %r9
je 0x3a30
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rcx
movq -0x38(%rbp), %r13
movq (%rcx,%r13), %rax
cmpl $0x0, 0x4(%rax,%r15,4)
leaq 0x1(%r15), %r15
jne 0x3816
movq -0x30(%rbp), %rax
movq (%rax), %rsi
addq %r13, %rsi
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
callq 0x4c16
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rax
movq (%rax,%r13), %rax
movslq (%rax), %rax
imulq $0x18, %rax, %rsi
movq -0x50(%rbp), %rax
addq (%rax), %rsi
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
callq 0x4c16
movq %r14, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x36ae
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rdi
addq (%rax), %rdi
movq %r14, %rsi
callq 0x54e4
movq %r14, %rdi
callq 0x2632
movq %r15, %rdi
callq 0x2632
movq %rbx, %rdi
jmp 0x3a0a
movq -0x30(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rbx
addq %rbx, %rsi
leaq -0x110(%rbp), %r13
movq %r13, %rdi
callq 0x4c16
movq -0x48(%rbp), %rax
movq 0x2c8(%rax), %rax
movq (%rax,%rbx), %rax
movslq (%rax), %rax
imulq $0x18, %rax, %rsi
movq -0x50(%rbp), %rax
addq (%rax), %rsi
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
callq 0x4c16
movq %r14, %rdi
movq %r13, %rdx
movq %r15, %rcx
callq 0x36ae
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rdi
addq (%rax), %rdi
movq %r14, %rsi
callq 0x54e4
movq %r14, %rdi
callq 0x2632
movq %r15, %rdi
callq 0x2632
movq %r13, %rdi
callq 0x2632
jmp 0x3a2c
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rdi
addq (%rcx), %rdi
negl %eax
movl %eax, -0x98(%rbp)
movq %r14, %rsi
callq 0x52cc
leaq -0x68(%rbp), %r9
movq -0x70(%rbp), %rdi
incq %rdi
jmp 0x37d7
movq %rsi, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x2632
jmp 0x3ad4
movq %rax, %rbx
jmp 0x3ad4
movq %rax, %rbx
jmp 0x3a7b
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2632
leaq -0xc8(%rbp), %rdi
jmp 0x3ac1
jmp 0x3ac8
jmp 0x3ac8
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x2632
jmp 0x3a9c
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0x3ac1
jmp 0x3ac8
jmp 0x3ac8
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x2632
jmp 0x3abd
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2632
jmp 0x3acb
movq %rax, %rbx
movq -0x30(%rbp), %rdi
callq 0x257e
movq %rbx, %rdi
callq 0x22c0