// File: /workspace/github_cpp_makefile_star2_O2/kiven-li[P]xbytes/xbytes.cpp
// Function: xbytes::xbytes::resolve_conflict(xbytes::action&, xbytes::action&)
int xbytes::resolve_conflict(action& x, action& y)
{
	int error = 0;
	assert(x.lookahead == y.lookahead);

	if(x.type == LR_ACTION_SHIFT && y.type == LR_ACTION_SHIFT)
	{
		y.type = LR_ACTION_SSCONFLICT;
		error++;
	}

	if(x.type == LR_ACTION_SHIFT && y.type == LR_ACTION_REDUCE)
	{
		symbol* xs = x.lookahead;
		symbol* ys = y.r->precedence_symbol;

		if(ys == NULL || xs->precedence < 0 || ys->precedence < 0)
		{
			//Not enough precedence information
			y.type = LR_ACTION_SRCONFLICT;
			error++;
		}
		else if(xs->precedence > ys->precedence)
		{
			y.type = LR_ACTION_RDRESOLVED;
		}
		else if(xs->precedence < ys->precedence)
		{
			x.type = LR_ACTION_SHRESOLVED;
		}
		else if(xs->precedence == ys->precedence && xs->associativity == AT_RIGHT)//Use operator
		{
			y.type = LR_ACTION_RDRESOLVED;//associativity
		}
		else if(xs->precedence == ys->precedence && xs->associativity == AT_LEFT)//to break tie
		{
			x.type = LR_ACTION_SHRESOLVED;
		}
		else
		{
			assert(xs->precedence == ys->precedence && xs->associativity == AT_NONE);
			x.type = LR_ACTION_ERROR;
		}
	}
	else if(x.type = LR_ACTION_REDUCE && y.type == LR_ACTION_REDUCE)
	{
		symbol* xs = x.r->precedence_symbol;
		symbol* ys = y.r->precedence_symbol;

		if(xs == NULL || ys == NULL || xs->precedence < 0 || 
			ys->precedence < 0 || xs->precedence == ys->precedence)
		{
			y.type = LR_ACTION_RRCONFLICT;
			error++;
		}
		else if(xs->precedence > ys->precedence)
		{
			y.type = LR_ACTION_RDRESOLVED;
		}
		else if(xs->precedence < ys->precedence)
		{
			x.type = LR_ACTION_RDRESOLVED;
		}
	}
	else
	{
		assert(
			x.type == LR_ACTION_SHRESOLVED ||
			x.type == LR_ACTION_RDRESOLVED ||
			x.type == LR_ACTION_SSCONFLICT ||
			x.type == LR_ACTION_SRCONFLICT ||
			x.type == LR_ACTION_RRCONFLICT ||
			y.type == LR_ACTION_SHRESOLVED ||
			y.type == LR_ACTION_RDRESOLVED ||
			y.type == LR_ACTION_SSCONFLICT ||
			y.type == LR_ACTION_SRCONFLICT ||
			y.type == LR_ACTION_RRCONFLICT
			);
	}

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x10(%rsi), %rax
cmpq 0x10(%rdx), %rax
jne 0x5452
movl (%rsi), %edi
xorl $0x2, %edi
movl (%rdx), %ecx
movl %ecx, %r8d
xorl $0x2, %r8d
orl %edi, %r8d
jne 0x533c
movl $0x6, (%rdx)
andl $0x0, (%rsi)
pushq $0x1
popq %rax
movl (%rdx), %ecx
addl $-0x6, %ecx
cmpl $0x5, %ecx
jb 0x5430
leaq 0x4f66(%rip), %rdi      # 0xa28a
leaq 0x4e7d(%rip), %rsi      # 0xa1a8
leaq 0x4ede(%rip), %rcx      # 0xa210
movl $0x306, %edx            # imm = 0x306
callq 0x2160
movl %ecx, %r8d
xorl $0x3, %r8d
orl %r8d, %edi
jne 0x53c1
movq 0x8(%rdx), %rcx
movq 0xa0(%rcx), %rcx
testq %rcx, %rcx
je 0x541f
movl 0xa0(%rax), %edi
testl %edi, %edi
js 0x541f
movl 0xa0(%rcx), %ecx
testl %ecx, %ecx
js 0x541f
cmpl %ecx, %edi
ja 0x5417
jb 0x5432
movl 0xa4(%rax), %eax
testl %eax, %eax
je 0x544a
cmpl $0x1, %eax
je 0x5432
cmpl $0x2, %eax
je 0x5417
leaq 0x4ea0(%rip), %rdi      # 0xa249
leaq 0x4df8(%rip), %rsi      # 0xa1a8
leaq 0x4e59(%rip), %rcx      # 0xa210
movl $0x2e1, %edx            # imm = 0x2E1
callq 0x2160
xorl %eax, %eax
xorl %edi, %edi
cmpl $0x3, %ecx
sete %dil
movl %edi, (%rsi)
jne 0x530f
movq 0x8(%rsi), %rax
movq 0xa0(%rax), %rcx
movq 0x8(%rdx), %rax
movq 0xa0(%rax), %rax
testq %rcx, %rcx
sete %dil
testq %rax, %rax
sete %r8b
orb %dil, %r8b
jne 0x5427
movl 0xa0(%rcx), %ecx
testl %ecx, %ecx
js 0x5427
movl 0xa0(%rax), %edi
testl %edi, %edi
js 0x5427
cmpl %edi, %ecx
je 0x5427
jbe 0x543c
movl $0x9, (%rdx)
jmp 0x5438
movl $0x7, (%rdx)
jmp 0x542d
movl $0x8, (%rdx)
pushq $0x1
popq %rax
popq %rbp
retq
movl $0xa, (%rsi)
xorl %eax, %eax
jmp 0x5430
xorl %eax, %eax
cmpl %edi, %ecx
jae 0x5430
movl $0x9, (%rsi)
jmp 0x5430
movl $0x5, (%rsi)
jmp 0x5438
leaq 0x4d9c(%rip), %rdi      # 0xa1f5
leaq 0x4d48(%rip), %rsi      # 0xa1a8
leaq 0x4da9(%rip), %rcx      # 0xa210
movl $0x2bc, %edx            # imm = 0x2BC
callq 0x2160
nop