// File: /workspace/github_cpp_makefile_star2_O3/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 0x8(%rdi), %rax
cmpq (%rdi), %rax
je 0x4703
movq %rsi, %r14
movq %rdi, %r15
movl %ecx, 0xc(%rsp)
xorl %r12d, %r12d
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x2ea0
movq 0x8(%r15), %rax
cmpq (%r15), %rax
je 0x46cf
xorl %r13d, %r13d
movl %ebx, %ebp
cmpq %r13, %r12
je 0x465d
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 0x2b9f(%rip), %xmm1     # 0x7160
psubb %xmm1, %xmm0
movdqa %xmm0, %xmm1
movdqa 0x2b9f(%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 0x2b89(%rip), %xmm1     # 0x7180
psadbw 0x2b51(%rip), %xmm1     # 0x7150
pshufd $0xee, %xmm1, %xmm0     # xmm0 = xmm1[2,3,2,3]
psubd %xmm0, %xmm1
movd %xmm1, %ebx
testl %ebx, %ebx
jle 0x465d
cmpl %ebx, %ebp
jge 0x4641
movq (%r14), %rax
movq 0x8(%r14), %rsi
cmpq %rax, %rsi
je 0x4627
movq %rax, 0x8(%r14)
movq %rax, %rsi
movl %r12d, (%rsp)
movl %r13d, 0x4(%rsp)
movl 0xc(%rsp), %eax
testl %eax, %eax
je 0x4680
cmpl $0x1, %eax
jne 0x4686
movb $0x1, %al
jmp 0x4682
jne 0x465d
movl %r12d, (%rsp)
movl %r13d, 0x4(%rsp)
movl 0xc(%rsp), %eax
testl %eax, %eax
je 0x4699
cmpl $0x1, %eax
jne 0x469f
movb $0x1, %al
jmp 0x469b
movl %ebp, %ebx
incq %r13
movq (%r15), %rax
movq 0x8(%r15), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movl %ebx, %ebp
cmpq %r13, %rdx
ja 0x4585
jmp 0x46d2
xorl %eax, %eax
movb %al, 0x8(%rsp)
cmpq 0x10(%r14), %rsi
jne 0x46ab
movq %r14, %rdi
movq %rsp, %rdx
callq 0x479a
jmp 0x465f
xorl %eax, %eax
movb %al, 0x8(%rsp)
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x46c0
movl %ebp, %ebx
movl 0x8(%rsp), %eax
movl %eax, 0x8(%rsi)
movq (%rsp), %rax
movq %rax, (%rsi)
addq $0xc, 0x8(%r14)
jmp 0x465f
movq %r14, %rdi
movq %rsp, %rdx
callq 0x479a
movl %ebp, %ebx
jmp 0x465f
movq %rax, %rcx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x46f0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
incq %r12
sarq $0x3, %rcx
cmpq %r12, %rcx
ja 0x4566
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x472e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2270