// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1d8, %rsp            # imm = 0x1D8
movq %rsi, 0x8(%rsp)
movq %rdi, 0xf8(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movabsq $0x3333333333333333, %rbx # imm = 0x3333333333333333
movabsq $0xf0f0f0f0f0f0f0f, %r15 # imm = 0xF0F0F0F0F0F0F0F
movabsq $0x101010101010101, %r12 # imm = 0x101010101010101
leaq 0x1c0(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
movq 0x1c0(%rsp), %rdi
movq 0x1c8(%rsp), %rax
subq %rdi, %rax
movabsq $0x5555555555555555, %r9 # imm = 0x5555555555555555
je 0x3dec
sarq $0x3, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movq (%rdi,%rcx,8), %rsi
movq %rsi, %r8
shrq %r8
andq %r9, %r8
subq %r8, %rsi
movq %rsi, %r8
andq %rbx, %r8
shrq $0x2, %rsi
andq %rbx, %rsi
addq %r8, %rsi
movq %rsi, %r8
shrq $0x4, %r8
addq %rsi, %r8
andq %r15, %r8
imulq %r12, %r8
shrq $0x38, %r8
addl %r8d, %edx
incq %rcx
cmpq %rcx, %rax
jne 0x3da7
movslq %edx, %r14
jmp 0x3def
xorl %r14d, %r14d
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r13
subq (%rax), %r13
testq %rdi, %rdi
je 0x3e10
movq 0x1d0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
sarq $0x3, %r13
cmpq %r14, %r13
leaq 0x190(%rsp), %r14
je 0x40f4
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0x3e4a
movq $0x0, 0x78(%rsp)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
movq %r14, %rdi
leaq 0x70(%rsp), %r14
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x450b
movl %eax, %r13d
movq 0x190(%rsp), %rdi
testq %rdi, %rdi
je 0x3e8b
movq 0x1a0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x178(%rsp), %rbp
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x3a8c
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x3edb
movq 0x188(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x160(%rsp), %rbp
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
callq 0x2ea0
movq %rbp, %rdi
movq %r14, %rsi
movl %r13d, %edx
movl $0x1, %ecx
callq 0x450b
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0x3f20
movq 0x170(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x70(%rsp), %rbp
movq 0x78(%rsp), %r14
cmpq %rbp, %r14
je 0x40ba
leaq 0x6246(%rip), %rdi      # 0xa180
callq 0x4714
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rsi
subq %rcx, %rsi
sarq $0x2, %rsi
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rsi
xorl %edx, %edx
divq %rsi
movslq %edx, %rax
leaq (%rax,%rax,2), %r13
cmpb $0x0, 0x8(%rcx,%r13,4)
je 0x404f
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x148(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
leaq 0x30(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0x3a8c
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x3fc8
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x70(%rsp), %rax
movslq (%rax,%r13,4), %rcx
movq 0x30(%rsp), %rdx
movslq 0x4(%rax,%r13,4), %rax
movq (%rdx,%rcx,8), %rcx
xorq %rcx, (%rdx,%rax,8)
leaq 0x130(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x2ea0
movq 0x8(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x3a8c
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x4024
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
shlq $0x2, %r13
addq 0x70(%rsp), %r13
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x4096
movl 0x8(%r13), %eax
movl %eax, 0x8(%rsi)
movq (%r13), %rax
movq %rax, (%rsi)
addq $0xc, 0x18(%rsp)
jmp 0x40a3
leaq (%rcx,%r13,4), %rdx
movslq (%rdx), %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x4(%rdx), %rsi
movq (%rcx,%rax,8), %rax
xorq %rax, (%rcx,%rsi,8)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x408a
movl 0x8(%rdx), %eax
movl %eax, 0x8(%rsi)
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0xc, 0x18(%rsp)
jmp 0x40ba
leaq 0x10(%rsp), %rdi
callq 0x4776
jmp 0x40ba
leaq 0x10(%rsp), %rdi
movq %r13, %rdx
callq 0x4776
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x40ba
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x40d1
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x40eb
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
cmpq %rbp, %r14
jne 0x3d66
leaq 0x1a8(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
movq 0x1a8(%rsp), %rdi
movq 0x1b0(%rsp), %rax
xorl %r14d, %r14d
subq %rdi, %rax
je 0x4179
sarq $0x3, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %ecx, %ecx
movabsq $0x5555555555555555, %r8 # imm = 0x5555555555555555
movq (%rdi,%rcx,8), %rdx
movq %rdx, %rsi
shrq %rsi
andq %r8, %rsi
subq %rsi, %rdx
movq %rdx, %rsi
andq %rbx, %rsi
shrq $0x2, %rdx
andq %rbx, %rdx
addq %rsi, %rdx
movq %rdx, %rsi
shrq $0x4, %rsi
addq %rdx, %rsi
andq %r15, %rsi
imulq %r12, %rsi
shrq $0x38, %rsi
addl %esi, %r14d
incq %rcx
cmpq %rcx, %rax
jne 0x4136
movslq %r14d, %r14
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rbx
subq (%rax), %rbx
sarq $0x3, %rbx
testq %rdi, %rdi
je 0x419e
movq 0x1b8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
cmpq %r14, %rbx
movq 0xf8(%rsp), %rbx
je 0x4225
leaq 0x5fce(%rip), %rdi      # 0xa180
callq 0x4714
testb $0x1, %al
jne 0x41e4
leaq 0x70(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x3168
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0x49cc
jmp 0x420b
leaq 0x70(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x32ea
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x70(%rsp), %rdx
movq 0x78(%rsp), %rcx
callq 0x49cc
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x4225
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
leaq 0x118(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2ea0
leaq 0x118(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x3b58
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x42a6
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x100(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2f16
leaq 0x100(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x3bce
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x42ea
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4301
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x43cd
jmp 0x43cd
jmp 0x4460
jmp 0x4460
jmp 0x4460
movq %rax, %rbx
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x4463
movq 0x110(%rsp), %rsi
jmp 0x4456
movq %rax, %rbx
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x4463
movq 0x128(%rsp), %rsi
jmp 0x4456
jmp 0x4460
jmp 0x4460
movq %rax, %rbx
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x43bc
movq 0x140(%rsp), %rsi
jmp 0x43ad
movq %rax, %rbx
movq 0x148(%rsp), %rdi
testq %rdi, %rdi
je 0x43bc
movq 0x158(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x43bc
jmp 0x43d4
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x442d
movq 0x40(%rsp), %rsi
jmp 0x4425
movq %rax, %rbx
jmp 0x4444
jmp 0x43d4
movq %rax, %rbx
jmp 0x442d
movq %rax, %rbx
movq 0x190(%rsp), %rdi
testq %rdi, %rdi
je 0x4444
movq 0x1a0(%rsp), %rsi
jmp 0x443c
movq %rax, %rbx
movq 0x178(%rsp), %rdi
testq %rdi, %rdi
je 0x442d
movq 0x188(%rsp), %rsi
jmp 0x4425
movq %rax, %rbx
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0x442d
movq 0x170(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4444
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x4463
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
jmp 0x4463
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x447a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %rbx, %rdi
callq 0x2270