// File: /workspace/github_cpp_makefile_star2_O1/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), %rcx
cmpq 0x10(%rdx), %rcx
jne 0x7837
xorl %eax, %eax
cmpl $0x2, (%rsi)
jne 0x770f
cmpl $0x2, (%rdx)
jne 0x770f
movl $0x6, (%rdx)
movl $0x1, %eax
movl (%rsi), %r8d
xorl $0x2, %r8d
movl (%rdx), %edi
movl %edi, %r9d
xorl $0x3, %r9d
orl %r8d, %r9d
jne 0x7768
movq 0x8(%rdx), %rdi
movq 0xa0(%rdi), %r8
testq %r8, %r8
je 0x77c1
movl 0xa0(%rcx), %edi
testl %edi, %edi
js 0x77c1
movl 0xa0(%r8), %r8d
testl %r8d, %r8d
js 0x77c1
cmpl %r8d, %edi
jg 0x7807
jge 0x77fc
movl $0xa, (%rsi)
jmp 0x77fa
xorl %ecx, %ecx
cmpl $0x3, %edi
sete %cl
movl %ecx, (%rsi)
jne 0x77c9
movq 0x8(%rsi), %rcx
movq 0xa0(%rcx), %rdi
movq 0x8(%rdx), %rcx
movq 0xa0(%rcx), %rcx
testq %rdi, %rdi
sete %r8b
testq %rcx, %rcx
sete %r9b
orb %r8b, %r9b
jne 0x77f2
movl 0xa0(%rdi), %edi
testl %edi, %edi
js 0x77f2
movl 0xa0(%rcx), %ecx
testl %ecx, %ecx
js 0x77f2
cmpl %ecx, %edi
je 0x77f2
jg 0x7807
jge 0x77fa
movl $0x9, (%rsi)
jmp 0x77fa
movl $0x7, (%rdx)
jmp 0x77f8
movl (%rdx), %ecx
addl $-0x6, %ecx
cmpl $0x5, %ecx
jb 0x77fa
leaq 0x5ab0(%rip), %rdi      # 0xd28a
leaq 0x59c7(%rip), %rsi      # 0xd1a8
leaq 0x5a28(%rip), %rcx      # 0xd210
movl $0x306, %edx            # imm = 0x306
callq 0x3150
movl $0x8, (%rdx)
incl %eax
popq %rbp
retq
jne 0x7856
cmpl $0x2, 0xa4(%rcx)
jne 0x780f
movl $0x9, (%rdx)
jmp 0x77fa
cmpl %r8d, %edi
jne 0x7856
cmpl $0x1, 0xa4(%rcx)
je 0x775d
cmpl %r8d, %edi
jne 0x7856
cmpl $0x0, 0xa4(%rcx)
jne 0x7856
movl $0x5, (%rsi)
jmp 0x77fa
leaq 0x59b7(%rip), %rdi      # 0xd1f5
leaq 0x5963(%rip), %rsi      # 0xd1a8
leaq 0x59c4(%rip), %rcx      # 0xd210
movl $0x2bc, %edx            # imm = 0x2BC
callq 0x3150
leaq 0x59ec(%rip), %rdi      # 0xd249
leaq 0x5944(%rip), %rsi      # 0xd1a8
leaq 0x59a5(%rip), %rcx      # 0xd210
movl $0x2e1, %edx            # imm = 0x2E1
callq 0x3150
nop