// File: /workspace/github_cpp_makefile_star2_O1/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 0x3149
testb %al, %al
jne 0x65ef
leaq 0x4685(%rip), %rbx      # 0xa3a8
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movabsq $-0x79435e50d79435e5, %r14 # imm = 0x86BCA1AF286BCA1B
subq %rax, %rcx
je 0x5d71
sarq $0x3, %rcx
imulq %r14, %rcx
addq $0x84, %rax
movl $0x1, %edx
leaq 0x4441(%rip), %rsi      # 0xa194
cmpb $0x1, -0x7c(%rax)
jne 0x5d62
cmpl $-0x1, (%rax)
jne 0x5d62
movl (%rsi), %edi
movl %edi, (%rax)
movl %edx, %edi
addq $0x98, %rax
incl %edx
cmpq %rdi, %rcx
ja 0x5d53
leaq 0x440c(%rip), %rdi      # 0xa184
cmpl $0x0, (%rdi)
je 0x65ef
leaq 0x43d8(%rip), %r15      # 0xa160
leaq 0x1632(%rip), %r12      # 0x73c1
xorl %ebp, %ebp
movl (%r15), %esi
movq (%rbx), %rax
movq 0x8(%rbx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x65fe
imulq $0x98, %rsi, %rcx
cmpb $0x1, 0x8(%rax,%rcx)
jne 0x65e5
addq %rax, %rcx
cmpb $0x1, (%rcx)
jne 0x65e5
leaq 0x43c0(%rip), %rsi      # 0xa194
movl (%rsi), %esi
subl 0x84(%rcx), %esi
incl %esi
movl %esi, 0x88(%rcx)
movl (%r15), %esi
cmpq %rsi, %rdx
jbe 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x90(%rax,%rcx), %esi
movq 0x41d3(%rip), %rdi      # 0x9fd8
callq 0x20e0
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x15da(%rip), %rsi      # 0x73f6
callq 0x2180
movl $0x3, %edx
movq %r13, %rdi
leaq 0x158d(%rip), %rsi      # 0x73bd
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 0x65fe
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 0x153c(%rip), %rsi      # 0x73c4
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x34(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x14f9(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x14a3(%rip), %rsi      # 0x73cb
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 0x65fe
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 0x1450(%rip), %rsi      # 0x73d0
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x44(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1401(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x13b4(%rip), %rsi      # 0x73d4
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x4c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1361(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x1318(%rip), %rsi      # 0x73d8
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x54(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x12c1(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x127c(%rip), %rsi      # 0x73dc
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x5c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1221(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x11e0(%rip), %rsi      # 0x73e0
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x64(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1181(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x1144(%rip), %rsi      # 0x73e4
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x6c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10e1(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x10a8(%rip), %rsi      # 0x73e8
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x74(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1041(%rip), %rsi      # 0x73c9
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 0x65fe
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 0x100c(%rip), %rsi      # 0x73ec
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x7c(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0xfa1(%rip), %rsi       # 0x73c9
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 0x65fe
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 0xf6d(%rip), %rsi       # 0x73f0
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x84(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0xefb(%rip), %rsi       # 0x73c9
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 0x65fe
imulq $0x98, %rsi, %rcx
movl 0x88(%rax,%rcx), %esi
movq %r13, %rdi
callq 0x2270
movq %rax, %r13
movl $0x3, %edx
movq %rax, %rdi
leaq 0xedb(%rip), %rsi       # 0x73f4
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), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r14, %rdx
cmpq %rsi, %rdx
jbe 0x65fe
imulq $0x98, %rsi, %rdi
movslq 0x2c(%rcx,%rdi), %rsi
cmpq $-0x1, %rsi
je 0x65ab
leaq 0x3e43(%rip), %rax      # 0xa3c0
movq (%rax), %r8
movq 0x8(%rax), %rax
subq %r8, %rax
sarq $0x3, %rax
cmpq %rsi, %rax
jbe 0x660c
addq %rcx, %rdi
movl 0x30(%rdi), %eax
cmpl 0x4(%r8,%rsi,8), %eax
jne 0x65ab
movb $0x0, (%r8,%rsi,8)
movl $0xffffffff, 0x4(%r8,%rsi,8) # imm = 0xFFFFFFFF
movl (%r15), %esi
cmpq %rsi, %rdx
jbe 0x65fe
imulq $0x98, %rsi, %rax
movb $0x0, (%rcx,%rax)
movq $0x0, 0x20(%rcx,%rax)
leal 0x1(%rsi), %eax
leaq 0x3bab(%rip), %rcx      # 0xa17c
cmpl (%rcx), %eax
movl $0x0, %ecx
cmovel %ecx, %eax
movl %eax, (%r15)
leaq 0x3b9f(%rip), %rdi      # 0xa184
incl %ebp
cmpl (%rdi), %ebp
jb 0x5d91
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcf1(%rip), %rdi       # 0x72f6
xorl %eax, %eax
callq 0x21d0
leaq 0xce3(%rip), %rdi       # 0x72f6
movq %rax, %rdx
jmp 0x6605