// File: /workspace/github_c_makefile_star2_O3/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 0x25bc(%rip), %rsi      # 0xa897
xorl %eax, %eax
callq 0x20f0
movl %ebx, %edi
movq %r14, %rsi
callq 0x3eaa
movq 0x10(%r12), %rdx
leaq 0x26b0(%rip), %rsi      # 0xa9a8
movl %ebx, %edi
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, 0x10(%r12)
je 0x848d
leaq 0x2842(%rip), %r13      # 0xab56
xorl %r14d, %r14d
movq %r12, -0x38(%rbp)
movq (%r12), %rax
movq (%rax,%r14,8), %r12
movl %ebx, %edi
leaq 0x26a4(%rip), %rsi      # 0xa9d0
movq %r14, %rdx
xorl %eax, %eax
callq 0x20f0
movq %r12, -0x30(%rbp)
movq 0x10(%r12), %r12
testq %r12, %r12
je 0x838d
movq 0x10(%r15), %rax
movq (%rax), %rax
movslq 0x8(%r12), %rcx
xorq $0x1000, %rcx           # imm = 0x1000
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdx
movl 0xc(%r12), %ecx
movl %ebx, %edi
leaq 0x2670(%rip), %rsi      # 0xa9dd
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, (%r12)
je 0x838d
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq (%r12), %r12
jmp 0x833f
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r12
testq %r12, %r12
je 0x8425
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x83bf
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %r12
jmp 0x8420
movq 0x10(%r15), %rax
movq (%rax), %rax
movslq 0x8(%r12), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rdx
movl %ebx, %edi
leaq 0x2612(%rip), %rsi      # 0xa9ee
xorl %eax, %eax
callq 0x20f0
movslq 0xc(%r12), %rdx
xorq $0x4000, %rdx           # imm = 0x4000
movl %ebx, %edi
movq %r15, %rsi
callq 0x8834
movl %ebx, %edi
leaq 0x2639(%rip), %rsi      # 0xaa3b
xorl %eax, %eax
callq 0x20f0
cmpq $0x0, (%r12)
je 0x8425
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq (%r12), %r12
testq %r12, %r12
jne 0x83bf
movq -0x30(%rbp), %rcx
movb 0x29(%rcx), %al
cmpb $0x1, %al
jne 0x8457
cmpq $0x0, 0x20(%rcx)
movq -0x38(%rbp), %r12
jne 0x8442
cmpq $0x0, 0x10(%rcx)
je 0x845b
movl %ebx, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
movq -0x30(%rbp), %rax
movb 0x29(%rax), %al
jmp 0x845b
movq -0x38(%rbp), %r12
testb $0x1, %al
je 0x846f
movl %ebx, %edi
leaq 0x2595(%rip), %rsi      # 0xa9fd
xorl %eax, %eax
callq 0x20f0
movl %ebx, %edi
leaq 0x26e4(%rip), %rsi      # 0xab5c
xorl %eax, %eax
callq 0x20f0
incq %r14
cmpq 0x10(%r12), %r14
jb 0x831b
leaq 0x2440(%rip), %rsi      # 0xa8d4
movl %ebx, %edi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0