// File: ys1998[P]spsim/src/lists.cpp
// Function: ActiveList::graduate(Instruction&)
void ActiveList::graduate(Instruction& instr){
	for(auto& p : _q){
		if(p.first.get_id() == instr.get_id()){
			p.second = true;
			// update the clock times
			p.first.IF = instr.IF;
			p.first.DE = instr.DE;
			p.first.RF1 = instr.RF1;
			p.first.EXEC = instr.EXEC;
			p.first.RF2 = instr.RF2;
			p.first.MEM = instr.MEM;
			p.first.WB = instr.WB;
			break;
		}
	}

	while(!_q.empty() && _q.front().second){
		Instruction temp = _q.front().first;
		std::tuple<int, int, int, int> t = temp.physical_regs();
		if(std::get<3>(t) != -1){
			f->add(std::get<3>(t));
		}
		o->push_back(temp);
		_q.pop_front();
		if(_q.empty())
			terminate = true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x13b70
movq -0x18(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x13ba0
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x13bd0
testb $0x1, %al
jne 0x136d2
jmp 0x1377f
leaq -0x38(%rbp), %rdi
callq 0x13c00
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x6270
movl %eax, -0x104(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6270
movl %eax, %ecx
movl -0x104(%rbp), %eax
cmpl %ecx, %eax
jne 0x1376f
movq -0x60(%rbp), %rax
movb $0x1, 0x78(%rax)
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x4c(%rax)
jmp 0x1377f
jmp 0x13771
leaq -0x38(%rbp), %rdi
callq 0x13c20
jmp 0x136bc
jmp 0x13781
movq -0x100(%rbp), %rdi
callq 0x13c70
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x105(%rbp)
jne 0x137b1
movq -0x100(%rbp), %rdi
callq 0x13ca0
movb 0x78(%rax), %al
movb %al, -0x105(%rbp)
movb -0x105(%rbp), %al
testb $0x1, %al
jne 0x137c0
jmp 0x138aa
movq -0x100(%rbp), %rdi
callq 0x13ca0
movq %rax, %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x6c70
movq -0x110(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x10520
jmp 0x137f7
leaq -0xe8(%rbp), %rdi
callq 0x10b10
cmpl $-0x1, (%rax)
je 0x13858
movq -0x100(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x118(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x10b10
movq -0x118(%rbp), %rdi
movl (%rax), %esi
callq 0x12bc0
jmp 0x13836
jmp 0x13858
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x61d0
jmp 0x138b3
movq -0x100(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xab70
jmp 0x13871
movq -0x100(%rbp), %rdi
callq 0x13cd0
movq -0x100(%rbp), %rdi
callq 0x13c70
testb $0x1, %al
jne 0x1388f
jmp 0x13899
leaq 0x1ba2a(%rip), %rax     # 0x2f2c0
movb $0x1, (%rax)
leaq -0xd8(%rbp), %rdi
callq 0x61d0
jmp 0x13781
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0xf0(%rbp), %rdi
callq 0x3480
nop