// File: /workspace/github_c_makefile_star2_O2/MaoKo[P]FGFX/fgfp/src/lr.c
// Function: check_conflict
bool
check_conflict(cfg_t const* cfg, lr1_state_t* state,
									trans_list_t** reduce_list, int kind) {

	trans_list_t* target_action = (kind == SHIFT_REDUCE)
								? state->shift_lst : state->reduces;
	bool several = false;
	if (state->accept)
		{ several = handle_accept_conflict(cfg, reduce_list); }

	while (target_action) {
		trans_list_t* reset_list = (*reduce_list);
		while (reset_list) {
			if (kind == SHIFT_REDUCE) {
				symbol_t* shift_sym = (symbol_t*)AT_VECTOR(cfg->terminal,
												reset_list->input);

				if ((_SHIFT ^ target_action->input) == reset_list->input) {
					production_t* crt_prod = (production_t*)
												AT_VECTOR(cfg->productions,
												_REDUCE ^ reset_list->state);
					symbol_t* last_sym;
					if (crt_prod->mimic_sym)
						{ last_sym = crt_prod->mimic_sym; }
					else
						{ last_sym = last_symbol_in_prod(crt_prod); }

					if (last_sym && PRECEDENCE(last_sym) != NOT_PREC
							&& PRECEDENCE(shift_sym) != NOT_PREC) {
						if (PRECEDENCE(last_sym) > PRECEDENCE(shift_sym)) {
							del_node_trans_list(&state->shift_lst,
															target_action);
						}
						else if (PRECEDENCE(last_sym) < PRECEDENCE(shift_sym))
							{ del_node_trans_list(reduce_list, reset_list); }
						else {
							if (LEFT(shift_sym)) {
								del_node_trans_list(&state->shift_lst,
															target_action);
							}
							if (RIGHT(shift_sym)) 
							{ del_node_trans_list(reduce_list, reset_list); }
						}
						return (check_conflict(cfg, state, reduce_list, kind));
					}
					else {
						// Favor of shifting
						del_node_trans_list(reduce_list, reset_list);
						several = true; break;
					}
				}
			}
			else if ((kind == REDUCE_REDUCE)
					&& (target_action->input == reset_list->input)) {
				// Favor of reducing by the rule that appear earlier

				trans_list_t const* tnode =
					(target_action->state > reset_list->state) ?
						target_action : reset_list ;

				trans_list_t** list_src =
					(target_action->state > reset_list->state) ?
						&state->reduces : reduce_list ;

				del_node_trans_list(list_src, tnode);
				return (true);
			}
			reset_list = reset_list->next;
		}
		target_action = target_action->next;
	}
	return (several);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r13d
movq %rdx, %r14
movq %rsi, %rcx
movq %rdi, %r15
leaq 0x10(%rsi), %rax
movq %rax, -0x38(%rbp)
leaq 0x20(%rsi), %rax
movq %rax, -0x48(%rbp)
movq %rsi, -0x30(%rbp)
xorl %eax, %eax
cmpl $0x1, %r13d
setne %al
shll $0x4, %eax
movq 0x10(%rax,%rcx), %r12
cmpb $0x1, 0x29(%rcx)
jne 0x7269
xorl %eax, %eax
xorl %ebx, %ebx
testb $0x1, %bl
jne 0x726b
movq %r14, %rsi
movq (%rsi), %rsi
testq %rsi, %rsi
sete %bl
je 0x7235
movq 0x10(%r15), %rcx
movq (%rcx), %rcx
movslq 0x8(%rsi), %rdx
movq (%rcx,%rdx,8), %rcx
cmpb $0x1, 0x18(%rcx)
jne 0x723d
movq %r14, %rdi
callq 0x380b
movb $0x1, %al
jmp 0x7235
xorl %eax, %eax
testq %r12, %r12
je 0x73bd
movq %r14, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x731b
cmpl $0x1, %r13d
jne 0x729e
movslq 0x8(%rbx), %rcx
movl 0x8(%r12), %edx
xorl %ecx, %edx
cmpl $0x1000, %edx           # imm = 0x1000
jne 0x7277
jmp 0x72b3
cmpl $0x2, %r13d
jne 0x7277
movl 0x8(%r12), %ecx
cmpl 0x8(%rbx), %ecx
jne 0x7277
jmp 0x739f
movq (%r15), %rax
movq 0x10(%r15), %rdx
movq (%rdx), %rdx
movq (%rdx,%rcx,8), %rsi
movq (%rax), %rax
movslq 0xc(%rbx), %rcx
xorq $0x4000, %rcx           # imm = 0x4000
movq (%rax,%rcx,8), %rdi
movq 0x28(%rdi), %rax
testq %rax, %rax
jne 0x72ee
movq %rsi, -0x40(%rbp)
callq 0x5536
movq -0x40(%rbp), %rsi
testq %rax, %rax
je 0x730e
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x730e
movl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x730e
movq 0x20(%rsi), %rax
testq %rax, %rax
je 0x730e
movl (%rax), %edx
cmpl $-0x1, %edx
jne 0x7324
movq %r14, %rdi
movq %rbx, %rsi
callq 0x380b
movb $0x1, %al
movq (%r12), %r12
jmp 0x726b
cmpl %edx, %ecx
jle 0x7331
movq -0x38(%rbp), %rdi
movq %r12, %rsi
jmp 0x7339
jge 0x734b
movq %r14, %rdi
movq %rbx, %rsi
callq 0x380b
pushq $0x1
popq %r13
movq -0x30(%rbp), %rcx
jmp 0x721a
cmpb $0x1, 0x4(%rax)
movq -0x30(%rbp), %rcx
jne 0x737b
movq -0x38(%rbp), %rdi
movq %rsi, %r13
movq %r12, %rsi
movq %rcx, %r12
callq 0x380b
movq %r12, %rcx
movq 0x20(%r13), %rax
pushq $0x1
popq %r13
testq %rax, %rax
je 0x721a
cmpb $0x1, 0x5(%rax)
pushq $0x1
popq %r13
jne 0x721a
movq %r14, %rdi
movq %rbx, %rsi
movq %rcx, %rbx
callq 0x380b
movq %rbx, %rcx
jmp 0x721a
movl 0xc(%r12), %eax
cmpl 0xc(%rbx), %eax
cmovgq %r12, %rbx
cmovgq -0x48(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x380b
movb $0x1, %al
andb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq