// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x4(%rbp), %edi
leaq 0x18bc(%rip), %rsi      # 0xcc4d
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x4150
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x19a8(%rip), %rsi      # 0xcd5e
movb $0x0, %al
callq 0x10d0
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0xb5b4
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movl -0x4(%rbp), %edi
movq -0x28(%rbp), %rdx
leaq 0x198e(%rip), %rsi      # 0xcd86
movb $0x0, %al
callq 0x10d0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xb47d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movl 0x8(%rcx), %ecx
xorl $0x1000, %ecx           # imm = 0x1000
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movl -0x4(%rbp), %edi
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x38(%rbp), %rax
movl 0xc(%rax), %ecx
leaq 0x1945(%rip), %rsi      # 0xcd93
movb $0x0, %al
callq 0x10d0
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0xb470
movl -0x4(%rbp), %edi
leaq 0x1aa3(%rip), %rsi      # 0xcf0c
movb $0x0, %al
callq 0x10d0
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0xb40b
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xb4a4
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xb4a4
movl -0x4(%rbp), %edi
leaq 0x1a6f(%rip), %rsi      # 0xcf0c
movb $0x0, %al
callq 0x10d0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xb546
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movl -0x4(%rbp), %edi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x18bc(%rip), %rsi      # 0xcda4
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
xorl $0x4000, %eax           # imm = 0x4000
movslq %eax, %rdx
callq 0xba00
movl -0x4(%rbp), %edi
leaq 0x18dd(%rip), %rsi      # 0xcdf1
movb $0x0, %al
callq 0x10d0
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
je 0xb536
movl -0x4(%rbp), %edi
leaq 0x19dd(%rip), %rsi      # 0xcf0c
movb $0x0, %al
callq 0x10d0
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0xb4b0
movq -0x30(%rbp), %rax
testb $0x1, 0x29(%rax)
je 0xb577
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0xb566
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xb577
movl -0x4(%rbp), %edi
leaq 0x199c(%rip), %rsi      # 0xcf0c
movb $0x0, %al
callq 0x10d0
movq -0x30(%rbp), %rax
testb $0x1, 0x29(%rax)
je 0xb592
movl -0x4(%rbp), %edi
leaq 0x1828(%rip), %rsi      # 0xcdb3
movb $0x0, %al
callq 0x10d0
movl -0x4(%rbp), %edi
leaq 0x1976(%rip), %rsi      # 0xcf12
movb $0x0, %al
callq 0x10d0
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xb3c5
movl -0x4(%rbp), %edi
leaq 0x16cc(%rip), %rsi      # 0xcc8a
movb $0x0, %al
callq 0x10d0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)