// File: /workspace/github_cpp_makefile_star2_O3/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 0x77c7
movl (%rsi), %edi
xorl $0x2, %edi
movl (%rdx), %ecx
movl %ecx, %r8d
xorl $0x2, %r8d
orl %edi, %r8d
jne 0x76af
movl $0x6, (%rdx)
movl $0x0, (%rsi)
movl $0x1, %eax
movl (%rdx), %ecx
addl $-0x6, %ecx
cmpl $0x5, %ecx
jb 0x77a5
leaq 0x5bf3(%rip), %rdi      # 0xd28a
leaq 0x5b0a(%rip), %rsi      # 0xd1a8
leaq 0x5b6b(%rip), %rcx      # 0xd210
movl $0x306, %edx            # imm = 0x306
callq 0x3150
movl %ecx, %r8d
xorl $0x3, %r8d
orl %r8d, %edi
jne 0x7734
movq 0x8(%rdx), %rcx
movq 0xa0(%rcx), %rcx
testq %rcx, %rcx
je 0x7792
movl 0xa0(%rax), %edi
testl %edi, %edi
js 0x7792
movl 0xa0(%rcx), %ecx
testl %ecx, %ecx
js 0x7792
cmpl %ecx, %edi
ja 0x778a
jb 0x77a7
movl 0xa4(%rax), %eax
testl %eax, %eax
je 0x77bf
cmpl $0x1, %eax
je 0x77a7
cmpl $0x2, %eax
je 0x778a
leaq 0x5b2d(%rip), %rdi      # 0xd249
leaq 0x5a85(%rip), %rsi      # 0xd1a8
leaq 0x5ae6(%rip), %rcx      # 0xd210
movl $0x2e1, %edx            # imm = 0x2E1
callq 0x3150
xorl %eax, %eax
xorl %edi, %edi
cmpl $0x3, %ecx
sete %dil
movl %edi, (%rsi)
jne 0x7682
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 0x779a
movl 0xa0(%rcx), %ecx
testl %ecx, %ecx
js 0x779a
movl 0xa0(%rax), %edi
testl %edi, %edi
js 0x779a
cmpl %edi, %ecx
je 0x779a
jbe 0x77b1
movl $0x9, (%rdx)
jmp 0x77ad
movl $0x7, (%rdx)
jmp 0x77a0
movl $0x8, (%rdx)
movl $0x1, %eax
popq %rbp
retq
movl $0xa, (%rsi)
xorl %eax, %eax
jmp 0x77a5
xorl %eax, %eax
cmpl %edi, %ecx
jae 0x77a5
movl $0x9, (%rsi)
jmp 0x77a5
movl $0x5, (%rsi)
jmp 0x77ad
leaq 0x5a27(%rip), %rdi      # 0xd1f5
leaq 0x59d3(%rip), %rsi      # 0xd1a8
leaq 0x5a34(%rip), %rcx      # 0xd210
movl $0x2bc, %edx            # imm = 0x2BC
callq 0x3150