// File: /workspace/github_cpp_makefile_star2_O2/xiangzejun[P]Optimizing_Implementations_of_Linear_Layers/main.cpp
// Function: print_seq(std::vector<std::bitset<32ul>, std::allocator<std::bitset<32ul>>>, std::vector<std::bitset<32ul>, std::allocator<std::bitset<32ul>>>, std::vector<xpair, std::allocator<xpair>>)
void print_seq(vector<ROW> m, vector<ROW> tmp_m, vector<xpair> seq)
{
	ofstream f;
	f.open(FILENAME);
	f << "Original Matrix:" << endl;
	for(int i = 0; i < m.size(); i++)
		f << m[i] << endl;
	f << endl << endl;
	f << "Reduced Matrix:" << endl;
	for(int i = 0; i < tmp_m.size(); i++)
		f << tmp_m[i] << endl;
	f << endl << endl;


	f << "Xor Count = " << seq.size() << endl;
	
	int tab[SIZE] = {0};
	for(int i = 0; i < tmp_m.size(); i++)
		{
			for(int j = 0; j < tmp_m.size(); j++)
			{
				if(tmp_m[i].test(tmp_m.size() - 1 - j))
				{
					tab[i] = j;
					break;
				}
			}
		}

	for(int i = seq.size() - 1; i >= 0; i--)
		{//f << seq[i].dst << " <- " << seq[i].src << endl;
			f<<"x["<<tab[seq[i].dst]<<"] = x["<<tab[seq[i].dst]<<"] ^ x["<<tab[seq[i].src]<<"]";
		    tmp_m[seq[i].dst] ^= tmp_m[seq[i].src];
		  	bool flag = false;
		    for(int j = 0; j < m.size(); j++)
		    {
				if(tmp_m[seq[i].dst] == m[j])
				{
					flag = true;
					f<<"    y["<<j<<"]"<<endl;
					break;
				}
			}
			
			if(!flag)
			{
				f<<endl;
			}
		}
		f.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x88(%rsp), %r12
movq %r12, %rdi
callq 0x2240
leaq 0x392d(%rip), %rsi      # 0x6004
pushq $0x10
popq %rdx
movq %r12, %rdi
callq 0x2040
leaq 0x393c(%rip), %rsi      # 0x6025
leaq 0x88(%rsp), %rdi
callq 0x2150
movq %rax, %rdi
callq 0x20a0
xorl %r13d, %r13d
leaq 0x88(%rsp), %r12
xorl %ebp, %ebp
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jbe 0x273a
addq %r13, %rsi
movq %r12, %rdi
callq 0x2a88
movq %rax, %rdi
callq 0x20a0
incq %rbp
addq $0x8, %r13
jmp 0x270b
leaq 0x88(%rsp), %rdi
callq 0x20a0
movq %rax, %rdi
callq 0x20a0
leaq 0x38e0(%rip), %rsi      # 0x6036
leaq 0x88(%rsp), %rdi
callq 0x2150
movq %rax, %rdi
callq 0x20a0
xorl %r13d, %r13d
leaq 0x88(%rsp), %r12
xorl %ebp, %ebp
movq (%r14), %rsi
movq 0x8(%r14), %rax
subq %rsi, %rax
sarq $0x3, %rax
cmpq %rbp, %rax
jbe 0x27a7
addq %r13, %rsi
movq %r12, %rdi
callq 0x2a88
movq %rax, %rdi
callq 0x20a0
incq %rbp
addq $0x8, %r13
jmp 0x2778
leaq 0x88(%rsp), %rdi
callq 0x20a0
movq %rax, %rdi
callq 0x20a0
leaq 0x3883(%rip), %rsi      # 0x6046
leaq 0x88(%rsp), %rdi
callq 0x2150
movq %rax, %rdi
movq 0x8(%rbx), %rax
subq (%rbx), %rax
pushq $0xc
popq %rcx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x20e0
movq %rax, %rdi
callq 0x20a0
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
xorl %r13d, %r13d
movq (%r14), %rax
movq 0x8(%r14), %rsi
movq %rsi, %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x286f
pushq $-0x1
popq %rbp
xorl %r12d, %r12d
subq %rax, %rsi
sarq $0x3, %rsi
cmpq %r12, %rsi
jbe 0x286a
leaq (%rax,%r13,8), %rdi
addq %rbp, %rsi
callq 0x2b50
testb %al, %al
jne 0x2866
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rsi
decq %rbp
jmp 0x283b
movl %r12d, (%rsp,%r13,4)
incq %r13
jmp 0x281f
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
pushq $0xc
popq %rcx
idivq %rcx
movl %eax, %ebp
leaq 0x88(%rsp), %r13
decq %rbp
testl %ebp, %ebp
js 0x2992
movq %r13, %rdi
leaq 0x37ba(%rip), %rsi      # 0x6057
callq 0x2150
movl %ebp, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq (%rbx), %rdx
imulq $0xc, %rcx, %r12
movslq 0x4(%rdx,%r12), %rcx
movl (%rsp,%rcx,4), %esi
movq %rax, %rdi
callq 0x2250
movq %rax, %rdi
leaq 0x3788(%rip), %rsi      # 0x6053
callq 0x2150
movq (%rbx), %rcx
movslq 0x4(%rcx,%r12), %rcx
movl (%rsp,%rcx,4), %esi
movq %rax, %rdi
callq 0x2250
movq %rax, %rdi
leaq 0x376d(%rip), %rsi      # 0x605a
callq 0x2150
movq (%rbx), %rcx
movslq (%rcx,%r12), %rcx
movl (%rsp,%rcx,4), %esi
movq %rax, %rdi
callq 0x2250
movq %rax, %rdi
leaq 0x3753(%rip), %rsi      # 0x6061
callq 0x2150
movq (%rbx), %rax
movslq (%rax,%r12), %rcx
movq (%r14), %rdx
movslq 0x4(%rax,%r12), %rsi
movq (%rdx,%rsi,8), %rax
xorq (%rdx,%rcx,8), %rax
movq %rax, (%rdx,%rsi,8)
movq (%r15), %rcx
movq 0x8(%r15), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
xorl %r12d, %r12d
cmpq %r12, %rdx
je 0x294f
cmpq (%rcx,%r12,8), %rax
je 0x295c
incq %r12
jmp 0x293f
movq %r13, %rdi
callq 0x20a0
jmp 0x2888
movq %r13, %rdi
leaq 0x36fd(%rip), %rsi      # 0x6063
callq 0x2150
movq %rax, %rdi
movl %r12d, %esi
callq 0x2250
movq %rax, %rdi
leaq 0x36e1(%rip), %rsi      # 0x6061
callq 0x2150
movq %rax, %rdi
callq 0x20a0
jmp 0x2888
leaq 0x88(%rsp), %rdi
callq 0x21e0
leaq 0x88(%rsp), %rdi
callq 0x21f0
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x29cc
jmp 0x29cc
jmp 0x29cc
jmp 0x29cc
jmp 0x29cc
jmp 0x29cc
jmp 0x29cc
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x21f0
movq %rbx, %rdi
callq 0x2270