// File: /workspace/github_cpp_makefile_star2_O2/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/strategy.cpp
// Function: select_oper(std::vector<std::bitset<32ul>, std::allocator<std::bitset<32ul>>>, std::vector<xpair, std::allocator<xpair>>&, int, int)
int select_oper(vector<ROW> m, vector<xpair> &max_seq, int no_reduced, int opr_type)
{
	int no_before = 0;
	int no_after = 0;
	xpair new_ele;

	for (int i = 0; i < m.size(); i++)
	{
		vector<ROW> tmp_m(m);
		for (int j = 0; j < m.size(); j++)
		{
			if (i != j)
			{
				no_before = tmp_m[j].count();
				tmp_m[j] ^= tmp_m[i];
				no_after = tmp_m[j].count();
				if((no_before - no_after) > 0)
				{
					if (no_reduced < (no_before - no_after))
					{
						no_reduced = no_before - no_after;
						max_seq.clear();
						new_ele.src = i;
						new_ele.dst = j;
						if(opr_type == 0)
						{
							new_ele.flag = false;
						}
						else if(opr_type == 1)
						{
							new_ele.flag = true;
						}
						max_seq.push_back(new_ele);
					}

					else if (no_reduced == (no_before - no_after))
					{
						new_ele.src = i;
						new_ele.dst = j;
						if(opr_type == 0)
						{
							new_ele.flag = false;
						}
						else if(opr_type == 1)
						{
							new_ele.flag = true;
						}
						max_seq.push_back(new_ele);
					}
				}
			}
		}
	}
    return no_reduced;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
leaq 0x10(%rsp), %r13
movl %ecx, (%rsp)
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
cmpq %r12, %rax
jbe 0x3926
movq %r13, %rdi
movq %r15, %rsi
callq 0x29e4
xorl %r13d, %r13d
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
cmpq %r13, %rax
jbe 0x3911
cmpq %r13, %r12
je 0x38d9
movq 0x10(%rsp), %rax
movq (%rax,%r13,8), %rcx
movq (%rax,%r12,8), %rdx
xorq %rcx, %rdx
movq %rdx, (%rax,%r13,8)
movq %rcx, %xmm0
movq %rdx, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, %xmm1
psrlw $0x1, %xmm1
pand 0x287d(%rip), %xmm1     # 0x60c0
psubb %xmm1, %xmm0
movdqa %xmm0, %xmm1
movdqa 0x287d(%rip), %xmm2     # 0x60d0
pand %xmm2, %xmm1
psrlw $0x2, %xmm0
pand %xmm2, %xmm0
paddb %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrlw $0x4, %xmm1
paddb %xmm0, %xmm1
pand 0x2867(%rip), %xmm1     # 0x60e0
psadbw 0x282f(%rip), %xmm1     # 0x60b0
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
psubd %xmm0, %xmm1
movd %xmm1, %ebp
testl %ebp, %ebp
jle 0x38d9
cmpl %ebp, %ebx
jge 0x38bd
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x38a3
movq %rax, 0x8(%r14)
movl %r12d, 0x4(%rsp)
movl %r13d, 0x8(%rsp)
movl (%rsp), %eax
testl %eax, %eax
je 0x38e5
cmpl $0x1, %eax
jne 0x38eb
movb $0x1, %al
jmp 0x38e7
jne 0x38d9
movl %r12d, 0x4(%rsp)
movl %r13d, 0x8(%rsp)
movl (%rsp), %eax
testl %eax, %eax
je 0x38fa
cmpl $0x1, %eax
jne 0x3900
movb $0x1, %al
jmp 0x38fc
movl %ebx, %ebp
incq %r13
movl %ebp, %ebx
jmp 0x37f3
xorl %eax, %eax
movb %al, 0xc(%rsp)
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0x394c
jmp 0x38db
xorl %eax, %eax
movb %al, 0xc(%rsp)
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0x394c
movl %ebx, %ebp
jmp 0x38db
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x2bbe
incq %r12
jmp 0x37d1
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2bbe
movq %rbx, %rdi
callq 0x2270