// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r13
movq 0x8(%rdi), %rax
subq (%rdi), %rax
pushq $0xc
popq %rcx
cqto
idivq %rcx
movslq %eax, %r9
xorl %r10d, %r10d
testl %r9d, %r9d
movl $0x0, %eax
cmovgl %r9d, %eax
pushq $0x2
popq %rcx
movl %ecx, (%rsp)
pushq $0x1
popq %rcx
movq %rdi, 0x18(%rsp)
movq %r9, 0x28(%rsp)
movq %rsi, 0x38(%rsp)
movq %rax, 0x58(%rsp)
cmpq %rax, %r10
je 0x4e9c
movslq %ecx, %rbp
leaq 0x1(%r10), %rax
movq %rax, 0x10(%rsp)
imulq $0xc, %r10, %r14
movq %rcx, 0x60(%rsp)
movq %rcx, 0x40(%rsp)
movl (%rsp), %edi
movq %r10, 0x20(%rsp)
cmpq %r9, %rbp
jge 0x4db7
movq (%rsi,%r10,8), %rax
cmpl $0x0, -0x4(%rax,%rbp,4)
jne 0x4bac
movq (%rsi,%rbp,8), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x4db7
movq (%r13), %rax
imulq $0xc, %rbp, %rdx
movl 0x4(%rax,%r14), %ecx
cmpl %ecx, (%rax,%rdx)
je 0x4bca
addq %rdx, %rax
cmpl %ecx, 0x4(%rax)
jne 0x4d9e
movq %rdx, 0x48(%rsp)
movl %edi, 0x4(%rsp)
movslq %edi, %rbx
imulq $0xc, %rbx, %r15
leaq -0x4(,%rbx,4), %rax
movq %rax, 0x50(%rsp)
leaq (%rsi,%rbx,8), %rax
movq %rax, 0x68(%rsp)
leaq -0x1(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq 0x1(%rbp), %rax
movq %rax, 0x30(%rsp)
xorl %r12d, %r12d
leaq (%rbx,%r12), %rax
cmpq %r9, %rax
jge 0x4d98
movq 0x68(%rsp), %rax
movq (%rax,%r12,8), %rax
movl 0x4(%rax,%rbp,4), %eax
testl %eax, %eax
jne 0x4c37
movq (%rsi,%rbp,8), %rcx
addq 0x50(%rsp), %rcx
cmpl $0x0, (%rcx,%r12,4)
je 0x4d98
movq (%r13), %rcx
movl (%rcx,%r15), %edx
cmpl (%rcx,%r14), %edx
jne 0x4d0d
leaq (%rcx,%r14), %rdi
movq 0x48(%rsp), %rdx
leaq (%rcx,%rdx), %r8
movl (%rcx,%rdx), %edx
movl 0x4(%rdi), %r11d
cmpl %r11d, %edx
jne 0x4c72
movl 0x4(%rcx,%r15), %edi
cmpl 0x4(%r8), %edi
je 0x4c76
jmp 0x4d0d
movl 0x4(%r8), %edi
cmpl %r11d, %edi
jne 0x4c86
cmpl %edx, 0x4(%rcx,%r15)
jne 0x4d0d
movq (%rsi,%r10,8), %rcx
cmpl $0x0, -0x4(%rcx,%rbp,4)
je 0x4d19
testl %eax, %eax
jne 0x4def
movq (%rsi,%rbp,8), %rax
addq 0x50(%rsp), %rax
cmpl $0x0, (%rax,%r12,4)
je 0x4d0d
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x2a34
movq (%r13), %rax
movq (%rax,%r14), %rcx
movq 0x40(%rsp), %rax
leal (%rax,%r12), %edx
leaq 0x88(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x4353
movl %eax, %r13d
leaq 0x88(%rsp), %rdi
callq 0x2c54
movq 0x38(%rsp), %rsi
movq 0x20(%rsp), %r10
movq 0x28(%rsp), %r9
testb %r13b, %r13b
movq 0x18(%rsp), %r13
jne 0x4dd1
addq $0xc, %r15
incq %r12
jmp 0x4c05
testl %eax, %eax
je 0x4d0d
movq (%rsi,%rbp,8), %rax
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x4d0d
leaq 0xa0(%rsp), %rdi
movq %r13, %rsi
callq 0x2a34
movq (%r13), %rax
movq (%rax,%r15), %rcx
leaq 0xa0(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x4353
movl %eax, %r13d
leaq 0xa0(%rsp), %rdi
callq 0x2c54
testb %r13b, %r13b
jne 0x4de0
movq 0x20(%rsp), %r10
movq 0x38(%rsp), %rsi
movq (%rsi,%r10,8), %rax
cmpl $0x0, -0x4(%rax,%rbp,4)
movq 0x18(%rsp), %r13
movq 0x28(%rsp), %r9
jne 0x4c9d
jmp 0x4d0d
movl 0x4(%rsp), %edi
jmp 0x4da6
incq %rbp
movq %rbp, 0x30(%rsp)
incl %edi
incq 0x40(%rsp)
movq 0x30(%rsp), %rbp
jmp 0x4b85
incl (%rsp)
movq 0x60(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %r10
movq 0x58(%rsp), %rax
jmp 0x4b5a
leaq (%rbx,%r12), %rax
addq $-0x2, %rax
movq %rax, 0x8(%rsp)
jmp 0x4def
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %r13
movq (%r13), %rdx
leaq (%rdx,%r15), %rsi
movl 0x4(%rdx,%r15), %eax
movl %eax, 0x80(%rsp)
leaq (%rdx,%r14), %rax
movl 0x4(%rdx,%r14), %ecx
movl %ecx, 0x74(%rsp)
movq 0x48(%rsp), %rbx
cmpl %ecx, (%rdx,%rbx)
je 0x4e22
addq %rbx, %rdx
movl (%rax), %ecx
movq %rdx, %rax
leaq 0x7c(%rsp), %r13
movl %ecx, (%r13)
movl (%rax), %eax
leaq 0x70(%rsp), %r15
movl %eax, (%r15)
movq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x5760
addq (%r12), %rbx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x5760
addq (%r12), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x5760
movslq 0x8(%rsp), %rax
imulq $0xc, %rax, %rbx
movq (%r12), %rsi
addq %rbx, %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x579a
movq (%r12), %rax
leaq (%rax,%rbx), %rsi
addq $0xc, %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0x579a
movq 0x28(%rsp), %r9
movq 0x20(%rsp), %r10
cmpq %r9, %r10
setl %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq