// File: /workspace/github_cpp_makefile_star2_O3/dsesami[P]superscalar-processor-model/retire.cc
// Function: retire()
void retire(){

    if(isROBempty()) return; // Nothing within ROB.

   for(u_int i=0; i<ROB.size(); i++) {
        // set first cycle and duration of this instruction.
        if(ROB.at(i).ready && (ROB.at(i).instruction.retire_first == -1)) {
            ROB.at(i).instruction.retire_first = cycles;
        }
   }
for(u_int i=0; i<WIDTH; i++) {
   if(ROB.at(head).ready && ROB.at(head).valid) {
       // Print information

       ROB.at(head).instruction.retire_time = cycles - ROB.at(head).instruction.retire_first+1;
        cout << ROB.at(head).instruction.dyn << " "
             << "fu{" << ROB.at(head).instruction.op_type << "} "
             << "src{" << ROB.at(head).instruction.src_1 << ","
             << ROB.at(head).instruction.src_2 << "} "
             << "dst{" << ROB.at(head).instruction.dest << "} "
             << "FE{" << ROB.at(head).instruction.fetch_first << ","
             << ROB.at(head).instruction.fetch_time << "} "
             << "DE{" << ROB.at(head).instruction.decode_first << ","
             << ROB.at(head).instruction.decode_time << "} "
             << "RN{" << ROB.at(head).instruction.rename_first << ","
             << ROB.at(head).instruction.rename_time << "} "
             << "RR{" << ROB.at(head).instruction.regRead_first << ","
             << ROB.at(head).instruction.regRead_time << "} "
             << "DI{" << ROB.at(head).instruction.dispatch_first << ","
             << ROB.at(head).instruction.dispatch_time << "} "
             << "IS{" << ROB.at(head).instruction.issue_first << ","
             << ROB.at(head).instruction.issue_time << "} "
             << "EX{" << ROB.at(head).instruction.execute_first << ","
             << ROB.at(head).instruction.execute_time << "} "
             << "WB{" << ROB.at(head).instruction.writeback_first << ","
             << ROB.at(head).instruction.writeback_time << "} "
             << "RT{" << ROB.at(head).instruction.retire_first << ","
             << ROB.at(head).instruction.retire_time << "}  "
             << endl;

        //dyn_instr_count++;
        // invalidate RMT
        if(ROB.at(head).instruction.dest != -1) {
            if(ROB.at(head).instruction.rn_dest == RMT.at(ROB.at(head).instruction.dest).rob_tag) {
                RMT.at(ROB.at(head).instruction.dest).valid = false;
                RMT.at(ROB.at(head).instruction.dest).rob_tag = -1;
            }
        }
        // Move head down and stop.
        //ROB.at(head).ready = 0;
        ROB.at(head).valid = 0;
        ROB.at(head).instruction.address = 0;
        //ROB.at(head).address = 0;
        //ROB.at(head).dest = -1;

        head++;
        if(head == ROBSIZE) head = 0;
        //dyn_instr_count++;
   }
}
    return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
callq 0x317d
testb %al, %al
jne 0x70a7
leaq 0x4bdd(%rip), %rbx      # 0xb3a8
movq (%rbx), %rdi
movq 0x8(%rbx), %r8
movq %r8, %rax
movabsq $-0x79435e50d79435e5, %r14 # imm = 0x86BCA1AF286BCA1B
subq %rdi, %rax
je 0x6821
sarq $0x3, %rax
imulq %r14, %rax
leaq 0x84(%rdi), %rcx
movl $0x1, %edx
leaq 0x4995(%rip), %rsi      # 0xb194
cmpb $0x1, -0x7c(%rcx)
jne 0x6810
cmpl $-0x1, (%rcx)
jne 0x6810
movl (%rsi), %r9d
movl %r9d, (%rcx)
movl %edx, %r9d
addq $0x98, %rcx
incl %edx
cmpq %r9, %rax
ja 0x67ff
leaq 0x495c(%rip), %rax      # 0xb184
movl (%rax), %ecx
testl %ecx, %ecx
je 0x70a7
leaq 0x4927(%rip), %r15      # 0xb160
movl (%r15), %esi
leaq 0x1bdd(%rip), %r12      # 0x8420
xorl %ebp, %ebp
movl %esi, %eax
movq %r8, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rax, %rdx
jbe 0x70c4
imulq $0x98, %rax, %rax
cmpb $0x1, 0x8(%rdi,%rax)
jne 0x709d
addq %rdi, %rax
cmpb $0x1, (%rax)
jne 0x709d
leaq 0x4911(%rip), %rcx      # 0xb194
movl (%rcx), %ecx
subl 0x84(%rax), %ecx
incl %ecx
movl %ecx, 0x88(%rax)
movl (%r15), %esi
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rax
movl 0x90(%rdi,%rax), %esi
movq 0x4724(%rip), %rdi      # 0xafd8
callq 0x20e0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1b8a(%rip), %rsi      # 0x8455
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1b3d(%rip), %rsi      # 0x841c
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x28(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x4, %edx
movq %r13, %rdi
leaq 0x1aec(%rip), %rsi      # 0x8423
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x34(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1aa9(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x3c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x4, %edx
movq %r13, %rdi
leaq 0x1a53(%rip), %rsi      # 0x842a
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x2c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1a00(%rip), %rsi      # 0x842f
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x44(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x19b1(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x48(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1964(%rip), %rsi      # 0x8433
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x4c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1911(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x50(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x18c8(%rip), %rsi      # 0x8437
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x54(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1871(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x58(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x182c(%rip), %rsi      # 0x843b
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x5c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x17d1(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x60(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1790(%rip), %rsi      # 0x843f
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x64(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1731(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x68(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x16f4(%rip), %rsi      # 0x8443
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x6c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1691(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x70(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x1658(%rip), %rsi      # 0x8447
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x74(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x15f1(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x78(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x15bc(%rip), %rsi      # 0x844b
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x7c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1551(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x80(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x151d(%rip), %rsi      # 0x844f
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x84(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x14ab(%rip), %rsi      # 0x8428
callq 0x2180
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rcx
movl 0x88(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x3, %edx
movq %rax, %rdi
leaq 0x148b(%rip), %rsi      # 0x8453
callq 0x2180
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20f0
movl (%r15), %esi
movq (%rbx), %rdi
movq 0x8(%rbx), %r8
movq %r8, %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %r10
movslq 0x2c(%rdi,%r10), %rax
cmpq $-0x1, %rax
je 0x7065
leaq 0x4391(%rip), %rcx      # 0xb3c0
movq (%rcx), %r9
movq 0x8(%rcx), %rcx
subq %r9, %rcx
sarq $0x3, %rcx
cmpq %rax, %rcx
jbe 0x70d0
addq %rdi, %r10
movl 0x30(%r10), %ecx
cmpl 0x4(%r9,%rax,8), %ecx
jne 0x7065
movb $0x0, (%r9,%rax,8)
movl $0xffffffff, 0x4(%r9,%rax,8) # imm = 0xFFFFFFFF
movl (%r15), %esi
cmpq %rsi, %rdx
jbe 0x70b6
imulq $0x98, %rsi, %rax
movb $0x0, (%rdi,%rax)
movq $0x0, 0x20(%rdi,%rax)
incl %esi
leaq 0x40f5(%rip), %rax      # 0xb17c
cmpl (%rax), %esi
movl $0x0, %eax
cmovel %eax, %esi
movl %esi, (%r15)
leaq 0x40e9(%rip), %rax      # 0xb184
movl (%rax), %ecx
incl %ebp
cmpl %ecx, %ebp
jb 0x6845
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1298(%rip), %rdi      # 0x8355
xorl %eax, %eax
callq 0x21d0
leaq 0x128a(%rip), %rdi      # 0x8355
movq %rax, %rsi
jmp 0x70bd
leaq 0x127e(%rip), %rdi      # 0x8355
movq %rax, %rsi
movq %rcx, %rdx
jmp 0x70bd