// File: CMU-SAFARI[P]Register-Interval/main.cpp
// Function: basic_blocks_log(std::vector<basicBlock*, std::allocator<basicBlock*>>, char*)
void basic_blocks_log(vector<basicBlock*> basic_blocks, char* file_name){
	std::string File(file_name);
	int p = File.find("/");
	int p1 = p;
	while(p != string::npos){
		p1 = p;
		p = File.find("/", p + 1);
	}
	int p2 = File.find(".");
	File = File.substr(p1 + 1, p2 - p1 - 1);
        std::ofstream out("output/BasicBlocks_" + File + ".txt");
        
        vector<basicBlock*> P ,S;
	out << "The number of basic_blocks = " << basic_blocks.size() << endl;
	for (int i = 0; i < basic_blocks.size(); i++){
		out << " #The basic_block ID : " << basic_blocks[i]->getID() << endl;
		out << "		#Number of Instructions = " << basic_blocks[i]->numberOfInstructions() << endl;
		out << "		#Register_list = {";
		set<string> L = basic_blocks[i]->get_output_list();
		set<string>::iterator it;
		for (it = L.begin(); it != L.end(); it++)
			out << *it << " ";
		out << "}; #Number of Registers = " << L.size() << ";" << endl;
		P = basic_blocks[i]->get_predecessors();
		S = basic_blocks[i]->get_successors();
		out << "		#predecessors = {";
		for(int j=0;j<P.size();j++){
			out << P[j]->getID() << " ";
		}
		out << "};		#successors = {";
		for(int j=0;j<S.size();j++){
			out << S[j]->getID() << " ";
		}
		out <<"};" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x388(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x380(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x378(%rbp)
callq 0x3450
movq -0x380(%rbp), %rsi
movq -0x378(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x3340
jmp 0x958e
leaq -0x31(%rbp), %rdi
callq 0x32a0
leaq -0x30(%rbp), %rdi
leaq 0xeaa6(%rip), %rsi      # 0x18048
xorl %eax, %eax
movl %eax, %edx
callq 0x3490
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movslq -0x48(%rbp), %rax
cmpq $-0x1, %rax
je 0x95fc
movl -0x48(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
leaq -0x30(%rbp), %rdi
leaq 0xea70(%rip), %rsi      # 0x18048
callq 0x3490
movl %eax, -0x48(%rbp)
jmp 0x95b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x32a0
jmp 0x9c9e
leaq 0xea47(%rip), %rsi      # 0x1804a
xorl %eax, %eax
movl %eax, %edx
leaq -0x30(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x3490
movq -0x390(%rbp), %rsi
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rdx
movl -0x50(%rbp), %ecx
notl %eax
addl %ecx, %eax
movslq %eax, %rcx
leaq -0x70(%rbp), %rdi
callq 0x3260
jmp 0x9640
leaq -0x30(%rbp), %rdi
movq %rdi, -0x398(%rbp)
leaq -0x70(%rbp), %rsi
movq %rsi, -0x3a0(%rbp)
callq 0x32c0
movq -0x3a0(%rbp), %rdi
callq 0x31a0
movq -0x398(%rbp), %rdx
leaq 0xe9d7(%rip), %rsi      # 0x1804c
leaq -0x2b0(%rbp), %rdi
callq 0xcff0
jmp 0x9683
leaq 0xe9d6(%rip), %rdx      # 0x18060
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0xcfa0
jmp 0x969f
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
movl $0x10, %edx
callq 0x3470
jmp 0x96b9
leaq -0x290(%rbp), %rdi
callq 0x31a0
leaq -0x2b0(%rbp), %rdi
callq 0x31a0
leaq -0x2c8(%rbp), %rdi
callq 0xbdb0
leaq -0x2e0(%rbp), %rdi
callq 0xbdb0
leaq 0xe975(%rip), %rsi      # 0x18065
leaq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x3a8(%rbp)
jmp 0x9705
movq -0x388(%rbp), %rdi
callq 0xbe80
movq -0x3a8(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x3b0(%rbp)
jmp 0x9729
movq -0x3b0(%rbp), %rdi
movq 0x18891(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x973e
movl $0x0, -0x2e4(%rbp)
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rax
movq %rax, -0x3b8(%rbp)
callq 0xbe80
movq %rax, %rcx
movq -0x3b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x9c3b
leaq 0xe907(%rip), %rsi      # 0x18083
leaq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x3c0(%rbp)
jmp 0x9791
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rsi
callq 0xbea0
movq (%rax), %rdi
callq 0x4350
movq -0x3c0(%rbp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, -0x3c8(%rbp)
jmp 0x97c3
movq -0x3c8(%rbp), %rdi
movq 0x187f7(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x97d8
leaq 0xe8bc(%rip), %rsi      # 0x1809b
leaq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x3d0(%rbp)
jmp 0x97f4
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rsi
callq 0xbea0
movq (%rax), %rdi
callq 0x40c0
movq -0x3d0(%rbp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, -0x3d8(%rbp)
jmp 0x9826
movq -0x3d8(%rbp), %rdi
movq 0x18794(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x983b
leaq 0xe876(%rip), %rsi      # 0x180b8
leaq -0x270(%rbp), %rdi
callq 0x3240
jmp 0x9850
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rsi
callq 0xbea0
movq (%rax), %rsi
leaq -0x318(%rbp), %rdi
callq 0x43c0
jmp 0x9874
leaq -0x320(%rbp), %rdi
callq 0xb900
leaq -0x318(%rbp), %rdi
callq 0xb9f0
movq %rax, -0x328(%rbp)
movq -0x328(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x318(%rbp), %rdi
callq 0xba50
movq %rax, -0x330(%rbp)
leaq -0x320(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0xba20
testb $0x1, %al
jne 0x98d0
jmp 0x999b
leaq -0x320(%rbp), %rdi
callq 0xba80
movq %rax, %rsi
leaq -0x270(%rbp), %rdi
callq 0x3220
movq %rax, -0x3e0(%rbp)
jmp 0x98f4
movq -0x3e0(%rbp), %rdi
leaq 0xe797(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0x9909
jmp 0x990b
leaq -0x320(%rbp), %rdi
xorl %esi, %esi
callq 0xc5e0
movq %rax, -0x338(%rbp)
jmp 0x98a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9c95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x995c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x31a0
leaq -0x2b0(%rbp), %rdi
callq 0x31a0
jmp 0x9c95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x9c71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x318(%rbp), %rdi
callq 0xb6d0
jmp 0x9c71
leaq 0xe72b(%rip), %rsi      # 0x180cd
leaq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x3e8(%rbp)
jmp 0x99b7
leaq -0x318(%rbp), %rdi
callq 0xc350
movq -0x3e8(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x3f0(%rbp)
jmp 0x99db
movq -0x3f0(%rbp), %rdi
leaq 0xe728(%rip), %rsi      # 0x18111
callq 0x3240
movq %rax, -0x3f8(%rbp)
jmp 0x99f7
movq -0x3f8(%rbp), %rdi
movq 0x185c3(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x9a0c
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rsi
callq 0xbea0
movq (%rax), %rsi
leaq -0x350(%rbp), %rdi
callq 0x44a0
jmp 0x9a30
leaq -0x2c8(%rbp), %rdi
leaq -0x350(%rbp), %rsi
movq %rsi, -0x400(%rbp)
callq 0xcf20
movq -0x400(%rbp), %rdi
callq 0xbdd0
movq -0x388(%rbp), %rdi
movslq -0x2e4(%rbp), %rsi
callq 0xbea0
movq (%rax), %rsi
leaq -0x368(%rbp), %rdi
callq 0x44d0
jmp 0x9a7a
leaq -0x2e0(%rbp), %rdi
leaq -0x368(%rbp), %rsi
movq %rsi, -0x408(%rbp)
callq 0xcf20
movq -0x408(%rbp), %rdi
callq 0xbdd0
leaq 0xe641(%rip), %rsi      # 0x180e8
leaq -0x270(%rbp), %rdi
callq 0x3240
jmp 0x9ab5
movl $0x0, -0x36c(%rbp)
movslq -0x36c(%rbp), %rax
movq %rax, -0x410(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0xbe80
movq %rax, %rcx
movq -0x410(%rbp), %rax
cmpq %rcx, %rax
jae 0x9b45
movslq -0x36c(%rbp), %rsi
leaq -0x2c8(%rbp), %rdi
callq 0xbea0
movq (%rax), %rdi
callq 0x4350
movl %eax, %esi
leaq -0x270(%rbp), %rdi
callq 0x3420
movq %rax, -0x418(%rbp)
jmp 0x9b1a
movq -0x418(%rbp), %rdi
leaq 0xe571(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0x9b2f
jmp 0x9b31
movl -0x36c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x36c(%rbp)
jmp 0x9abf
leaq 0xe5b0(%rip), %rsi      # 0x180fc
leaq -0x270(%rbp), %rdi
callq 0x3240
jmp 0x9b5a
movl $0x0, -0x370(%rbp)
movslq -0x370(%rbp), %rax
movq %rax, -0x420(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0xbe80
movq %rax, %rcx
movq -0x420(%rbp), %rax
cmpq %rcx, %rax
jae 0x9bea
movslq -0x370(%rbp), %rsi
leaq -0x2e0(%rbp), %rdi
callq 0xbea0
movq (%rax), %rdi
callq 0x4350
movl %eax, %esi
leaq -0x270(%rbp), %rdi
callq 0x3420
movq %rax, -0x428(%rbp)
jmp 0x9bbf
movq -0x428(%rbp), %rdi
leaq 0xe4cc(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0x9bd4
jmp 0x9bd6
movl -0x370(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x370(%rbp)
jmp 0x9b64
leaq 0xe51f(%rip), %rsi      # 0x18110
leaq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x430(%rbp)
jmp 0x9c06
movq -0x430(%rbp), %rdi
movq 0x183b4(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x9c1b
leaq -0x318(%rbp), %rdi
callq 0xb6d0
movl -0x2e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e4(%rbp)
jmp 0x9748
leaq -0x2e0(%rbp), %rdi
callq 0xbdd0
leaq -0x2c8(%rbp), %rdi
callq 0xbdd0
leaq -0x270(%rbp), %rdi
callq 0x3390
leaq -0x30(%rbp), %rdi
callq 0x31a0
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
leaq -0x2e0(%rbp), %rdi
callq 0xbdd0
leaq -0x2c8(%rbp), %rdi
callq 0xbdd0
leaq -0x270(%rbp), %rdi
callq 0x3390
leaq -0x30(%rbp), %rdi
callq 0x31a0
movq -0x40(%rbp), %rdi
callq 0x3440
nopw (%rax,%rax)