// File: /workspace/github_c_makefile_star2_O1/MaoKo[P]FGFX/fgfp/src/gen_lr.c
// Function: gen_action_table
void
gen_action_table(int filde, cfg_t const* cfg,
							vector_t const* lr1_states, char const* header) {

	dprintf(filde, STATIC SP INT NL);
	gen_verbatim_file(filde, header);

	dprintf(filde, "_lr_action_table[%zu][" MACRO_TOKEN "] = " BEG_BLOCK NL,
			SIZE_VECTOR(lr1_states));

	for (size_t i = 0; i < SIZE_VECTOR(lr1_states); ++i) {
		lr1_state_t* state = (lr1_state_t*)AT_VECTOR(lr1_states, i);
		dprintf(filde, "/* %3zu */" TAB BEG_BLOCK, i);
		trans_list_t* action = state->shift_lst;
		while (action) {
			symbol_t* ter = (symbol_t*)AT_VECTOR(cfg->terminal,
													action->input ^ _SHIFT);
			dprintf(filde, "[" TOKEN_PREFIX SEP "%s]="
					SHIFT_STR "(%d)", ter->name, action->state);
			if (action->next)
				{ dprintf(filde, COMMA SP); }
			action = action->next;
		}
	
		if (state->reduces && state->shift_lst) 
			{ dprintf(filde, COMMA SP); }
		
		action = state->reduces;
		while (action) {
			symbol_t* ter = (symbol_t*)AT_VECTOR(cfg->terminal, action->input);
			dprintf(filde, "[" TOKEN_PREFIX SEP "%s]="
												REDUCE_STR "(", ter->name);
			gen_nproduction(filde, cfg, action->state ^ _REDUCE);		
			dprintf(filde, ")");
	
			if  (action->next)
				{ dprintf(filde, COMMA SP); }
			action = action->next;
		}

		if (state->accept && (state->reduces || state->shift_lst))
			{ dprintf(filde, COMMA SP); }

		if (state->accept)
			{ dprintf(filde, "[T_EOF]=" ACCEPT_STR COMMA); }
		dprintf(filde, END_BLOCK COMMA NL);
	}
	dprintf(filde, END_BLOCK SEMI NL NL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movl %edi, %ebx
leaq 0x2246(%rip), %rsi      # 0xa899
xorl %eax, %eax
callq 0x20f0
movl %ebx, %edi
movq %r14, %rsi
callq 0x3fa6
movq 0x10(%r12), %rdx
leaq 0x233a(%rip), %rsi      # 0xa9aa
movl %ebx, %edi
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, 0x10(%r12)
je 0x87ec
movq %r12, %rax
leaq 0x24c9(%rip), %r13      # 0xab58
leaq 0x2349(%rip), %r12      # 0xa9df
xorl %edx, %edx
movq %rax, -0x38(%rbp)
movq (%rax), %rax
movq (%rax,%rdx,8), %r14
movl %ebx, %edi
leaq 0x2326(%rip), %rsi      # 0xa9d2
movq %rdx, -0x40(%rbp)
xorl %eax, %eax
callq 0x20f0
movq %r14, -0x30(%rbp)
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x8705
movq 0x10(%r15), %rax
movq (%rax), %rax
movslq 0x8(%r14), %rcx
xorq $0x1000, %rcx           # imm = 0x1000
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdx
movl 0xc(%r14), %ecx
movl %ebx, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, (%r14)
je 0x8700
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq (%r14), %r14
jmp 0x86bf
movq -0x30(%rbp), %r14
cmpq $0x0, 0x20(%r14)
je 0x8723
cmpq $0x0, 0x10(%r14)
je 0x8723
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq 0x20(%r14), %r14
testq %r14, %r14
je 0x878b
movq 0x10(%r15), %rax
movq (%rax), %rax
movslq 0x8(%r14), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdx
movl %ebx, %edi
leaq 0x22a8(%rip), %rsi      # 0xa9f0
xorl %eax, %eax
callq 0x20f0
movslq 0xc(%r14), %rdx
xorq $0x4000, %rdx           # imm = 0x4000
movl %ebx, %edi
movq %r15, %rsi
callq 0x8b94
movl %ebx, %edi
leaq 0x22d0(%rip), %rsi      # 0xaa3d
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, (%r14)
je 0x8786
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq (%r14), %r14
jmp 0x8727
movq -0x30(%rbp), %r14
cmpb $0x1, 0x29(%r14)
jne 0x87b0
cmpq $0x0, 0x20(%r14)
jne 0x87a4
cmpq $0x0, 0x10(%r14)
je 0x87b0
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
cmpb $0x1, 0x29(%r14)
jne 0x87c7
movl %ebx, %edi
leaq 0x223f(%rip), %rsi      # 0xa9ff
xorl %eax, %eax
callq 0x20f0
movl %ebx, %edi
leaq 0x238e(%rip), %rsi      # 0xab5e
xorl %eax, %eax
callq 0x20f0
movq -0x40(%rbp), %rdx
incq %rdx
movq -0x38(%rbp), %rax
cmpq 0x10(%rax), %rdx
jb 0x869c
leaq 0x20e3(%rip), %rsi      # 0xa8d6
movl %ebx, %edi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0