// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
leaq -0x240(%rbp), %r15
movq %r15, %rdi
callq 0x33a0
leaq 0x7569(%rip), %rsi      # 0xd9a4
movq %r15, %rdi
movl $0x10, %edx
callq 0x3040
movq 0x38(%r14), %rax
cmpq %rax, 0x40(%r14)
je 0x6b70
xorl %ebx, %ebx
movq %r14, -0x38(%rbp)
movq (%rax,%rbx,8), %rax
movq %rax, -0x30(%rbp)
movl $0x6, %edx
movq %r15, %rdi
leaq 0x726f(%rip), %rsi      # 0xd6e2
callq 0x32b0
leaq -0x240(%rbp), %rdi
movl %ebx, %esi
callq 0x33b0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6cff(%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 0x660e
xorl %r15d, %r15d
movq (%rax,%r15,8), %rax
movq (%rax), %r12
movl 0x8(%rax), %r14d
movl $0x1, %edx
movq %r13, %rdi
leaq 0x7150(%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 0x71c1(%rip), %rsi      # 0xd6e9
callq 0x32b0
movq 0x38(%r12), %rax
cmpq 0x30(%r12), %rax
je 0x65a1
xorl %r13d, %r13d
cmpq %r13, %r14
leaq -0x240(%rbp), %rbx
jne 0x655c
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x72bd(%rip), %rsi      # 0xd814
callq 0x32b0
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x706a(%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 0x653c
jmp 0x65a4
xorl %r13d, %r13d
cmpl %r14d, %r13d
leaq -0x240(%rbp), %r13
jne 0x65c4
movl $0x1, %edx
movq %r13, %rdi
leaq 0x7255(%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 0x64e5
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
movq -0x38(%rbp), %r14
movq -0x40(%rbp), %rbx
movsbl %al, %esi
leaq -0x240(%rbp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
movq 0x38(%r14), %rax
movq (%rax,%rbx,8), %rcx
movq 0x50(%rcx), %rax
cmpq %rax, 0x58(%rcx)
je 0x6b18
xorl %esi, %esi
movq %rsi, -0x30(%rbp)
leaq (%rsi,%rsi,2), %rcx
movq (%rax,%rcx,8), %r14
cmpq %r14, 0x8(%rax,%rcx,8)
je 0x6adb
leaq (%rax,%rcx,8), %rbx
movl $0x8, %r15d
xorl %r12d, %r12d
movl -0x8(%r14,%r15), %eax
decl %eax
cmpl $0x9, %eax
ja 0x6aaf
leaq 0x69ec(%rip), %rcx      # 0xd084
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6f9b(%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 0x6fff(%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 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6f1f(%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 0x7244(%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 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6ea2(%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 0x71ec(%rip), %rsi      # 0xd9d4
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6e35(%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 0x7163(%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 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6db9(%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 0x710f(%rip), %rsi      # 0xd9e0
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6d4c(%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 0x70ae(%rip), %rsi      # 0xd9ec
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6cdf(%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 0x7015(%rip), %rsi      # 0xd9c0
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6c72(%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 0x6fb0(%rip), %rsi      # 0xd9c8
callq 0x32b0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3230
jmp 0x6a9c
movl $0x1, %edx
leaq -0x240(%rbp), %rdi
leaq 0x6c08(%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 0x6f76(%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 0x6681
movq -0x30(%rbp), %rsi
incq %rsi
movq -0x38(%rbp), %r14
movq 0x38(%r14), %rax
movq -0x40(%rbp), %rbx
movq (%rax,%rbx,8), %rcx
movq 0x50(%rcx), %rax
movq 0x58(%rcx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rsi, %rcx
ja 0x665d
movq -0x240(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x240(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x3230
movsbl %al, %esi
leaq -0x240(%rbp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3170
incq %rbx
movq 0x38(%r14), %rax
movq 0x40(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
leaq -0x240(%rbp), %r15
ja 0x645c
leaq -0x240(%rbp), %rdi
callq 0x32e0
movq 0xa44d(%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 0x6bce
jmp 0x6bce
jmp 0x6bce
jmp 0x6bce
jmp 0x6bce
movq %rax, %rbx
movq 0xa3f8(%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