// File: /workspace/github_cpp_makefile_star2_O2/SeanLee97[P]LL1-Parser/grammar.cpp
// Function: Grammar::print_table()
void Grammar::print_table(){
    cout<<"+++++++++++++++++ parse table ++++++++++++++++++++++"<<endl<<endl;

	int n_idx, t_idx, rule_idx = 0;
	for(int i = 0; i < predict_sets.size(); i++) {
		n_idx = full_rules[i][0];
		rule_idx = i;

		if ( nonterminal_names[n_idx] == " "){
			continue;
		}
		// nonterminal
		cout<< nonterminal_names[n_idx]<<"\t\t";

		for(int j = 0; j < predict_sets[i].size(); j++) {

			t_idx = predict_sets[i][j];

			cout<< terminal_names[t_idx] << " | ";

			cout << nonterminal_names[n_idx] << " -> ";


			vector<int> pred_rule = right_hand_sides[rule_idx];

			int k = 0;
			while(pred_rule[k] != 0 && pred_rule[k] != 999) {
				++k;
			}

			for(k = k-1; k >= 0; k--) {
				if(pred_rule[k] < 0)
					cout << terminal_names[abs(pred_rule[k])] << " ";
				else
					cout << nonterminal_names[abs(pred_rule[k])] << " ";
			}
			cout<< " # ";
			k = 0; 
		}
		cout<<endl<<endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x66a7(%rip), %r14      # 0xafd0
leaq 0x2967(%rip), %rsi      # 0x7297
movq %r14, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movq %rbx, %rdi
xorl %ecx, %ecx
leaq 0x2981(%rip), %r15      # 0x72d5
leaq 0x250(%rbx), %r12
leaq 0x238(%rbx), %r13
movq %rbx, -0x30(%rbp)
movq 0x2a0(%rdi), %rax
subq 0x298(%rdi), %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rcx, %rax
jbe 0x4b1d
movq 0x2c8(%rdi), %rax
imulq $0x18, %rcx, %rdx
movq %rdx, -0x40(%rbp)
movq (%rax,%rdx), %rax
movslq (%rax), %rbx
shlq $0x5, %rbx
movq 0x250(%rdi), %rdi
addq %rbx, %rdi
movq %r15, %rsi
movq %rcx, -0x38(%rbp)
callq 0x4fda
movq -0x38(%rbp), %rcx
testb %al, %al
jne 0x4b11
movq -0x30(%rbp), %rax
movq 0x250(%rax), %rsi
addq %rbx, %rsi
movq %r14, %rdi
callq 0x2190
movq %rax, %rdi
leaq 0x28eb(%rip), %rsi      # 0x72cc
callq 0x21a0
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movq %rbx, -0x48(%rbp)
movq 0x298(%rdi), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rsi, %rcx
jbe 0x4afd
movq %rsi, -0x50(%rbp)
movslq (%rax,%rsi,4), %rsi
shlq $0x5, %rsi
addq 0x238(%rdi), %rsi
movq %rdi, %r15
movq %r14, %rdi
callq 0x2190
movq %rax, %rdi
leaq 0x2893(%rip), %rsi      # 0x72cf
callq 0x21a0
movq 0x250(%r15), %rsi
addq %rbx, %rsi
movq %r14, %rdi
callq 0x2190
movq %rax, %rdi
leaq 0x282c(%rip), %rsi      # 0x7289
callq 0x21a0
movq 0x2e0(%r15), %rsi
leaq 0x2865(%rip), %r15      # 0x72d5
addq -0x40(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x4c16
movq -0x68(%rbp), %rax
xorl %ebx, %ebx
movl (%rax,%rbx,4), %ecx
cmpl $0x3e7, %ecx            # imm = 0x3E7
je 0x4acc
testl %ecx, %ecx
je 0x4acc
incq %rbx
jmp 0x4a83
movq -0x68(%rbp), %rax
movl -0x4(%rax,%rbx,4), %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
testl %eax, %eax
movq %r12, %rax
cmovsq %r13, %rax
shlq $0x5, %rsi
addq (%rax), %rsi
movq %r14, %rdi
callq 0x2190
decq %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x21a0
testq %rbx, %rbx
jg 0x4a97
movq %r14, %rdi
leaq 0x27f8(%rip), %rsi      # 0x72d3
callq 0x21a0
leaq -0x68(%rbp), %rdi
callq 0x2632
movq -0x50(%rbp), %rsi
incq %rsi
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rbx
jmp 0x49f0
movq %r14, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movq -0x38(%rbp), %rcx
incq %rcx
movq -0x30(%rbp), %rdi
jmp 0x4966
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4b2e
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2632
movq %rbx, %rdi
callq 0x22c0