// File: kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::output_action_table(std::basic_ofstream<char, std::char_traits<char>>&)
void xbytes::output_action_table(std::ofstream& ss)
{
	for(int i = 0; i < states.size(); ++i)
	{
		ss << "/*" << std::setw(4) << i << "*/";
		for(int j = 0; j < states[i]->actions.size(); ++j)
		{
			int valid_action_count = 0;
			action_array& aa = states[i]->actions[j];
			for(int m = 0; m < aa.size(); ++m)
			{
				assert(valid_action_count <= 1);
				action& act = aa[m];
				switch(act.type)
				{
				case LR_ACTION_ACCEPT:
				case LR_ACTION_REDUCE:
					ss << "{" << act.type << "," << act.r->index << "},";
					valid_action_count++;
					break;
				case LR_ACTION_SHIFT:
				case LR_ACTION_GOTO:
					ss << "{" << act.type << "," << act.next_state << "},";
					valid_action_count++;
					break;
				case LR_ACTION_ERROR:
					ss << "{" << act.type << ",0},";
					valid_action_count++;
					break;
				}
			}			
		}
		ss << std::endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x48(%rbp)
addq $0x38, %rdi
callq 0xc550
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0xbb69
movq -0x10(%rbp), %rdi
leaq 0xdef4(%rip), %rsi      # 0x19803
callq 0x32e0
movq %rax, -0x50(%rbp)
movl $0x4, %edi
callq 0xd690
movq -0x50(%rbp), %rdi
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %esi
callq 0x3380
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xdf1a(%rip), %rsi      # 0x19860
callq 0x32e0
movl $0x0, -0x1c(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x58(%rbp)
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0xc570
movq (%rax), %rdi
addq $0x50, %rdi
callq 0xcef0
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
jae 0xbb4b
movq -0x40(%rbp), %rdi
movl $0x0, -0x20(%rbp)
addq $0x38, %rdi
movslq -0x14(%rbp), %rsi
callq 0xc570
movq (%rax), %rdi
addq $0x50, %rdi
movslq -0x1c(%rbp), %rsi
callq 0xce30
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x28(%rbp), %rdi
callq 0xcf20
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0xbb3b
cmpl $0x1, -0x20(%rbp)
jg 0xb9e3
jmp 0xba02
leaq 0xdd2a(%rip), %rdi      # 0x19714
leaq 0xd7a7(%rip), %rsi      # 0x19198
movl $0x60b, %edx            # imm = 0x60B
leaq 0xde15(%rip), %rcx      # 0x19812
callq 0x31d0
movq -0x28(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0xcf50
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x64(%rbp)
decl %eax
subl $0x2, %eax
jb 0xba9f
jmp 0xba25
movl -0x64(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0xba43
jmp 0xba32
movl -0x64(%rbp), %eax
subl $0x5, %eax
je 0xbaf5
jmp 0xbb2b
movq -0x10(%rbp), %rdi
leaq 0xddfe(%rip), %rsi      # 0x1984c
callq 0x32e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xdd9c(%rip), %rsi      # 0x19807
callq 0x32e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xddc4(%rip), %rsi      # 0x19850
callq 0x32e0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbb2b
movq -0x10(%rbp), %rdi
leaq 0xdda2(%rip), %rsi      # 0x1984c
callq 0x32e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xdd40(%rip), %rsi      # 0x19807
callq 0x32e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xdd6b(%rip), %rsi      # 0x19850
callq 0x32e0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbb2b
movq -0x10(%rbp), %rdi
leaq 0xdd4c(%rip), %rsi      # 0x1984c
callq 0x32e0
movq %rax, %rdi
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x34d0
movq %rax, %rdi
leaq 0xdd31(%rip), %rsi      # 0x1984e
callq 0x32e0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xbb2d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xb9ba
jmp 0xbb3d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xb952
movq -0x10(%rbp), %rdi
movq 0x18472(%rip), %rsi     # 0x23fc8
callq 0x3320
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb8df
addq $0x70, %rsp
popq %rbp
retq
nop