// File: SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::_process_grammar[abi:cxx11](char*)
vector<vector<string> > Grammar::_process_grammar(char* inputFile) {

	vector<string> temp_terminals(maxidx_terminal + 1); // Terminal names
	vector<string> temp_nonterminals(num_nonterminals + 1); // Nonterminal names

	vector< vector<string> > temp_names(2);
	temp_names[0] = temp_terminals;
	temp_names[1] = temp_nonterminals;

	input.open(inputFile); // 文件指针

	string cur_terminal_name;
	string cur_terminal_idx;

	// 终结符获取
	while(getline(input, line)) {
		if(line.compare("") == 0) break;

		stringstream ss(line); 
		getline(ss, cur_terminal_name, ' '); 
		getline(ss, cur_terminal_idx, ' ');

		// cout<<cur_terminal_idx<<"-"<<cur_terminal_name<<endl;
		temp_names[0][atoi(cur_terminal_idx.c_str())] = cur_terminal_name;
	}

	int cur_nonterminal_idx = 0; 
	string cur_nonterminal_name; 
	string last_unique_nonterminal("");

	while(getline(input, line)) {
		stringstream ss(line); 
		getline(ss, cur_nonterminal_name, ' ');

		if(cur_nonterminal_name.compare(last_unique_nonterminal) != 0) {
			temp_names[1][cur_nonterminal_idx + 1] = cur_nonterminal_name; 
			++cur_nonterminal_idx; 
			last_unique_nonterminal = cur_nonterminal_name;
		}
	}
	input.close();
	return temp_names;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x430(%rbp)
movq %rdi, %rax
movq %rax, -0x428(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x420(%rbp)
movl (%rax), %eax
incl %eax
cltq
movq %rax, -0x418(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x8a00
movq -0x418(%rbp), %rsi
movq -0x410(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x8a20
jmp 0x6649
leaq -0x31(%rbp), %rdi
callq 0x3dd0
movq -0x420(%rbp), %rax
movl 0x4(%rax), %eax
incl %eax
cltq
movq %rax, -0x440(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x8a00
movq -0x440(%rbp), %rsi
movq -0x438(%rbp), %rdx
leaq -0x60(%rbp), %rdi
callq 0x8a20
jmp 0x6690
leaq -0x61(%rbp), %rdi
callq 0x3dd0
movb $0x0, -0x62(%rbp)
leaq -0x63(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x8a90
movq -0x430(%rbp), %rdi
movq -0x448(%rbp), %rdx
movl $0x2, %esi
callq 0x8ab0
jmp 0x66c7
leaq -0x63(%rbp), %rdi
callq 0x8b20
movq -0x430(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8b40
movq %rax, %rdi
leaq -0x30(%rbp), %rsi
callq 0x8b60
jmp 0x66ee
movq -0x430(%rbp), %rdi
movl $0x1, %esi
callq 0x8b40
movq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0x8b60
jmp 0x670d
movq -0x420(%rbp), %rdi
addq $0x10, %rdi
movq -0x18(%rbp), %rsi
movl $0x8, %edx
callq 0x3140
jmp 0x6728
leaq -0x88(%rbp), %rdi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
callq 0x32f0
movq -0x420(%rbp), %rsi
movq %rsi, %rdi
addq $0x10, %rdi
addq $0x218, %rsi            # imm = 0x218
callq 0x3070
movq %rax, -0x450(%rbp)
jmp 0x6763
movq -0x450(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x32e0
movb %al, -0x451(%rbp)
jmp 0x6781
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x6790
jmp 0x6917
movq -0x420(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
leaq 0xaba5(%rip), %rsi      # 0x1134a
callq 0x30b0
cmpl $0x0, %eax
jne 0x6824
jmp 0x6917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3dd0
jmp 0x6bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x3dd0
jmp 0x6bb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x63(%rbp), %rdi
callq 0x8b20
jmp 0x6bac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6ba0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6b58
movq -0x420(%rbp), %rax
addq $0x218, %rax            # imm = 0x218
movq %rax, -0x460(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0x8680
movl %eax, -0x458(%rbp)
jmp 0x684f
movl -0x458(%rbp), %edx
movq -0x460(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x3340
jmp 0x686a
leaq -0x230(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0x20, %edx
callq 0x33d0
jmp 0x6884
leaq -0x230(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x20, %edx
callq 0x33d0
jmp 0x689e
movq -0x430(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8b40
movq %rax, -0x468(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x3330
movq -0x468(%rbp), %rdi
movslq %eax, %rsi
callq 0x8db0
movq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0x3040
jmp 0x68e9
leaq -0x230(%rbp), %rdi
callq 0x3180
jmp 0x6740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3180
jmp 0x6b58
movl $0x0, -0x234(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x32f0
leaq -0x279(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0x33a0
movq -0x470(%rbp), %rdx
leaq 0xa9fc(%rip), %rsi      # 0x1134a
leaq -0x278(%rbp), %rdi
callq 0x4440
jmp 0x695c
leaq -0x279(%rbp), %rdi
callq 0x3250
movq -0x420(%rbp), %rsi
movq %rsi, %rdi
addq $0x10, %rdi
addq $0x218, %rsi            # imm = 0x218
callq 0x3070
movq %rax, -0x478(%rbp)
jmp 0x698b
movq -0x478(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x32e0
movb %al, -0x479(%rbp)
jmp 0x69a9
movb -0x479(%rbp), %al
testb $0x1, %al
jne 0x69b8
jmp 0x6af2
movq -0x420(%rbp), %rax
addq $0x218, %rax            # imm = 0x218
movq %rax, -0x488(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0x8680
movl %eax, -0x480(%rbp)
jmp 0x69e3
movl -0x480(%rbp), %edx
movq -0x488(%rbp), %rsi
leaq -0x408(%rbp), %rdi
callq 0x3340
jmp 0x69fe
leaq -0x408(%rbp), %rdi
leaq -0x258(%rbp), %rsi
movl $0x20, %edx
callq 0x33d0
jmp 0x6a18
leaq -0x258(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3030
movl %eax, -0x48c(%rbp)
jmp 0x6a33
movl -0x48c(%rbp), %eax
cmpl $0x0, %eax
je 0x6ae1
movq -0x430(%rbp), %rdi
movl $0x1, %esi
callq 0x8b40
movq %rax, %rdi
movl -0x234(%rbp), %eax
incl %eax
movslq %eax, %rsi
callq 0x8db0
movq %rax, %rdi
leaq -0x258(%rbp), %rsi
callq 0x3040
jmp 0x6a77
movl -0x234(%rbp), %eax
incl %eax
movl %eax, -0x234(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3040
jmp 0x6a9a
jmp 0x6ae1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x279(%rbp), %rdi
callq 0x3250
jmp 0x6b4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6b40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x408(%rbp), %rdi
callq 0x3180
jmp 0x6b40
leaq -0x408(%rbp), %rdi
callq 0x3180
jmp 0x6968
movq -0x420(%rbp), %rdi
addq $0x10, %rdi
callq 0x3080
jmp 0x6b04
movb $0x1, -0x62(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x3130
leaq -0x258(%rbp), %rdi
callq 0x3130
leaq -0xa8(%rbp), %rdi
callq 0x3130
leaq -0x88(%rbp), %rdi
callq 0x3130
testb $0x1, -0x62(%rbp)
jne 0x6b7e
jmp 0x6b72
leaq -0x278(%rbp), %rdi
callq 0x3130
leaq -0x258(%rbp), %rdi
callq 0x3130
leaq -0xa8(%rbp), %rdi
callq 0x3130
leaq -0x88(%rbp), %rdi
callq 0x3130
jmp 0x6ba0
movq -0x430(%rbp), %rdi
callq 0x8dd0
leaq -0x60(%rbp), %rdi
callq 0x3770
leaq -0x30(%rbp), %rdi
callq 0x3770
movq -0x428(%rbp), %rax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
movq -0x430(%rbp), %rdi
callq 0x8dd0
leaq -0x60(%rbp), %rdi
callq 0x3770
leaq -0x30(%rbp), %rdi
callq 0x3770
movq -0x40(%rbp), %rdi
callq 0x3390
nopw (%rax,%rax)