// File: CMU-SAFARI[P]Register-Interval/main.cpp
// Function: registerInterval_log(std::vector<registerInterval*, std::allocator<registerInterval*>>, int, char*)
void registerInterval_log(vector<registerInterval*> intervals, int iteration, 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/registerIntervals_" + File + ".txt");
        
	out << "The number of Intervals = " << intervals.size() << endl;
	for (int i = 0; i < intervals.size(); i++){
		out << " #Interval ID = " << intervals[i]->getID() << " #Number of Instructions = " << intervals[i]->getNumberOfInstructions() << endl;
		out << "		 #Register_list = {";
		set<string> L = intervals[i]->get_register_list();
		set<string>::iterator it;
		for (it = L.begin(); it != L.end(); it++)
			out << *it << " ";
		out << "}; #Number of Registers = " << L.size() << ";" << endl;
			
		vector<registerInterval*> ii;

		ii = intervals[i]->get_predecessors();
		out <<"		Predecessors = { ";
		for(int j = 0; j < ii.size(); j++){
			out << ii[j]->getID() << " ";
		}

		ii = intervals[i]->get_successors();
		out << "}		Successors = { ";
		for(int j = 0; j < ii.size(); j++){
			out << ii[j]->getID() << " ";
		}
		out << "};" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x380(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x378(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x3450
movq -0x378(%rbp), %rsi
movq -0x370(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x3340
jmp 0x9d01
leaq -0x39(%rbp), %rdi
callq 0x32a0
leaq -0x38(%rbp), %rdi
leaq 0xe333(%rip), %rsi      # 0x18048
xorl %eax, %eax
movl %eax, %edx
callq 0x3490
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movslq -0x50(%rbp), %rax
cmpq $-0x1, %rax
je 0x9d6f
movl -0x50(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
leaq -0x38(%rbp), %rdi
leaq 0xe2fd(%rip), %rsi      # 0x18048
callq 0x3490
movl %eax, -0x50(%rbp)
jmp 0x9d27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x32a0
jmp 0xa3eb
leaq 0xe2d4(%rip), %rsi      # 0x1804a
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x3490
movq -0x388(%rbp), %rsi
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %ecx
incl %ecx
movslq %ecx, %rdx
movl -0x58(%rbp), %ecx
notl %eax
addl %ecx, %eax
movslq %eax, %rcx
leaq -0x78(%rbp), %rdi
callq 0x3260
jmp 0x9db3
leaq -0x38(%rbp), %rdi
movq %rdi, -0x390(%rbp)
leaq -0x78(%rbp), %rsi
movq %rsi, -0x398(%rbp)
callq 0x32c0
movq -0x398(%rbp), %rdi
callq 0x31a0
movq -0x390(%rbp), %rdx
leaq 0xe32b(%rip), %rsi      # 0x18113
leaq -0x2b8(%rbp), %rdi
callq 0xcff0
jmp 0x9df6
leaq 0xe263(%rip), %rdx      # 0x18060
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0xcfa0
jmp 0x9e12
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
movl $0x10, %edx
callq 0x3470
jmp 0x9e2c
leaq -0x298(%rbp), %rdi
callq 0x31a0
leaq -0x2b8(%rbp), %rdi
callq 0x31a0
leaq 0xe2e2(%rip), %rsi      # 0x1812d
leaq -0x278(%rbp), %rdi
callq 0x3240
movq %rax, -0x3a0(%rbp)
jmp 0x9e60
movq -0x380(%rbp), %rdi
callq 0xbc10
movq -0x3a0(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x3a8(%rbp)
jmp 0x9e84
movq -0x3a8(%rbp), %rdi
movq 0x18136(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x9e99
movl $0x0, -0x2bc(%rbp)
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rax
movq %rax, -0x3b0(%rbp)
callq 0xbc10
movq %rax, %rcx
movq -0x3b0(%rbp), %rax
cmpq %rcx, %rax
jae 0xa3b8
leaq 0xe271(%rip), %rsi      # 0x18148
leaq -0x278(%rbp), %rdi
callq 0x3240
movq %rax, -0x3b8(%rbp)
jmp 0x9eec
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rsi
callq 0xbc30
movq (%rax), %rdi
callq 0x37f0
movq -0x3b8(%rbp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, -0x3c0(%rbp)
jmp 0x9f1e
movq -0x3c0(%rbp), %rdi
leaq 0xe22d(%rip), %rsi      # 0x18159
callq 0x3240
movq %rax, -0x3c8(%rbp)
jmp 0x9f3a
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rsi
callq 0xbc30
movq (%rax), %rdi
callq 0x3800
movq -0x3c8(%rbp), %rdi
movl %eax, %esi
callq 0x3420
movq %rax, -0x3d0(%rbp)
jmp 0x9f6c
movq -0x3d0(%rbp), %rdi
movq 0x1804e(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0x9f81
leaq 0xe1ed(%rip), %rsi      # 0x18175
leaq -0x278(%rbp), %rdi
callq 0x3240
jmp 0x9f96
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rsi
callq 0xbc30
movq (%rax), %rsi
leaq -0x2f0(%rbp), %rdi
callq 0x38f0
jmp 0x9fba
leaq -0x2f8(%rbp), %rdi
callq 0xb900
leaq -0x2f0(%rbp), %rdi
callq 0xb9f0
movq %rax, -0x300(%rbp)
movq -0x300(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0xba50
movq %rax, -0x308(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0xba20
testb $0x1, %al
jne 0xa016
jmp 0xa0d5
leaq -0x2f8(%rbp), %rdi
callq 0xba80
movq %rax, %rsi
leaq -0x278(%rbp), %rdi
callq 0x3220
movq %rax, -0x3d8(%rbp)
jmp 0xa03a
movq -0x3d8(%rbp), %rdi
leaq 0xe051(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0xa04f
jmp 0xa051
leaq -0x2f8(%rbp), %rdi
xorl %esi, %esi
callq 0xc5e0
movq %rax, -0x310(%rbp)
jmp 0x9fe7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa3e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa0a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x31a0
leaq -0x2b8(%rbp), %rdi
callq 0x31a0
jmp 0xa3e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa3d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa3aa
leaq 0xdff1(%rip), %rsi      # 0x180cd
leaq -0x278(%rbp), %rdi
callq 0x3240
movq %rax, -0x3e0(%rbp)
jmp 0xa0f1
leaq -0x2f0(%rbp), %rdi
callq 0xc350
movq -0x3e0(%rbp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, -0x3e8(%rbp)
jmp 0xa115
movq -0x3e8(%rbp), %rdi
leaq 0xdfee(%rip), %rsi      # 0x18111
callq 0x3240
movq %rax, -0x3f0(%rbp)
jmp 0xa131
movq -0x3f0(%rbp), %rdi
movq 0x17e89(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0xa146
leaq -0x328(%rbp), %rdi
callq 0xb650
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rsi
callq 0xbc30
movq (%rax), %rsi
leaq -0x340(%rbp), %rdi
callq 0x3c50
jmp 0xa176
leaq -0x328(%rbp), %rdi
leaq -0x340(%rbp), %rsi
movq %rsi, -0x3f8(%rbp)
callq 0xcd70
movq -0x3f8(%rbp), %rdi
callq 0xb670
leaq 0xdfe8(%rip), %rsi      # 0x1818b
leaq -0x278(%rbp), %rdi
callq 0x3240
jmp 0xa1b1
movl $0x0, -0x344(%rbp)
movslq -0x344(%rbp), %rax
movq %rax, -0x400(%rbp)
leaq -0x328(%rbp), %rdi
callq 0xbc10
movq %rax, %rcx
movq -0x400(%rbp), %rax
cmpq %rcx, %rax
jae 0xa25e
movslq -0x344(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0xbc30
movq (%rax), %rdi
callq 0x37f0
movl %eax, %esi
leaq -0x278(%rbp), %rdi
callq 0x3420
movq %rax, -0x408(%rbp)
jmp 0xa216
movq -0x408(%rbp), %rdi
leaq 0xde75(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0xa22b
jmp 0xa22d
movl -0x344(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x344(%rbp)
jmp 0xa1bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x328(%rbp), %rdi
callq 0xb670
jmp 0xa3aa
movq -0x380(%rbp), %rdi
movslq -0x2bc(%rbp), %rsi
callq 0xbc30
movq (%rax), %rsi
leaq -0x360(%rbp), %rdi
callq 0x3c90
jmp 0xa282
leaq -0x328(%rbp), %rdi
leaq -0x360(%rbp), %rsi
movq %rsi, -0x410(%rbp)
callq 0xcd70
movq -0x410(%rbp), %rdi
callq 0xb670
leaq 0xdef0(%rip), %rsi      # 0x1819f
leaq -0x278(%rbp), %rdi
callq 0x3240
jmp 0xa2bd
movl $0x0, -0x364(%rbp)
movslq -0x364(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq -0x328(%rbp), %rdi
callq 0xbc10
movq %rax, %rcx
movq -0x418(%rbp), %rax
cmpq %rcx, %rax
jae 0xa34d
movslq -0x364(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0xbc30
movq (%rax), %rdi
callq 0x37f0
movl %eax, %esi
leaq -0x278(%rbp), %rdi
callq 0x3420
movq %rax, -0x420(%rbp)
jmp 0xa322
movq -0x420(%rbp), %rdi
leaq 0xdd69(%rip), %rsi      # 0x18099
callq 0x3240
jmp 0xa337
jmp 0xa339
movl -0x364(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x364(%rbp)
jmp 0xa2c7
leaq 0xddbc(%rip), %rsi      # 0x18110
leaq -0x278(%rbp), %rdi
callq 0x3240
movq %rax, -0x428(%rbp)
jmp 0xa369
movq -0x428(%rbp), %rdi
movq 0x17c51(%rip), %rsi     # 0x21fc8
callq 0x3280
jmp 0xa37e
leaq -0x328(%rbp), %rdi
callq 0xb670
leaq -0x2f0(%rbp), %rdi
callq 0xb6d0
movl -0x2bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x9ea3
leaq -0x2f0(%rbp), %rdi
callq 0xb6d0
jmp 0xa3d6
leaq -0x278(%rbp), %rdi
callq 0x3390
leaq -0x38(%rbp), %rdi
callq 0x31a0
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
leaq -0x278(%rbp), %rdi
callq 0x3390
leaq -0x38(%rbp), %rdi
callq 0x31a0
movq -0x48(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)