// File: /workspace/github_cpp_makefile_star2_O1/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::get_first(std::vector<bool, std::allocator<bool>>)
vector<vector<int> > Grammar::get_first(vector<bool> local_is_epsilon) {
	// array
	vector<vector<int> > temp_first(num_nonterminals + 1, vector<int>(0));
	bool complete = false;

	while(!complete) {
		complete = true;
		for(int i = 0; i < full_rules.size(); i++) {   // line
			for(int j = 1; j < full_rules[i].size(); j++) {  // symbol of line
				if(full_rules[i][j] == 0) {
					//  0 为结束标记 end
					break;

				// full_rules[i][j] - terminal
				} else if(full_rules[i][j] < 0) {

					// full_rules[i][j] 是否在 temp_first[full_rules[i][0]] 中
					if(!_in_array(temp_first[full_rules[i][0]], full_rules[i][j])) {
						temp_first[full_rules[i][0]].push_back(abs(full_rules[i][j]));
						complete = false; 
						// 找到first terminal退出
						break;
					} else break;

				// full_rules[i][j] - nonterminal
				// temp_first[full_rules[i][j]] 的first集不为空
				// temp_first[full_rules[i][j]] 的first集也为当前nonterminal的first集,故追加上
				} else if(full_rules[i][j] > 0 && temp_first[full_rules[i][j]].size() > 0) {

					vector<int> cur_elements_first = temp_first[full_rules[i][j]];

					for(int k = 0; k < cur_elements_first.size(); k++) {
						if(!_in_array(temp_first[full_rules[i][0]], cur_elements_first[k])) {
							temp_first[full_rules[i][0]].push_back(cur_elements_first[k]);
							complete = false;
						}
					}
				}
				
				// 当前nonterminal !-> epsilon，则退出
				if(! local_is_epsilon[abs(full_rules[i][j]) - 1]) {
					break;
				}
			}
		}
	}

	return temp_first;			
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbx
movslq 0x4(%rsi), %rsi
incq %rsi
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
leaq -0x2d(%rbp), %rcx
callq 0x5f18
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3425
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %r13, -0x60(%rbp)
movq 0x2d0(%r15), %rax
cmpq 0x2c8(%r15), %rax
je 0x378c
movb $0x1, %al
movl %eax, -0x2c(%rbp)
xorl %edx, %edx
movq 0x2c8(%r15), %rax
movq %rdx, -0x68(%rbp)
leaq (%rdx,%rdx,2), %r14
movq (%rax,%r14,8), %rcx
movq 0x8(%rax,%r14,8), %rdx
subq %rcx, %rdx
cmpq $0x5, %rdx
jb 0x3752
leaq (%rax,%r14,8), %rax
movl $0x1, %edi
movl (%rcx,%rdi,4), %edx
testq %rdx, %rdx
je 0x3752
testl %edx, %edx
js 0x3666
movq (%rbx), %rcx
leaq (%rdx,%rdx,2), %rdx
movq 0x8(%rcx,%rdx,8), %rsi
cmpq (%rcx,%rdx,8), %rsi
je 0x35d3
movq (%rax), %rax
movq %rdi, -0x58(%rbp)
movslq (%rax,%rdi,4), %rax
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rsi
leaq -0x50(%rbp), %rdi
callq 0x5fba
movq -0x50(%rbp), %rdi
cmpq %rdi, -0x48(%rbp)
je 0x35be
xorl %r13d, %r13d
movq 0x2c8(%r15), %rax
movq (%rax,%r14,8), %rax
movslq (%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq (%rbx), %rsi
leaq -0x80(%rbp), %rdi
callq 0x5fba
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rax
subq %rdi, %rax
je 0x353d
sarq $0x2, %rax
movq -0x50(%rbp), %rcx
movl (%rcx,%r13,4), %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
movb $0x1, %r12b
cmpl %ecx, (%rdi)
je 0x3540
movl $0x1, %r8d
movq %r8, %rsi
cmpq %r8, %rdx
je 0x3534
leaq 0x1(%rsi), %r8
cmpl %ecx, (%rdi,%rsi,4)
jne 0x3523
cmpq %rsi, %rax
seta %r12b
jmp 0x3540
xorl %r12d, %r12d
testq %rdi, %rdi
je 0x3551
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
testb %r12b, %r12b
jne 0x359f
movq 0x2c8(%r15), %rax
movq (%rax,%r14,8), %rax
movslq (%rax), %rax
movq (%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (,%r13,4), %rdx
addq -0x50(%rbp), %rdx
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3593
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x3598
callq 0x677c
movl $0x0, -0x2c(%rbp)
incq %r13
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %r13, %rax
ja 0x34c9
movq -0x60(%rbp), %r13
testq %rdi, %rdi
je 0x35cf
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x58(%rbp), %rdi
movq 0x2c8(%r15), %rax
movq (%rax,%r14,8), %rax
movl (%rax,%rdi,4), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
movslq %ecx, %rax
leaq -0x1(%rax), %rcx
leaq 0x3e(%rax), %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
addq (%r13), %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
movq %rdi, %r8
movq %rsi, %rdi
addq $0x3f, %rsi
andq %rcx, %rsi
xorl %ecx, %ecx
cmpq %rdi, %rsi
setbe %cl
decb %al
movq -0x8(%rdx,%rcx,8), %rcx
movzbl %al, %eax
btq %rax, %rcx
jae 0x3752
incq %r8
movq 0x2c8(%r15), %rax
leaq (%rax,%r14,8), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r8, %rdx
movq %r8, %rdi
ja 0x3472
jmp 0x3752
movq %rdi, -0x58(%rbp)
movslq (%rcx), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq (%rbx), %rsi
leaq -0x98(%rbp), %rdi
callq 0x5fba
movq -0x98(%rbp), %rdi
movq -0x90(%rbp), %rax
subq %rdi, %rax
je 0x36e6
sarq $0x2, %rax
movq 0x2c8(%r15), %rcx
movq (%rcx,%r14,8), %rcx
movq -0x58(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
movb $0x1, %r12b
cmpl %ecx, (%rdi)
je 0x36e9
movl $0x1, %r8d
movq %r8, %rsi
cmpq %r8, %rdx
je 0x36dd
leaq 0x1(%rsi), %r8
cmpl %ecx, (%rdi,%rsi,4)
jne 0x36cc
cmpq %rsi, %rax
seta %r12b
jmp 0x36e9
xorl %r12d, %r12d
testq %rdi, %rdi
je 0x36fd
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
testb %r12b, %r12b
movq -0x58(%rbp), %rsi
jne 0x3752
movq 0x2c8(%r15), %rax
movq (%rax,%r14,8), %rax
movslq (%rax), %rcx
movq (%rbx), %rdx
leaq (%rcx,%rcx,2), %rcx
leaq (%rdx,%rcx,8), %rdi
movl (%rax,%rsi,4), %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
movl %eax, -0x50(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3742
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x374b
leaq -0x50(%rbp), %rdx
callq 0x665a
movl $0x0, -0x2c(%rbp)
movq 0x2d0(%r15), %rax
subq 0x2c8(%r15), %rax
movq -0x68(%rbp), %rdx
incq %rdx
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %rdx, %rax
ja 0x3444
testb $0x1, -0x2c(%rbp)
je 0x3429
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x37e1
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x37e1
jmp 0x37bc
jmp 0x37bc
movq %rax, %r14
jmp 0x37d9
movq %rax, %r14
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x37d9
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2650
movq %r14, %rdi
callq 0x22e0
nop