// File: /workspace/github_cpp_makefile_star2_O2/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/strategy.cpp
// Function: strgy3(std::vector<std::bitset<32ul>, std::allocator<std::bitset<32ul>>>&)
vector<xpair> strgy3(vector<ROW> &m)
{
	vector<xpair> tmp_seq;
	while(get_ones(m) != m.size())
	{
		vector<xpair> base_oper;
		base_oper.clear();
		int value = 0;

		int Reduced_Row = select_oper(m, base_oper, value, 0);

		vector<ROW> trans_m;
		get_trans_matrix(trans_m,m);

		int Reduced_Col = select_oper(trans_m, base_oper, Reduced_Row, 1);
		if (base_oper.size() >= 1)
			{
				int rand_num = rand_generator() % base_oper.size();
			
				if (!base_oper[rand_num].flag)
				{
					m[base_oper[rand_num].dst] ^= m[base_oper[rand_num].src];
					tmp_seq.push_back(base_oper[rand_num]);
				}
	
				else if (base_oper[rand_num].flag)
				{   
					vector<ROW> trans_tmp_m;
					get_trans_matrix(trans_tmp_m, m);
					trans_tmp_m[base_oper[rand_num].dst] ^= trans_tmp_m[base_oper[rand_num].src];
					get_trans_matrix(m, trans_tmp_m);
					tmp_seq.push_back(base_oper[rand_num]);
				}
			}
			else 
			{
				break;
			}
	}
    
	if (get_ones(m) != m.size())
	{ 
	    // int rnd = rand()%2;
		int rnd = rand_generator() % 2;
		if(rnd == 0)
		{
			vector<xpair> seq_2(strgy1(m));
			tmp_seq.insert(tmp_seq.end(), seq_2.begin(), seq_2.end());
		}
		else if(rnd == 1)
		{
			vector<xpair> seq_2(strgy2(m));
			tmp_seq.insert(tmp_seq.end(), seq_2.begin(), seq_2.end());
		}
	}
	
	int tab[SIZE] = {0};
	build_table(m, tab);
	vector<xpair> final_seq = update_seq_str(tmp_seq, tab);
	return final_seq;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rsi, 0x8(%rsp)
movq %rdi, 0xe8(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x198(%rsp), %r15
leaq 0x150(%rsp), %r12
leaq 0x138(%rsp), %r14
movq %r15, %rbx
leaq 0x1b0(%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rbp
movq %rbp, %rsi
callq 0x29e4
movq %r15, %rdi
callq 0x3732
movslq %eax, %r13
movq %r15, %rdi
movq 0x8(%rbp), %r15
subq (%rbp), %r15
sarq $0x3, %r15
callq 0x2bbe
cmpq %r13, %r15
je 0x350d
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq %rbx, %r15
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x29e4
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x37b0
movl %eax, %r13d
movq %r15, %rdi
callq 0x2bbe
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
leaq 0x180(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x29e4
leaq 0xd0(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x305c
movq %rbx, %rdi
callq 0x2bbe
leaq 0x168(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x29e4
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movl %r13d, %edx
pushq $0x1
popq %rcx
callq 0x37b0
movq %rbx, %rdi
callq 0x2bbe
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x34f1
leaq 0x5da3(%rip), %rdi      # 0x9178
callq 0x3970
movq %rax, %rcx
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0xc
popq %rdi
idivq %rdi
movq %rax, %rdi
movq %rcx, %rax
xorl %edx, %edx
divq %rdi
movslq %edx, %rax
imulq $0xc, %rax, %r13
cmpb $0x0, 0x8(%rsi,%r13)
je 0x34b1
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
andq $0x0, 0xc0(%rsp)
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x29e4
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rbx
movq %r12, %rsi
callq 0x305c
movq %rbx, %rdi
callq 0x2bbe
movq 0x30(%rsp), %rax
movslq (%rax,%r13), %rcx
movq 0xb0(%rsp), %rdx
movslq 0x4(%rax,%r13), %rax
movq (%rdx,%rcx,8), %rcx
xorq %rcx, (%rdx,%rax,8)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x29e4
movq 0x8(%rsp), %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x305c
movq %rbx, %rdi
callq 0x2bbe
addq 0x30(%rsp), %r13
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x394c
leaq 0xb0(%rsp), %rdi
callq 0x2bbe
jmp 0x34d5
addq %r13, %rsi
movslq (%rsi), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x4(%rsi), %rdx
movq (%rcx,%rax,8), %rax
xorq %rax, (%rcx,%rdx,8)
leaq 0x10(%rsp), %rdi
callq 0x394c
leaq 0xd0(%rsp), %rdi
callq 0x2bbe
leaq 0x30(%rsp), %rdi
callq 0x2c54
jmp 0x32d1
leaq 0xd0(%rsp), %rdi
callq 0x2bbe
leaq 0x30(%rsp), %rdi
callq 0x2c54
movq 0x8(%rsp), %rbp
leaq 0x120(%rsp), %rdi
movq %rbp, %rsi
callq 0x29e4
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0x3732
movslq %eax, %r15
movq 0x8(%rbp), %r12
subq (%rbp), %r12
sarq $0x3, %r12
movq %rbx, %rdi
callq 0x2bbe
cmpq %r15, %r12
je 0x35af
leaq 0x5c28(%rip), %rdi      # 0x9178
callq 0x3970
testb $0x1, %al
jne 0x3580
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x2d64
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x39d4
jmp 0x35a5
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x2eae
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x39d4
leaq 0x30(%rsp), %rdi
callq 0x2c54
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
leaq 0x108(%rsp), %rdi
movq %rbp, %rsi
callq 0x29e4
movq 0xe8(%rsp), %rbx
leaq 0x108(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3135
leaq 0x108(%rsp), %rdi
callq 0x2bbe
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2a34
leaq 0xf0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x31b3
leaq 0xf0(%rsp), %rdi
callq 0x2c54
leaq 0x10(%rsp), %rdi
callq 0x2c54
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x36bf
jmp 0x36bf
jmp 0x36ef
jmp 0x36ef
jmp 0x36ef
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x371b
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x2bbe
jmp 0x3720
jmp 0x36ef
jmp 0x36ef
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x36b8
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x2bbe
jmp 0x36f7
movq %rax, %rbx
jmp 0x3716
jmp 0x3706
jmp 0x3706
movq %rax, %rbx
leaq 0x198(%rsp), %rdi
jmp 0x3711
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x36ff
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x36ff
movq %rax, %rbx
jmp 0x3720
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x2bbe
jmp 0x3709
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2bbe
leaq 0x30(%rsp), %rdi
callq 0x2c54
leaq 0x10(%rsp), %rdi
callq 0x2c54
movq %rbx, %rdi
callq 0x2270