// File: 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
subq $0x1d0, %rsp            # imm = 0x1D0
movq %r8, -0x198(%rbp)
movq %rcx, -0x190(%rbp)
movq %rdx, -0x188(%rbp)
movq %rdi, -0x180(%rbp)
movq %rdi, %rax
movq %rax, -0x178(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movb $0x0, -0x29(%rbp)
movslq 0x8(%rax), %rax
movq %rax, -0x168(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x8550
movq -0x160(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
leaq -0x48(%rbp), %rdi
callq 0x8570
jmp 0x6005
leaq -0x5d(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x85e0
movq -0x180(%rbp), %rdi
movq -0x168(%rbp), %rsi
movq -0x1a0(%rbp), %rcx
leaq -0x48(%rbp), %rdx
callq 0x8600
jmp 0x6035
leaq -0x5d(%rbp), %rdi
callq 0x3bd0
leaq -0x48(%rbp), %rdi
callq 0x3900
leaq -0x49(%rbp), %rdi
callq 0x3ae0
movl $0x0, -0x64(%rbp)
movq -0x170(%rbp), %rdi
movslq -0x64(%rbp), %rax
movq %rax, -0x1a8(%rbp)
addq $0x2c8, %rdi            # imm = 0x2C8
callq 0x8790
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
cmpq %rcx, %rax
jae 0x659a
movl $0x1, -0x68(%rbp)
movq -0x170(%rbp), %rdi
movslq -0x68(%rbp), %rax
movq %rax, -0x1b0(%rbp)
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
callq 0x87c0
movq %rax, %rcx
movq -0x1b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x658a
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x86c0
cmpl $0x0, (%rax)
jne 0x6240
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x87e0
jmp 0x6119
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x86c0
movq -0x198(%rbp), %rdi
movslq (%rax), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x87e0
jmp 0x615c
movq -0x170(%rbp), %rsi
leaq -0x80(%rbp), %rdi
leaq -0x98(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
callq 0x5e50
jmp 0x617c
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
leaq -0x80(%rbp), %rsi
callq 0x89a0
leaq -0x80(%rbp), %rdi
callq 0x3900
leaq -0xb0(%rbp), %rdi
callq 0x3900
leaq -0x98(%rbp), %rdi
callq 0x3900
jmp 0x658a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x61ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x5d(%rbp), %rdi
callq 0x3bd0
leaq -0x48(%rbp), %rdi
callq 0x3900
leaq -0x49(%rbp), %rdi
callq 0x3ae0
jmp 0x65cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x65c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x622f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3900
leaq -0x98(%rbp), %rdi
callq 0x3900
jmp 0x65c0
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x86c0
cmpl $0x0, (%rax)
jge 0x62cb
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq -0x170(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x86c0
movq -0x1b8(%rbp), %rdi
movl (%rax), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, -0xb4(%rbp)
leaq -0xb4(%rbp), %rsi
callq 0x88d0
jmp 0x62c6
jmp 0x658a
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0xe8(%rbp), %rdi
callq 0x87e0
jmp 0x62ec
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x86c0
movq -0x190(%rbp), %rdi
movslq (%rax), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
callq 0x87e0
jmp 0x632f
movq -0x170(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
leaq -0x100(%rbp), %rcx
callq 0x5e50
jmp 0x6352
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x1d0(%rbp)
callq 0x89a0
movq -0x1d0(%rbp), %rdi
callq 0x3900
leaq -0x100(%rbp), %rdi
callq 0x3900
leaq -0xe8(%rbp), %rdi
callq 0x3900
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movslq -0x68(%rbp), %rsi
callq 0x86c0
movq -0x188(%rbp), %rdi
movl (%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x86e0
movq %rdx, -0x1c8(%rbp)
movq %rax, -0x1c0(%rbp)
jmp 0x63e2
movq -0x1c8(%rbp), %rax
movq -0x1c0(%rbp), %rcx
movq %rcx, -0x110(%rbp)
movq %rax, -0x108(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x8970
testb $0x1, %al
jne 0x6413
jmp 0x657a
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
movl -0x68(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x86c0
cmpl $0x0, (%rax)
jne 0x6578
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0x140(%rbp), %rdi
callq 0x87e0
jmp 0x6465
movq -0x170(%rbp), %rdi
addq $0x2c8, %rdi            # imm = 0x2C8
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x86c0
movq -0x198(%rbp), %rdi
movslq (%rax), %rsi
callq 0x86a0
movq %rax, %rsi
leaq -0x158(%rbp), %rdi
callq 0x87e0
jmp 0x64a8
movq -0x170(%rbp), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rdx
leaq -0x158(%rbp), %rcx
callq 0x5e50
jmp 0x64cb
movq -0x180(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x86a0
movq %rax, %rdi
leaq -0x128(%rbp), %rsi
callq 0x89a0
leaq -0x128(%rbp), %rdi
callq 0x3900
leaq -0x158(%rbp), %rdi
callq 0x3900
leaq -0x140(%rbp), %rdi
callq 0x3900
jmp 0x658a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x6536
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x3900
leaq -0xe8(%rbp), %rdi
callq 0x3900
jmp 0x65c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x656a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x3900
leaq -0x140(%rbp), %rdi
callq 0x3900
jmp 0x65c0
jmp 0x657c
jmp 0x658a
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x608f
jmp 0x658c
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x6057
movb $0x1, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x65b0
movq -0x180(%rbp), %rdi
callq 0x3710
movq -0x178(%rbp), %rax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x180(%rbp), %rdi
callq 0x3710
movq -0x58(%rbp), %rdi
callq 0x3390
nopw %cs:(%rax,%rax)