// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rdi, %rbx
movq 0x5561(%rip), %r14      # 0xafd0
leaq 0x2821(%rip), %rsi      # 0x8297
movl $0x34, %edx
movq %r14, %rdi
callq 0x2200
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq 0x2a0(%rbx), %rax
cmpq 0x298(%rbx), %rax
je 0x5d53
xorl %r12d, %r12d
leaq 0x27e3(%rip), %r15      # 0x82d5
movq 0x2c8(%rbx), %rax
leaq (%r12,%r12,2), %rcx
movq %rcx, -0x30(%rbp)
movq (%rax,%rcx,8), %rax
movslq (%rax), %r13
shlq $0x5, %r13
movq 0x250(%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x2090
testl %eax, %eax
je 0x5d27
movq %r12, -0x50(%rbp)
movq 0x250(%rbx), %rax
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
movq %r14, %rdi
callq 0x2200
movl $0x2, %edx
movq %rax, %rdi
leaq 0x277b(%rip), %rsi      # 0x82cc
callq 0x2200
movq 0x298(%rbx), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rax
cmpq %rax, 0x8(%rcx,%rdx,8)
je 0x5cd2
movq %r13, %r12
movq -0x30(%rbp), %rcx
leaq (,%rcx,8), %rcx
movq %rcx, -0x60(%rbp)
xorl %r13d, %r13d
movq %r12, -0x58(%rbp)
movslq (%rax,%r13,4), %rax
movq 0x238(%rbx), %rcx
shlq $0x5, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq %r14, %rdi
callq 0x2200
movl $0x3, %edx
movq %rax, %rdi
leaq 0x2716(%rip), %rsi      # 0x82cf
callq 0x2200
movq 0x250(%rbx), %rax
movq (%rax,%r12), %rsi
movq 0x8(%rax,%r12), %rdx
movq %r14, %rdi
callq 0x2200
movl $0x4, %edx
movq %rax, %rdi
leaq 0x26a4(%rip), %rsi      # 0x8289
callq 0x2200
movq 0x2e0(%rbx), %rsi
addq -0x60(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x5ebc
movl $0x1, %r12d
movq -0x48(%rbp), %rax
xorl %ecx, %ecx
movl (%rax,%rcx,4), %edx
testl %edx, %edx
je 0x5c21
cmpl $0x3e7, %edx            # imm = 0x3E7
je 0x5c21
incq %rcx
incq %r12
jmp 0x5c0a
testq %rcx, %rcx
je 0x5c7e
leal -0x2(%r12), %eax
movq -0x48(%rbp), %rcx
movl (%rcx,%rax,4), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
leaq 0x250(%rbx), %rdx
leaq 0x238(%rbx), %rsi
testl %eax, %eax
cmovsq %rsi, %rdx
movq (%rdx), %rax
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r14, %rdi
callq 0x2200
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
decq %r12
cmpq $0x1, %r12
jg 0x5c26
movl $0x3, %edx
movq %r14, %rdi
leaq 0x2646(%rip), %rsi      # 0x82d3
callq 0x2200
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x5ca7
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
incq %r13
movq 0x298(%rbx), %rcx
movq -0x30(%rbp), %rdx
movq (%rcx,%rdx,8), %rax
movq 0x8(%rcx,%rdx,8), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
movq -0x58(%rbp), %r12
ja 0x5b8a
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq -0x50(%rbp), %r12
movq 0x2a0(%rbx), %rax
subq 0x298(%rbx), %rax
incq %r12
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %r12, %rax
ja 0x5af2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5d64
movq %rax, %rbx
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x5d7c
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22e0