// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movl %ecx, %ebx
movq %rdx, -0x40(%rbp)
movq %rdi, %r12
xorl %eax, %eax
cmpl $0x1, %ecx
setne %al
shll $0x4, %eax
movq 0x10(%rax,%rsi), %rax
movq %rax, -0x38(%rbp)
movq %rsi, -0x58(%rbp)
cmpb $0x1, 0x29(%rsi)
jne 0x79eb
xorl %r13d, %r13d
xorl %esi, %esi
movq -0x40(%rbp), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x79d0
movq 0x10(%r12), %rax
movq (%rax), %rax
movslq 0x8(%r15), %rcx
movq (%rax,%rcx,8), %rax
movb 0x18(%rax), %r14b
cmpb $0x1, %r14b
jne 0x79c6
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x3c37
movb $0x1, %sil
jmp 0x79c9
movq (%r15), %r15
testb %r14b, %r14b
je 0x7996
jmp 0x79d3
xorl %r15d, %r15d
testq %r15, %r15
movzbl %r13b, %r13d
movl $0x1, %eax
cmovel %eax, %r13d
testb $0x1, %r13b
je 0x798f
jmp 0x79ed
xorl %esi, %esi
movq -0x58(%rbp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, -0x50(%rbp)
addq $0x20, %rax
movq %rax, -0x60(%rbp)
movq %r12, -0x68(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x7ba5
movq -0x40(%rbp), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x7b5d
cmpl $0x1, %ebx
jne 0x7acb
movslq 0x8(%r15), %rax
movq -0x38(%rbp), %rcx
movl 0x8(%rcx), %ecx
xorl %eax, %ecx
xorl %r14d, %r14d
cmpl $0x1000, %ecx           # imm = 0x1000
setne %r13b
jne 0x7af7
movq 0x10(%r12), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %r14
movq (%r12), %rax
movq (%rax), %rax
movslq 0xc(%r15), %rcx
xorq $0x4000, %rcx           # imm = 0x4000
movq (%rax,%rcx,8), %rdi
movq 0x28(%rdi), %rax
testq %rax, %rax
jne 0x7a95
movl %ebx, %r12d
movl %r13d, %ebx
movq %r14, %r13
movl %esi, %r14d
callq 0x5a18
movl %r14d, %esi
movq %r13, %r14
movl %ebx, %r13d
movl %r12d, %ebx
movq -0x68(%rbp), %r12
testq %rax, %rax
je 0x7ae2
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x7ae2
movl (%rax), %ecx
cmpl $-0x1, %ecx
je 0x7ae2
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x7ae2
movl (%rax), %edx
cmpl $-0x1, %edx
je 0x7ae2
cmpl %edx, %ecx
movl %esi, -0x44(%rbp)
jle 0x7b04
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
jmp 0x7b2f
cmpl $0x2, %ebx
jne 0x7afc
movq -0x38(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x8(%r15), %eax
jne 0x7afc
jmp 0x7b76
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x3c37
movl $0x5, %r14d
movb $0x1, %sil
testl %r14d, %r14d
jne 0x7b57
movq (%r15), %r15
jmp 0x7a17
jl 0x7b28
cmpb $0x1, 0x4(%rax)
jne 0x7b19
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3c37
movq 0x20(%r14), %rax
testq %rax, %rax
je 0x7b34
cmpb $0x1, 0x5(%rax)
jne 0x7b34
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x3c37
movl $0x1, %r14d
movq %r12, %rdi
movq -0x58(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
callq 0x7952
movb %al, -0x29(%rbp)
movl -0x44(%rbp), %esi
jmp 0x7af7
cmpl $0x5, %r14d
jne 0x7b6b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movb $0x1, %r13b
testb %r13b, %r13b
jne 0x7a05
jmp 0x7ba9
movq -0x38(%rbp), %rcx
movl 0xc(%rcx), %eax
cmpl 0xc(%r15), %eax
cmovgq %rcx, %r15
movq -0x40(%rbp), %rdi
cmovgq -0x60(%rbp), %rdi
movl %esi, %r14d
movq %r15, %rsi
callq 0x3c37
movl %r14d, %esi
movb $0x1, -0x29(%rbp)
xorl %r13d, %r13d
jmp 0x7b6b
movb %sil, -0x29(%rbp)
movb -0x29(%rbp), %al
andb $0x1, %al
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq