// File: /workspace/github_cpp_makefile_star2_O2/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/reduce.cpp
// Function: reduce0(std::vector<xpair, std::allocator<xpair>>&, int**)
bool reduce0(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[i].src != seq[j].src)
				continue;
			for(int k = j + 1; k < s; k++)
			{
				if((table[k][j + 1] == 0) && (table[j][k-1] == 0))
					break;
				if(seq[k].dst != seq[i].dst)
				{
					if (seq[k].dst != seq[j].dst)
						continue;
					else
					{
						if(seq[k].src != seq[i].dst)
							continue;
					}
				}
				else
				{
					if(seq[k].src != seq[j].dst)
						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 = seq[k];
				tmp2.src = seq[i].src;
				tmp2.dst = seq[k].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, %rbp
movq 0x8(%rdi), %rax
subq (%rdi), %rax
pushq $0xc
popq %rcx
cqto
idivq %rcx
movslq %eax, %rdi
xorl %r8d, %r8d
testl %edi, %edi
movl $0x0, %eax
cmovgl %edi, %eax
pushq $0x2
popq %rcx
movl %ecx, (%rsp)
pushq $0x1
popq %rcx
movq %rbp, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movq %rsi, 0x40(%rsp)
movq %rax, 0x58(%rsp)
cmpq %rax, %r8
je 0x4749
movslq %ecx, %r13
leaq 0x1(%r8), %rax
movq %rax, 0x8(%rsp)
imulq $0xc, %r8, %r10
movq %rcx, 0x60(%rsp)
movq %rcx, 0x48(%rsp)
movl (%rsp), %eax
movl %eax, 0x4(%rsp)
movq %r8, 0x10(%rsp)
movq %r10, 0x18(%rsp)
cmpq %rdi, %r13
jge 0x4674
movq (%rsi,%r8,8), %rax
cmpl $0x0, -0x4(%rax,%r13,4)
jne 0x4491
movq (%rsi,%r13,8), %rax
movq 0x8(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x4674
movq (%rbp), %rax
movl (%rax,%r10), %ecx
imulq $0xc, %r13, %r11
leaq 0x1(%r13), %r15
cmpl (%rax,%r11), %ecx
jne 0x4663
movslq 0x4(%rsp), %r14
imulq $0xc, %r14, %rbx
leaq -0x4(,%r14,4), %rax
movq %rax, 0x50(%rsp)
leaq (%rsi,%r14,8), %rax
movq %rax, 0x68(%rsp)
leaq -0x1(%r13), %rax
movq %rax, 0x38(%rsp)
xorl %r12d, %r12d
movq %r11, 0x30(%rsp)
leaq (%r14,%r12), %rax
cmpq %rdi, %rax
jge 0x4663
movq 0x68(%rsp), %rax
movq (%rax,%r12,8), %rax
movl (%rax,%r15,4), %eax
testl %eax, %eax
jne 0x450d
movq (%rsi,%r13,8), %rcx
addq 0x50(%rsp), %rcx
cmpl $0x0, (%rcx,%r12,4)
je 0x4663
movq (%rbp), %rcx
movl 0x4(%rcx,%rbx), %r9d
movl 0x4(%rcx,%r10), %edx
cmpl %edx, %r9d
jne 0x452f
movl (%rcx,%rbx), %edx
cmpl 0x4(%rcx,%r11), %edx
je 0x4543
jmp 0x45ce
cmpl 0x4(%rcx,%r11), %r9d
jne 0x45ce
cmpl %edx, (%rcx,%rbx)
jne 0x45ce
movq (%rsi,%r8,8), %rcx
cmpl $0x0, -0x4(%rcx,%r13,4)
je 0x45da
testl %eax, %eax
jne 0x468e
movq (%rsi,%r13,8), %rax
addq 0x50(%rsp), %rax
cmpl $0x0, (%rax,%r12,4)
je 0x45ce
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x2a34
movq (%rbp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx), %rcx
movq 0x48(%rsp), %rax
leal (%rax,%r12), %edx
leaq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x4353
movl %eax, %ebp
leaq 0x70(%rsp), %rdi
callq 0x2c54
movq 0x30(%rsp), %r11
movq 0x18(%rsp), %r10
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x28(%rsp), %rdi
testb %bpl, %bpl
movq 0x20(%rsp), %rbp
jne 0x4695
addq $0xc, %rbx
incq %r12
jmp 0x44db
testl %eax, %eax
je 0x45ce
movq (%rsi,%r13,8), %rax
movq 0x8(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x45ce
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0x2a34
movq (%rbp), %rax
movq (%rax,%rbx), %rcx
leaq 0x88(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x4353
movl %eax, %ebp
leaq 0x88(%rsp), %rdi
callq 0x2c54
testb %bpl, %bpl
jne 0x469f
movq 0x10(%rsp), %r8
movq 0x40(%rsp), %rsi
movq (%rsi,%r8,8), %rax
cmpl $0x0, -0x4(%rax,%r13,4)
movq 0x20(%rsp), %rbp
movq 0x28(%rsp), %rdi
movq 0x18(%rsp), %r10
movq 0x30(%rsp), %r11
jne 0x455b
jmp 0x45ce
incl 0x4(%rsp)
incq 0x48(%rsp)
movq %r15, %r13
jmp 0x4469
incl (%rsp)
movq 0x60(%rsp), %rcx
incq %rcx
movq 0x8(%rsp), %r8
movq 0x58(%rsp), %rax
jmp 0x4435
movq 0x38(%rsp), %r15
jmp 0x46ae
leaq (%r14,%r12), %r15
addq $-0x2, %r15
jmp 0x46ae
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r10
movq (%rbp), %rax
leaq (%rax,%rbx), %rsi
movl 0x8(%rax,%rbx), %ecx
leaq 0xa0(%rsp), %r13
movl %ecx, 0x8(%r13)
movq (%rax,%rbx), %rcx
movq %rcx, (%r13)
movl (%rax,%r10), %ecx
leaq 0xac(%rsp), %r14
movl %ecx, (%r14)
movl (%rax,%rbx), %eax
movl %eax, 0x4(%r14)
movq %rbp, %rdi
movq %r10, %rbx
callq 0x5760
movq 0x30(%rsp), %rsi
addq (%rbp), %rsi
movq %rbp, %rdi
callq 0x5760
addq (%rbp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x5760
movslq %r15d, %rax
imulq $0xc, %rax, %rbx
movq (%rbp), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x579a
movq (%rbp), %rax
leaq (%rax,%rbx), %rsi
addq $0xc, %rsi
movq %rbp, %rdi
movq %r14, %rdx
callq 0x579a
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %r8
cmpq %rdi, %r8
setl %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq