// File: /workspace/github_cpp_makefile_star2_O3/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, %r15
leaq -0x240(%rbp), %r14
movq %r14, %rdi
callq 0x33a0
leaq 0x754d(%rip), %rsi      # 0xd9a4
movq %r14, %rdi
movl $0x10, %edx
callq 0x3040
movq 0x38(%r15), %rax
cmpq %rax, 0x40(%r15)
je 0x6b94
xorl %ebx, %ebx
movq %r15, -0x38(%rbp)
movq (%rax,%rbx,8), %rax
movq %rax, -0x30(%rbp)
movl $0x6, %edx
movq %r14, %rdi
leaq 0x7253(%rip), %rsi      # 0xd6e2
callq 0x32b0
leaq -0x240(%rbp), %rdi
movl %ebx, %esi
callq 0x33b0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6ce3(%rip), %rsi      # 0xd197
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq %rbx, -0x40(%rbp)
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq %rax, 0x10(%rcx)
leaq -0x240(%rbp), %r13
je 0x662a
xorl %r15d, %r15d
movq (%rax,%r15,8), %rax
movq (%rax), %r12
movl 0x8(%rax), %r14d
movl $0x1, %edx
movq %r13, %rdi
leaq 0x7134(%rip), %rsi      # 0xd64f
callq 0x32b0
movq 0x8(%r12), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r13, %rdi
callq 0x32b0
movl $0x4, %edx
movq %rax, %rdi
leaq 0x71a5(%rip), %rsi      # 0xd6e9
callq 0x32b0
movq 0x38(%r12), %rax
cmpq 0x30(%r12), %rax
je 0x65bd
xorl %r13d, %r13d
cmpq %r13, %r14
leaq -0x240(%rbp), %rbx
jne 0x6578
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x72a1(%rip), %rsi      # 0xd814
callq 0x32b0
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x704e(%rip), %rsi      # 0xd5d5
callq 0x32b0
movq 0x30(%r12), %rax
movq (%rax,%r13,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %rbx, %rdi
callq 0x32b0
incq %r13
movq 0x38(%r12), %rax
subq 0x30(%r12), %rax
sarq $0x3, %rax
cmpq %r13, %rax
ja 0x6558
jmp 0x65c0
xorl %r13d, %r13d
cmpl %r14d, %r13d
leaq -0x240(%rbp), %r13
jne 0x65e0
movl $0x1, %edx
movq %r13, %rdi
leaq 0x7239(%rip), %rsi      # 0xd814
callq 0x32b0
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
incq %r15
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rax
movq 0x10(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x6501
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
movq -0x38(%rbp), %r15
movq -0x40(%rbp), %rbx
movsbl %al, %esi
leaq -0x240(%rbp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq 0x38(%r15), %rax
movq (%rax,%rbx,8), %rdx
movq 0x50(%rdx), %rcx
cmpq %rcx, 0x58(%rdx)
leaq -0x240(%rbp), %rsi
je 0x6b43
xorl %r8d, %r8d
leaq (%r8,%r8,2), %rdx
movq (%rcx,%rdx,8), %r14
cmpq %r14, 0x8(%rcx,%rdx,8)
je 0x6b12
movq %r8, -0x30(%rbp)
leaq (%rcx,%rdx,8), %rbx
movl $0x8, %r15d
xorl %r12d, %r12d
movl -0x8(%r14,%r15), %eax
decl %eax
cmpl $0x9, %eax
ja 0x6ad3
leaq 0x69c8(%rip), %rcx      # 0xd084
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6f77(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6fdb(%rip), %rsi      # 0xd6ee
callq 0x32b0
movl -0x4(%r14,%r15), %esi
movq %r13, %rdi
callq 0x33b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6efb(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
leaq 0x7220(%rip), %rsi      # 0xd9af
callq 0x32b0
movq (%r14,%r15), %rax
movl (%rax), %esi
movq %r13, %rdi
callq 0x33b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6e7e(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0x71c8(%rip), %rsi      # 0xd9d4
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6e11(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0x713f(%rip), %rsi      # 0xd9b8
callq 0x32b0
movl -0x4(%r14,%r15), %esi
movq %r13, %rdi
callq 0x33b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6d95(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0x70eb(%rip), %rsi      # 0xd9e0
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6d28(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0x708a(%rip), %rsi      # 0xd9ec
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6cbb(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0x6ff1(%rip), %rsi      # 0xd9c0
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6c4e(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0x6f8c(%rip), %rsi      # 0xd9c8
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6ac0
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6be4(%rip), %rsi      # 0xd64f
callq 0x32b0
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
leaq -0x240(%rbp), %rdi
callq 0x32b0
movq %rax, %r13
movl $0xb, %edx
movq %rax, %rdi
leaq 0x6f52(%rip), %rsi      # 0xd9f8
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
incq %r12
movq (%rbx), %r14
movq 0x8(%rbx), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $0x18, %r15
cmpq %r12, %rax
ja 0x66a5
movq -0x38(%rbp), %r15
movq 0x38(%r15), %rax
leaq -0x240(%rbp), %rsi
movq -0x30(%rbp), %r8
incq %r8
movq -0x40(%rbp), %rbx
movq (%rax,%rbx,8), %rdx
movq 0x50(%rdx), %rcx
movq 0x58(%rdx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rdx
cmpq %r8, %rdx
ja 0x6681
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rdi
addq %rsi, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
leaq -0x240(%rbp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
incq %rbx
movq 0x38(%r15), %rax
movq 0x40(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
leaq -0x240(%rbp), %r14
ja 0x6478
leaq -0x240(%rbp), %rdi
callq 0x32e0
movq 0xa429(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x238(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x240(%rbp,%rcx)
callq 0x31e0
leaq -0x148(%rbp), %rdi
callq 0x30c0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6bf2
jmp 0x6bf2
jmp 0x6bf2
jmp 0x6bf2
jmp 0x6bf2
movq %rax, %rbx
movq 0xa3d4(%rip), %rax      # 0x10fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x238(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x240(%rbp,%rcx)
callq 0x31e0
leaq -0x148(%rbp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x33d0
nop