// File: /workspace/github_cpp_makefile_star2_O1/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 $0x298, %rsp            # imm = 0x298
movq %rdx, %rbx
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
leaq 0x98(%rsp), %r12
movq %r12, %rdi
callq 0x2250
leaq 0x46d7(%rip), %rsi      # 0x7004
movq %r12, %rdi
movl $0x10, %edx
callq 0x2050
leaq 0x46e4(%rip), %rsi      # 0x7025
leaq 0x98(%rsp), %r12
movl $0x10, %edx
movq %r12, %rdi
callq 0x2180
movq 0x98(%rsp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq (%r15), %rsi
cmpq %rsi, 0x8(%r15)
je 0x29ed
xorl %r14d, %r14d
leaq 0x98(%rsp), %r13
xorl %r12d, %r12d
addq %r14, %rsi
movq %r13, %rdi
callq 0x2fa8
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
incq %r12
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
sarq $0x3, %rax
addq $0x8, %r14
cmpq %r12, %rax
ja 0x299e
movq 0x98(%rsp), %rax
leaq 0x98(%rsp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x45e2(%rip), %rsi      # 0x7036
leaq 0x98(%rsp), %r12
movl $0xf, %edx
movq %r12, %rdi
callq 0x2180
movq 0x98(%rsp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
cmpq %rsi, 0x8(%rax)
je 0x2b0a
xorl %r14d, %r14d
leaq 0x98(%rsp), %r13
xorl %r12d, %r12d
addq %r14, %rsi
movq %r13, %rdi
callq 0x2fa8
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
incq %r12
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rax
subq %rsi, %rax
sarq $0x3, %rax
addq $0x8, %r14
cmpq %r12, %rax
ja 0x2ab6
movq 0x98(%rsp), %rax
leaq 0x98(%rsp), %rdi
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
leaq 0x98(%rsp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x44d5(%rip), %rsi      # 0x7046
leaq 0x98(%rsp), %rdi
movl $0xc, %edx
callq 0x2180
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x2, %rax
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
leaq 0x98(%rsp), %r12
movq %r12, %rdi
callq 0x20d0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
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)
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %rax
subq %rcx, %rax
je 0x2c66
sarq $0x3, %rax
cmpq $0x1, %rax
movq %rax, %rdx
adcq $0x0, %rdx
leaq -0x1(%rax), %rsi
movq %rdx, %rdi
negq %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
leaq (%rsi,%r9), %r10
cmpq $0x20, %r10
jae 0x2e59
movq (%rcx,%r8,8), %r11
btq %r10, %r11
jb 0x2c56
decq %r9
cmpq %r9, %rdi
jne 0x2c34
jmp 0x2c5e
negl %r9d
movl %r9d, 0x10(%rsp,%r8,4)
incq %r8
cmpq %rdx, %r8
jne 0x2c31
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x2, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
decl %eax
js 0x2e02
movl %eax, %ebp
movl $0x2, %edx
movq %r12, %rdi
leaq 0x43c7(%rip), %rsi      # 0x7057
callq 0x2180
movq (%rbx), %rax
leaq (,%rbp,2), %r14
addq %rbp, %r14
movslq 0x4(%rax,%r14,4), %rax
movl 0x10(%rsp,%rax,4), %esi
movq %r12, %rdi
callq 0x2260
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x438d(%rip), %rsi      # 0x7053
callq 0x2180
movq (%rbx), %rax
movslq 0x4(%rax,%r14,4), %rax
movl 0x10(%rsp,%rax,4), %esi
movq %r13, %rdi
callq 0x2260
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x4369(%rip), %rsi      # 0x705a
callq 0x2180
movq (%rbx), %rax
movslq (%rax,%r14,4), %rax
movl 0x10(%rsp,%rax,4), %esi
movq %r13, %rdi
callq 0x2260
movl $0x1, %edx
movq %rax, %rdi
leaq 0x4349(%rip), %rsi      # 0x7061
callq 0x2180
movq (%rbx), %rax
movslq (%rax,%r14,4), %rcx
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
movslq 0x4(%rax,%r14,4), %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
je 0x2d66
sarq $0x3, %rdx
cmpq $0x1, %rdx
adcq $0x0, %rdx
xorl %r13d, %r13d
cmpq (%rcx,%r13,8), %rax
je 0x2d94
incq %r13
cmpq %r13, %rdx
jne 0x2d58
movq 0x98(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
jmp 0x2df2
movl $0x6, %edx
movq %r12, %rdi
leaq 0x42c0(%rip), %rsi      # 0x7063
callq 0x2180
movq %r12, %rdi
movl %r13d, %esi
callq 0x2260
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x429c(%rip), %rsi      # 0x7061
callq 0x2180
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq -0x1(%rbp), %rax
testq %rbp, %rbp
movq %rax, %rbp
jg 0x2c81
leaq 0x98(%rsp), %rdi
callq 0x21f0
movq 0x71ba(%rip), %rax      # 0x9fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0xa0(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x98(%rsp,%rcx)
callq 0x2110
leaq 0x190(%rsp), %rdi
callq 0x2060
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rax,%r9), %rdx
decq %rdx
leaq 0x4210(%rip), %rdi      # 0x7077
leaq 0x41fc(%rip), %rsi      # 0x706a
movl $0x20, %ecx
xorl %eax, %eax
callq 0x2210
jmp 0x2e88
jmp 0x2e88
jmp 0x2e88
jmp 0x2e88
jmp 0x2e88
jmp 0x2e88
jmp 0x2e88
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2270