// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movl %edx, %ebx
movq 0x8(%rdi), %rax
cmpq (%rdi), %rax
je 0x46e0
movq %rsi, %r14
movq %rdi, %r15
movl %ecx, 0x14(%rsp)
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2ea0
movq 0x8(%r15), %rax
cmpq (%r15), %rax
je 0x46b2
xorl %r12d, %r12d
movl %ebx, %ebp
cmpq %r12, %r13
je 0x463b
movq 0x20(%rsp), %rax
movq (%rax,%r12,8), %rcx
movq (%rax,%r13,8), %rdx
xorq %rcx, %rdx
movq %rdx, (%rax,%r12,8)
movq %rcx, %xmm0
movq %rdx, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, %xmm1
psrlw $0x1, %xmm1
pand 0x2bc7(%rip), %xmm1     # 0x7160
psubb %xmm1, %xmm0
movdqa %xmm0, %xmm1
movdqa 0x2bc7(%rip), %xmm2     # 0x7170
pand %xmm2, %xmm1
psrlw $0x2, %xmm0
pand %xmm2, %xmm0
paddb %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrlw $0x4, %xmm1
paddb %xmm0, %xmm1
pand 0x2bb1(%rip), %xmm1     # 0x7180
psadbw 0x2b79(%rip), %xmm1     # 0x7150
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
psubd %xmm0, %xmm1
movd %xmm1, %ebx
testl %ebx, %ebx
jle 0x463b
cmpl %ebx, %ebp
jge 0x461b
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x45fd
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
movl %r13d, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movl 0x14(%rsp), %eax
cmpl $0x1, %eax
je 0x4658
testl %eax, %eax
jne 0x465d
movb $0x0, 0x10(%rsp)
jmp 0x465d
jne 0x463b
movl %r13d, 0x8(%rsp)
movl %r12d, 0xc(%rsp)
movl 0x14(%rsp), %eax
cmpl $0x1, %eax
je 0x4676
testl %eax, %eax
jne 0x467b
movb $0x0, 0x10(%rsp)
jmp 0x467b
movl %ebp, %ebx
movq 0x8(%r15), %rax
subq (%r15), %rax
incq %r12
sarq $0x3, %rax
movl %ebx, %ebp
cmpq %r12, %rax
ja 0x455d
jmp 0x46b2
movb $0x1, 0x10(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
jne 0x4687
movq %r14, %rdi
leaq 0x8(%rsp), %rdx
callq 0x4776
jmp 0x463d
movb $0x1, 0x10(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x46a1
movl %ebp, %ebx
movl 0x10(%rsp), %eax
movl %eax, 0x8(%rsi)
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
movq 0x18(%rsp), %rax
addq $0xc, (%rax)
jmp 0x463d
movq %r14, %rdi
leaq 0x8(%rsp), %rdx
callq 0x4776
movl %ebp, %ebx
jmp 0x463d
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x46c9
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
incq %r13
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
cmpq %r13, %rax
ja 0x453e
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x470b
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2270
nop