// File: 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:
subq $0xe8, %rsp
movq %rdi, 0xd8(%rsp)
movq %rsi, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x3280
movl %eax, 0xcc(%rsp)
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
cmpl 0xcc(%rsp), %eax
jge 0xb5cb
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
movl 0xc0(%rsp), %eax
cmpl 0xcc(%rsp), %eax
jge 0xb5b3
movq 0xd0(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0xc0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xb1d2
movq 0xd0(%rsp), %rax
movslq 0xc0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0xc4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xb1d2
jmp 0xb5b3
movq 0xd8(%rsp), %rdi
movslq 0xc0(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x44(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x44(%rsp), %eax
cmpl (%rcx), %eax
je 0xb213
jmp 0xb59d
movq 0xd8(%rsp), %rdi
movslq 0xc0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x40(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xb254
jmp 0xb59d
movq 0xd0(%rsp), %rax
movslq 0xc4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0xc0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xb28e
movl 0xc0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0xb29c
movl 0xc4(%rsp), %eax
movl %eax, 0xc8(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc0(%rsp), %rsi
callq 0x3430
movq (%rax), %rcx
movq %rcx, 0xb4(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xbc(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x6080
movq %rax, 0x98(%rsp)
movslq 0xc0(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x6e80
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6040
movq 0x20(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0xc830
movq %rax, 0x90(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x6080
movq %rax, 0x78(%rsp)
movslq 0xc4(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x6e80
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6040
movq 0x28(%rsp), %rdi
movq 0x88(%rsp), %rsi
callq 0xc830
movq %rax, 0x70(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x6080
movq %rax, 0x58(%rsp)
movslq 0xc8(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x6e80
movq %rax, 0x60(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x6040
movq 0x30(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0xb4(%rsp), %rdx
callq 0xc8a0
movq %rax, 0x50(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x3c(%rsp), %eax
xorl (%rcx), %eax
movl %eax, 0x4c(%rsp)
movl 0xc8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0xcc(%rsp), %eax
jge 0xb593
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x1c(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xb4ca
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x18(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x18(%rsp), %eax
cmpl (%rcx), %eax
jne 0xb4ee
movl 0x4c(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl 0x14(%rsp), %ecx
xorl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x10(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x10(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xb55f
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0xc(%rsp), %eax
cmpl (%rcx), %eax
jne 0xb581
movl 0x4c(%rsp), %eax
movl %eax, 0x8(%rsp)
movq 0xd8(%rsp), %rdi
movslq 0x48(%rsp), %rsi
callq 0x3430
movl 0x8(%rsp), %ecx
xorl (%rax), %ecx
movl %ecx, (%rax)
jmp 0xb583
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xb446
movb $0x1, 0xe7(%rsp)
jmp 0xb5d3
movl 0xc0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
jmp 0xb16b
jmp 0xb5b5
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0xb146
movb $0x0, 0xe7(%rsp)
movb 0xe7(%rsp), %al
andb $0x1, %al
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)