// File: /workspace/github_cpp_makefile_star2_O3/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/reduce.cpp
// Function: reduce3(std::vector<xpair, std::allocator<xpair>>&, int**)
bool reduce3(vector<xpair> &seq, int** table)
{
	int s = seq.size();
	int index;

	for(int i = 0; i < s; i++)
	{
		for(int j = i + 1; j < s; j++)
		{
			if((table[i][j - 1] == 0) && (table[j][i + 1] == 0))
				break;
			if(seq[j].dst != seq[i].src)
				continue;
			if(seq[j].src != seq[i].dst)
				continue;
			if(table[i][j - 1])
				index = j - 1;
			else
				index = i;
			xpair tmp = seq[j];
			seq.erase(seq.begin() + j);
			seq.erase(seq.begin() + i);
			seq.insert(seq.begin() + index, tmp);
			int mask = seq[index].dst ^ seq[index].src;
			for(int k = index + 1; k < s; k++)
			{
				if((seq[k].dst == seq[index].dst) || (seq[k].dst == seq[index].src))
					seq[k].dst ^= mask;
				if((seq[k].src == seq[index].dst) || (seq[k].src == seq[index].src))
					seq[k].src ^= mask;
			}
			return true;
		}
	}
	return false;
}

// Assembly:
movq %rsi, %rcx
movq %rdi, %r8
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
movq %rdx, %r9
subq %rsi, %r9
movq %r9, %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdi
testl %edi, %edi
jle 0x6107
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
leaq -0x1(%rdi), %r9
movb $0x1, %al
movl $0x18, %ebp
xorl %r11d, %r11d
movb %al, 0x7(%rsp)
movq %r11, %r13
incq %r11
cmpq %rdi, %r11
setb %al
jae 0x60b0
movq (%rcx,%r13,8), %r15
leaq (,%r13,2), %r8
addq %r13, %r8
movq %r8, 0x20(%rsp)
leaq (%rsi,%r8,4), %rbx
movq %rbp, %r10
movq %r13, %r14
movl (%r15,%r14,4), %r8d
testl %r8d, %r8d
jne 0x608f
movq 0x8(%rcx,%r14,8), %r12
cmpl $0x0, (%r12,%r11,4)
je 0x60b0
movl -0x8(%rsi,%r10), %r12d
cmpl (%rbx), %r12d
jne 0x60a4
movl -0xc(%rsi,%r10), %r12d
cmpl 0x4(%rbx), %r12d
je 0x60be
incq %r14
addq $0xc, %r10
cmpq %r14, %r9
jne 0x607a
addq $0xc, %rbp
cmpq %rdi, %r11
jne 0x604a
jmp 0x61c7
testl %r8d, %r8d
cmoveq %r13, %r14
leaq (%rsi,%r10), %rax
movl -0x4(%rsi,%r10), %ecx
movl %ecx, 0x30(%rsp)
movq -0xc(%rsi,%r10), %rcx
movq %rcx, 0x28(%rsp)
cmpq %rdx, %rax
je 0x610e
leaq (%rsi,%r10), %rdi
addq $-0xc, %rdi
movq 0x10(%rsp), %rdx
subq %r10, %rdx
movq %rax, %rsi
callq 0x2240
movq 0x8(%rsp), %r15
movq (%r15), %rsi
movq 0x8(%r15), %rdx
jmp 0x6113
xorl %eax, %eax
jmp 0x61d5
movq 0x8(%rsp), %r15
addq $-0xc, %rdx
movq %rdx, 0x8(%r15)
movq 0x20(%rsp), %rcx
leaq (%rsi,%rcx,4), %rax
addq $0xc, %rax
cmpq %rdx, %rax
je 0x6143
leaq (%rsi,%rcx,4), %rdi
subq %rax, %rdx
movq %rax, %rsi
callq 0x2240
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq $-0xc, %rdx
movq %rdx, 0x8(%r15)
movslq %r14d, %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %rbx
addq %rbx, %rsi
leaq 0x28(%rsp), %rdx
movq %r15, %rdi
callq 0x6b66
leal 0x1(%r14), %esi
movq 0x18(%rsp), %r8
cmpl %r8d, %esi
jge 0x61c3
movq (%r15), %rdi
leaq (%rdi,%rbx), %rax
movl 0x4(%rdi,%rbx), %edx
movl (%rdi,%rbx), %ecx
xorl %edx, %ecx
movslq %esi, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,4), %rsi
addq $0x4, %rsi
notl %r14d
addl %r8d, %r14d
movl (%rsi), %edi
cmpl %edx, %edi
je 0x61a3
cmpl (%rax), %edi
jne 0x61aa
xorl %ecx, %edi
movl %edi, (%rsi)
movl 0x4(%rax), %edx
movl -0x4(%rsi), %edi
cmpl %edx, %edi
je 0x61b5
cmpl (%rax), %edi
jne 0x61ba
xorl %ecx, %edi
movl %edi, -0x4(%rsi)
addq $0xc, %rsi
decl %r14d
jne 0x6199
movb 0x7(%rsp), %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
andb $0x1, %al
retq