// File: xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/strategy.cpp
// Function: strgy1(std::vector<std::bitset<32ul>, std::allocator<std::bitset<32ul>>>&)
vector<xpair> strgy1(vector<ROW> &m)
{
	/* compatible with non-square matrix.*/
	vector<xpair> seq;
	int row_size = m.size();
	int col_size = m[0].size();

	int *mark = new int[row_size];
	memset(mark, 0, row_size * sizeof(int));
	xpair p;
	for (unsigned col = 1; col <= col_size; ++col) 
	{
		unsigned r = 0;
		while (((r < row_size) && (!m[r][col_size - col])) || (mark[r] == 1))
		{
			++r;
		}
		if (r >= row_size)
		{
			continue;
		}
		else
		{
			mark[r] = 1;
		}

		for (unsigned i = 0; i < row_size; ++i)
		{
			if (m[i][col_size - col] && (i != r)) 
			{
				m[i] ^= m[r];
				p.dst = i;
				p.src = r;
				p.flag = false;
				seq.push_back(p);
			}
		}
	}
	delete[] mark;
	return seq;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movb $0x0, 0x97(%rsp)
callq 0x5d30
movq 0x98(%rsp), %rdi
callq 0x32a0
movl %eax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x33d0
movq %rax, %rdi
callq 0x5d40
movl %eax, 0x8c(%rsp)
movslq 0x90(%rsp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x2030
movq %rax, 0x30(%rsp)
jmp 0x466f
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
movslq 0x90(%rsp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20b0
movl $0x1, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x8c(%rsp), %eax
ja 0x48bb
movl $0x0, 0x60(%rsp)
movl 0x60(%rsp), %eax
movl 0x90(%rsp), %ecx
movb $0x0, 0x4f(%rsp)
cmpl %ecx, %eax
jae 0x471b
movq 0x98(%rsp), %rdi
movl 0x60(%rsp), %eax
movl %eax, %esi
callq 0x33d0
movq %rax, %rsi
movl 0x8c(%rsp), %eax
movl 0x64(%rsp), %ecx
subl %ecx, %eax
movl %eax, %edx
leaq 0x50(%rsp), %rdi
callq 0x5d50
jmp 0x46fd
movb $0x1, 0x4f(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x5d90
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, 0x1f(%rsp)
jne 0x471b
jmp 0x4732
movq 0x80(%rsp), %rax
movl 0x60(%rsp), %ecx
cmpl $0x1, (%rax,%rcx,4)
sete %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
movb %al, 0x1e(%rsp)
testb $0x1, 0x4f(%rsp)
jne 0x4743
jmp 0x474d
leaq 0x50(%rsp), %rdi
callq 0x5dd0
movb 0x1e(%rsp), %al
testb $0x1, %al
jne 0x4757
jmp 0x4784
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x46b8
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
callq 0x3220
jmp 0x4901
movl 0x60(%rsp), %eax
cmpl 0x90(%rsp), %eax
jb 0x4796
jmp 0x48ab
movq 0x80(%rsp), %rax
movl 0x60(%rsp), %ecx
movl $0x1, (%rax,%rcx,4)
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x90(%rsp), %eax
jae 0x48a9
movq 0x98(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x33d0
movq %rax, %rsi
movl 0x8c(%rsp), %eax
movl 0x64(%rsp), %ecx
subl %ecx, %eax
movl %eax, %edx
leaq 0x38(%rsp), %rdi
callq 0x5d50
jmp 0x47f3
leaq 0x38(%rsp), %rdi
callq 0x5d90
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1d(%rsp)
jne 0x480c
jmp 0x481b
movl 0x48(%rsp), %eax
cmpl 0x60(%rsp), %eax
setne %al
movb %al, 0x1d(%rsp)
movb 0x1d(%rsp), %al
movb %al, 0x1c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x5dd0
movb 0x1c(%rsp), %al
testb $0x1, %al
jne 0x4837
jmp 0x4897
movq 0x98(%rsp), %rdi
movl 0x60(%rsp), %eax
movl %eax, %esi
callq 0x33d0
movq %rax, 0x10(%rsp)
movq 0x98(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x33d0
movq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x3450
movq 0x20(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x68(%rsp)
movb $0x0, 0x70(%rsp)
leaq 0x68(%rsp), %rsi
callq 0x5de0
jmp 0x4895
jmp 0x4897
jmp 0x4899
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x47b1
jmp 0x48ab
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x469f
movq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x48d8
movq 0x8(%rsp), %rdi
callq 0x21b0
movb $0x1, 0x97(%rsp)
testb $0x1, 0x97(%rsp)
jne 0x48f4
movq 0x20(%rsp), %rdi
callq 0x3220
movq 0x28(%rsp), %rax
addq $0xa8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x22a0
nopl (%rax,%rax)