// File: /workspace/github_cpp_makefile_star2_O2/kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::emit_action_table()
void xbytes::emit_action_table()
{
	std::ofstream ofs;
	ofs.open("ACTION.txt", std::ofstream::out);

	for(int i = 0; i < states.size(); ++i)
	{
		lr_state* ls = states[i];
		ofs << "STATE " << i << ":" << std::endl;

		//output all terms
		for(int j = 0; j < ls->terms.size(); ++j)
		{
			rule* r = ls->terms[j]->r;
			int dot = ls->terms[j]->dot;

			ofs << "	" << r->left->name << " -> ";
			int m = 0;
			for(m = 0; m < r->rights.size(); ++m)
			{
				if(m == dot) ofs << "*";
				ofs << " " << r->rights[m]->name; 
			}
			if(m == dot) ofs << "*";
			ofs << std::endl;
		}
		ofs << std::endl;

		//output all action
		for(int j = 0; j < states[i]->actions.size(); ++j)
		{
			action_array& aa = states[i]->actions[j];
			for(int m = 0; m < aa.size(); ++m)
			{
				action& act = aa[m];
				switch(act.type)
				{
				case LR_ACTION_REDUCE:
					ofs << "	" << symbols[j]->name << " REDUCE " << act.r->index << std::endl;
					break;
				case LR_ACTION_SHIFT:
					ofs << "	" << symbols[j]->name << " SHIFT " << act.next_state << std::endl;
					break;
				case LR_ACTION_GOTO:
					ofs << "	" << symbols[j]->name << " GOTO " << act.next_state << std::endl;
					break;
				case LR_ACTION_ACCEPT:
					ofs << "	" << symbols[j]->name << " ACCEPT" << std::endl;
					break;
				case LR_ACTION_SSCONFLICT:
					ofs << "	" << symbols[j]->name << " SSCONFLICT" << std::endl;
					break;
				case LR_ACTION_SRCONFLICT:
					ofs << "	" << symbols[j]->name << " SRCONFLICT" << std::endl;
					break;
				case LR_ACTION_RRCONFLICT:
					ofs << "	" << symbols[j]->name << " RRCONFLICT" << std::endl;
					break;
				case LR_ACTION_RDRESOLVED:
					ofs << "	" << symbols[j]->name << " RDRESOLVED" << std::endl;
					break;
				case LR_ACTION_SHRESOLVED:
					ofs << "	" << symbols[j]->name << " SHRESOLVED" << std::endl;
					break;
				}
			}
		}
		ofs << std::endl;	
	}

	ofs.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdi, -0x30(%rbp)
leaq -0x238(%rbp), %r14
movq %r14, %rdi
callq 0x2360
leaq 0x6348(%rip), %rsi      # 0xa9a4
pushq $0x10
popq %rdx
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
movq -0x30(%rbp), %rcx
movq 0x38(%rcx), %rax
movq 0x40(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x4a7b
movq (%rax,%r14,8), %rbx
leaq -0x238(%rbp), %rdi
leaq 0x604a(%rip), %rsi      # 0xa6e2
callq 0x2220
movq %rax, %rdi
movl %r14d, %esi
callq 0x2370
movq %rax, %rdi
leaq 0x5ae5(%rip), %rsi      # 0xa197
callq 0x2220
movq %rax, %rdi
callq 0x2110
movq %r14, -0x38(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x47a3
movq (%rax,%r14,8), %rax
movq (%rax), %r12
movl 0x8(%rax), %r15d
leaq -0x238(%rbp), %rdi
leaq 0x5f58(%rip), %rsi      # 0xa64f
callq 0x2220
movq 0x8(%r12), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
leaq 0x5fd2(%rip), %rsi      # 0xa6e9
callq 0x2220
xorl %r13d, %r13d
movq 0x38(%r12), %rax
subq 0x30(%r12), %rax
sarq $0x3, %rax
cmpq %r13, %rax
jbe 0x4777
cmpq %r13, %r15
jne 0x474a
leaq -0x238(%rbp), %rdi
leaq 0x60cf(%rip), %rsi      # 0xa814
callq 0x2220
leaq -0x238(%rbp), %rdi
leaq 0x5e7d(%rip), %rsi      # 0xa5d5
callq 0x2220
movq 0x30(%r12), %rcx
movq (%rcx,%r13,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
incq %r13
jmp 0x471f
cmpl %r13d, %r15d
jne 0x478f
leaq -0x238(%rbp), %rdi
leaq 0x608a(%rip), %rsi      # 0xa814
callq 0x2220
leaq -0x238(%rbp), %rdi
callq 0x2110
incq %r14
jmp 0x46c6
leaq -0x238(%rbp), %rdi
callq 0x2110
xorl %r14d, %r14d
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x50(%rax), %r13
movq 0x58(%rax), %rax
subq %r13, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r14, %rax
jbe 0x4a63
imulq $0x18, %r14, %rax
addq %rax, %r13
pushq $0x4
popq %rbx
xorl %r15d, %r15d
movq (%r13), %r12
movq 0x8(%r13), %rax
subq %r12, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpq %r15, %rax
jbe 0x4a5b
movl -0x4(%r12,%rbx), %eax
decl %eax
cmpl $0x9, %eax
ja 0x4a4f
leaq 0x5866(%rip), %rcx      # 0xa084
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x238(%rbp), %rdi
leaq 0x5e1a(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
leaq 0x5e92(%rip), %rsi      # 0xa6ee
callq 0x2220
addq %rbx, %r12
jmp 0x4926
leaq -0x238(%rbp), %rdi
leaq 0x5dd8(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
leaq 0x6111(%rip), %rsi      # 0xa9af
callq 0x2220
movq 0x4(%r12,%rbx), %r12
jmp 0x4926
leaq -0x238(%rbp), %rdi
leaq 0x5d97(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x60f8(%rip), %rsi      # 0xa9d4
jmp 0x4a3f
leaq -0x238(%rbp), %rdi
leaq 0x5d60(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
leaq 0x60a2(%rip), %rsi      # 0xa9b8
callq 0x2220
imulq $0x18, %r15, %rcx
addq %rcx, %r12
addq $0x4, %r12
movl (%r12), %esi
movq %rax, %rdi
callq 0x2370
jmp 0x4a47
leaq -0x238(%rbp), %rdi
leaq 0x5d0a(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x6077(%rip), %rsi      # 0xa9e0
jmp 0x4a3f
leaq -0x238(%rbp), %rdi
leaq 0x5cd3(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x604c(%rip), %rsi      # 0xa9ec
jmp 0x4a3f
leaq -0x238(%rbp), %rdi
leaq 0x5c9c(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x5fe9(%rip), %rsi      # 0xa9c0
jmp 0x4a3f
leaq -0x238(%rbp), %rdi
leaq 0x5c68(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x5fbd(%rip), %rsi      # 0xa9c8
jmp 0x4a3f
leaq -0x238(%rbp), %rdi
leaq 0x5c34(%rip), %rsi      # 0xa64f
callq 0x2220
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq (%rcx,%r14,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x2200
leaq 0x5fb9(%rip), %rsi      # 0xa9f8
movq %rax, %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2110
incq %r15
addq $0x18, %rbx
jmp 0x47eb
incq %r14
jmp 0x47b2
leaq -0x238(%rbp), %rdi
callq 0x2110
movq -0x38(%rbp), %r14
incq %r14
jmp 0x466a
leaq -0x238(%rbp), %rdi
callq 0x22c0
leaq -0x238(%rbp), %rdi
callq 0x22e0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4aaf
jmp 0x4aaf
jmp 0x4aaf
jmp 0x4aaf
jmp 0x4aaf
movq %rax, %rbx
leaq -0x238(%rbp), %rdi
callq 0x22e0
movq %rbx, %rdi
callq 0x2380