// File: xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/reduce.cpp
// Function: reduce2(std::vector<xpair, std::allocator<xpair>>&, int**)
bool reduce2(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].src != seq[i].dst) && (seq[j].dst != seq[i].dst))
				continue;
			for(int k = j + 1; k < s; k++)
			{
				if((table[k][j + 1] == 0) && (table[j][k-1] == 0))
					break;
				if(seq[k].src != seq[i].src)
					continue;
				else
				{
					if(seq[j].src == seq[i].dst)
					{
						if(seq[k].dst != seq[j].dst)
							continue;
					}
					if(seq[j].dst == seq[i].dst)
					{
						if(seq[k].dst != seq[j].src)
							continue;
					}
				}
				if((table[i][j - 1]) && table[k][j + 1])
					index = j - 1;//fixpoint = j;
				else if(table[j][i + 1] && table[k][j + 1] && exchange_set(seq, j - 1, i + 1, seq[k]))
					index = i; //fixpoint = i;
				else if(table[i][j - 1] && table[j][k - 1] && exchange_set(seq, j + 1, k - 1, seq[i]))
					index = k - 2; //fixpoint = k;
				else
					continue;
				xpair tmp1, tmp2;
				tmp1.dst = seq[k].dst;
				tmp2.dst = seq[i].dst;
				if(seq[j].src == seq[i].dst)
				{
					tmp1.src = seq[j].src;
					tmp2.src = seq[i].src;
				}
				else
				{
					tmp1.src = seq[i].src;
					tmp2.src = seq[j].src;
				}
				seq.erase(seq.begin() + k);
				seq.erase(seq.begin() + j);
				seq.erase(seq.begin() + i);
				seq.insert(seq.begin() + index, tmp1);
				seq.insert(seq.begin() + index + 1, tmp2);
				return true;
			}
		}
	}
	return false;
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1b8(%rsp)
movq %rsi, 0x1b0(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x3280
movl %eax, 0x1ac(%rsp)
movl $0x0, 0x1a4(%rsp)
movl 0x1a4(%rsp), %eax
cmpl 0x1ac(%rsp), %eax
jge 0xb0f4
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a0(%rsp)
movl 0x1a0(%rsp), %eax
cmpl 0x1ac(%rsp), %eax
jge 0xb0dc
movq 0x1b0(%rsp), %rax
movslq 0x1a4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xa822
movq 0x1b0(%rsp), %rax
movslq 0x1a0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xa822
jmp 0xb0dc
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x64(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x64(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xa8a0
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x60(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x60(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xa8a0
jmp 0xb0c6
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
movl 0x19c(%rsp), %eax
cmpl 0x1ac(%rsp), %eax
jge 0xb0c4
movq 0x1b0(%rsp), %rax
movslq 0x19c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a0(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xa918
movq 0x1b0(%rsp), %rax
movslq 0x1a0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x19c(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0xa918
jmp 0xb0c4
movq 0x1b8(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x5c(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x5c(%rsp), %eax
cmpl (%rcx), %eax
je 0xa958
jmp 0xb0ae
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x58(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x58(%rsp), %eax
cmpl 0x4(%rcx), %eax
jne 0xa9d8
movq 0x1b8(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x54(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x54(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0xa9d6
jmp 0xb0ae
jmp 0xa9d8
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x50(%rsp), %eax
cmpl 0x4(%rcx), %eax
jne 0xaa58
movq 0x1b8(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x4c(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x4c(%rsp), %eax
cmpl (%rcx), %eax
je 0xaa56
jmp 0xb0ae
jmp 0xaa58
jmp 0xaa5a
movq 0x1b0(%rsp), %rax
movslq 0x1a4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xaabe
movq 0x1b0(%rsp), %rax
movslq 0x19c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a0(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xaabe
movl 0x1a0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x1a8(%rsp)
jmp 0xad71
movq 0x1b0(%rsp), %rax
movslq 0x1a0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a4(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movb $0x0, 0x17f(%rsp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x4b(%rsp)
je 0xabd5
movq 0x1b0(%rsp), %rax
movslq 0x19c(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdx
xorl %eax, %eax
cmpl $0x0, (%rcx,%rdx,4)
movb %al, 0x4b(%rsp)
je 0xabd5
movq 0x1b8(%rsp), %rsi
leaq 0x180(%rsp), %rdi
callq 0x3120
movb $0x1, 0x17f(%rsp)
movl 0x1a0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x40(%rsp)
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0x3430
movl 0x40(%rsp), %esi
movl 0x44(%rsp), %edx
movq (%rax), %rcx
movq %rcx, 0x170(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x178(%rsp)
movq 0x170(%rsp), %rax
movq %rax, 0x160(%rsp)
movl 0x178(%rsp), %eax
movl %eax, 0x168(%rsp)
movq 0x160(%rsp), %rcx
leaq 0x180(%rsp), %rdi
movzbl 0x168(%rsp), %r8d
callq 0x9390
movb %al, 0x4b(%rsp)
movb 0x4b(%rsp), %al
movb %al, 0x3f(%rsp)
testb $0x1, 0x17f(%rsp)
jne 0xabe9
jmp 0xabf6
leaq 0x180(%rsp), %rdi
callq 0x3220
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0xac00
jmp 0xac13
movl 0x1a4(%rsp), %eax
movl %eax, 0x1a8(%rsp)
jmp 0xad6f
movq 0x1b0(%rsp), %rax
movslq 0x1a4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x1a0(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %ecx
movb $0x0, 0x147(%rsp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x3e(%rsp)
je 0xad2a
movq 0x1b0(%rsp), %rax
movslq 0x1a0(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movl 0x19c(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rdx
xorl %eax, %eax
cmpl $0x0, (%rcx,%rdx,4)
movb %al, 0x3e(%rsp)
je 0xad2a
movq 0x1b8(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x3120
movb $0x1, 0x147(%rsp)
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
movl 0x19c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x38(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %edx
movq (%rax), %rcx
movq %rcx, 0x138(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x140(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x128(%rsp)
movl 0x140(%rsp), %eax
movl %eax, 0x130(%rsp)
movq 0x128(%rsp), %rcx
leaq 0x148(%rsp), %rdi
movzbl 0x130(%rsp), %r8d
callq 0x9390
movb %al, 0x3e(%rsp)
movb 0x3e(%rsp), %al
movb %al, 0x33(%rsp)
testb $0x1, 0x147(%rsp)
jne 0xad3e
jmp 0xad4b
leaq 0x148(%rsp), %rdi
callq 0x3220
movb 0x33(%rsp), %al
testb $0x1, %al
jne 0xad55
jmp 0xad68
movl 0x19c(%rsp), %eax
subl $0x2, %eax
movl %eax, 0x1a8(%rsp)
jmp 0xad6d
jmp 0xb0ae
jmp 0xad6f
jmp 0xad71
movq 0x1b8(%rsp), %rdi
movslq 0x19c(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x120(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movl 0x4(%rax), %eax
movl %eax, 0x114(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl 0x4(%rcx), %eax
jne 0xae29
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x11c(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x110(%rsp)
jmp 0xae65
movq 0x1b8(%rsp), %rdi
movslq 0x1a4(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x11c(%rsp)
movq 0x1b8(%rsp), %rdi
movslq 0x1a0(%rsp), %rsi
callq 0x3430
movl (%rax), %eax
movl %eax, 0x110(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, (%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x6080
movq %rax, 0xf8(%rsp)
movslq 0x19c(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0x6e80
movq %rax, 0x100(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x6040
movq (%rsp), %rdi
movq 0x108(%rsp), %rsi
callq 0xc830
movq %rax, 0xf0(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x6080
movq %rax, 0xd8(%rsp)
movslq 0x1a0(%rsp), %rsi
leaq 0xd8(%rsp), %rdi
callq 0x6e80
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x6040
movq 0x8(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0xc830
movq %rax, 0xd0(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x6080
movq %rax, 0xb8(%rsp)
movslq 0x1a4(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x6e80
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x6040
movq 0x10(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0xc830
movq %rax, 0xb0(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x6080
movq %rax, 0x98(%rsp)
movslq 0x1a8(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x6e80
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6040
movq 0x18(%rsp), %rdi
movq 0xa8(%rsp), %rsi
leaq 0x11c(%rsp), %rdx
callq 0xc8a0
movq %rax, 0x90(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x1b8(%rsp), %rdi
callq 0x6080
movq %rax, 0x70(%rsp)
movslq 0x1a8(%rsp), %rsi
leaq 0x70(%rsp), %rdi
callq 0x6e80
movq %rax, 0x78(%rsp)
leaq 0x78(%rsp), %rdi
movl $0x1, %esi
callq 0x6e80
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6040
movq 0x20(%rsp), %rdi
movq 0x88(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq 0xc8a0
movq %rax, 0x68(%rsp)
movb $0x1, 0x1c7(%rsp)
jmp 0xb0fc
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0xa8b1
jmp 0xb0c6
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a0(%rsp)
jmp 0xa7bb
jmp 0xb0de
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0xa796
movb $0x0, 0x1c7(%rsp)
movb 0x1c7(%rsp), %al
andb $0x1, %al
addq $0x1c8, %rsp            # imm = 0x1C8
retq
nopl (%rax)