// File: /workspace/github_cpp_makefile_star2_O3/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::_grammar_counter(char*)
void Grammar::_grammar_counter(char* inputFile) {
	input.open(inputFile);
	// 获取出现次数最多的字符
	string cur_maxfreq_terminals;

	while(getline(input, line)){
		if(line.compare("") == 0) break;

		stringstream ss(line);

		getline(ss, cur_maxfreq_terminals, ' ');
		getline(ss, cur_maxfreq_terminals, ' ');
		// 最大id-terminal
		// atoi字符串转换成整型数的一个函数
		maxidx_terminal = atoi(cur_maxfreq_terminals.c_str());
	}

	string last_unique_nonterminal(""); 
	string this_nonterminal;

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

		if(this_nonterminal.compare(last_unique_nonterminal) != 0) {
			++num_nonterminals;
			last_unique_nonterminal = this_nonterminal;
		}

		++num_rules;
	}

	input.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x2120
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x218(%r14), %rax
movq %rax, -0x30(%rbp)
leaq -0x218(%rbp), %r12
leaq -0x90(%rbp), %r13
movq -0x30(%rbp), %r15
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4925
movq %r15, %rdi
leaq 0x3a11(%rip), %rsi      # 0x82ce
callq 0x2090
testl %eax, %eax
je 0x4925
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x2290
movq %r12, %rdi
movq %r13, %rsi
movl $0x20, %edx
callq 0x2300
movq %r12, %rdi
movq %r13, %rsi
movl $0x20, %edx
callq 0x2300
movq -0x90(%rbp), %rdi
callq 0x2280
movl %eax, (%r14)
movq %r12, %rdi
movq 0x66a9(%rip), %rsi      # 0xafb8
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4882
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x399a(%rip), %rdx      # 0x82ce
leaq -0x70(%rbp), %rdi
movq %rdx, %rsi
callq 0x2d4c
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x218(%rbp), %r12
movq -0x30(%rbp), %r15
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2300
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4a2b
movq %r12, %rdi
movq %r15, %rsi
movl $0x18, %edx
callq 0x2290
movq %r12, %r15
movq %r12, %rdi
leaq -0x50(%rbp), %rsi
movl $0x20, %edx
callq 0x2300
movq %r14, %r13
movq -0x48(%rbp), %r12
movq -0x68(%rbp), %r14
cmpq %r12, %r14
movq %r12, %rdx
cmovbq %r14, %rdx
testq %rdx, %rdx
je 0x49eb
movq -0x70(%rbp), %rsi
movq -0x50(%rbp), %rdi
callq 0x21e0
cmpq %r14, %r12
movq %r13, %r14
jne 0x49f3
testl %eax, %eax
je 0x4a04
jmp 0x49f3
cmpq %r14, %r12
movq %r13, %r14
je 0x4a04
incl 0x4(%r14)
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2100
incl 0x8(%r14)
movq %r15, %r12
movq %r15, %rdi
movq 0x65a3(%rip), %rsi      # 0xafb8
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x495a
movq %rbx, %rdi
callq 0x2060
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4a4c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4a65
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4a81
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4ae8
jmp 0x4abf
jmp 0x4abf
movq %rax, %rbx
movq 0x6515(%rip), %rsi      # 0xafb8
leaq -0x218(%rbp), %rdi
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4b1d
jmp 0x4ae8
movq %rax, %rbx
jmp 0x4b1d
movq %rax, %rbx
movq 0x64ea(%rip), %rsi      # 0xafb8
leaq -0x218(%rbp), %rdi
callq 0x2160
leaq -0x198(%rbp), %rdi
callq 0x20a0
jmp 0x4aeb
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4b04
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4b1d
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4b39
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22e0
nop