// File: /workspace/github_cpp_makefile_star2_O1/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::execute_instruction()
void O3_CPU::execute_instruction()
{
    if ((ROB.head == ROB.tail) && ROB.occupancy == 0)
        return;

    // out-of-order execution for non-memory instructions
    // memory instructions are handled by memory_instruction()
    uint32_t exec_issued = 0, num_iteration = 0;

    while (exec_issued < EXEC_WIDTH) {
        if (RTE0[RTE0_head] < ROB_SIZE) {
            uint32_t exec_index = RTE0[RTE0_head];
            if (ROB.entry[exec_index].event_cycle <= current_core_cycle[cpu]) {
                do_execution(exec_index);

                RTE0[RTE0_head] = ROB_SIZE;
                RTE0_head++;
                if (RTE0_head == ROB_SIZE)
                    RTE0_head = 0;
                exec_issued++;
            }
        }
        else {
            //DP (if (warmup_complete[cpu]) {
            //cout << "[RTE0] is empty head: " << RTE0_head << " tail: " << RTE0_tail << endl; });
            break;
        }

        num_iteration++;
        if (num_iteration == (ROB_SIZE-1))
            break;
    }

    num_iteration = 0;
    while (exec_issued < EXEC_WIDTH) {
        if (RTE1[RTE1_head] < ROB_SIZE) {
            uint32_t exec_index = RTE1[RTE1_head];
            if (ROB.entry[exec_index].event_cycle <= current_core_cycle[cpu]) {
                do_execution(exec_index);

                RTE1[RTE1_head] = ROB_SIZE;
                RTE1_head++;
                if (RTE1_head == ROB_SIZE)
                    RTE1_head = 0;
                exec_issued++;
            }
        }
        else {
            //DP (if (warmup_complete[cpu]) {
            //cout << "[RTE1] is empty head: " << RTE1_head << " tail: " << RTE1_tail << endl; });
            break;
        }

        num_iteration++;
        if (num_iteration == (ROB_SIZE-1))
            break;
    }
}

// Assembly:
movl 0x958(%rdi), %eax
cmpl 0x95c(%rdi), %eax
jne 0xd9ca
cmpl $0x0, 0x960(%rdi)
jne 0xd9ca
retq
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x9b8(%rdi), %rdx
movl (%rdi), %esi
movl 0x920(%rdi), %r8d
xorl %r9d, %r9d
movl $0xfe, %r10d
leaq 0x734cf(%rip), %rax     # 0x80ec0
movl $0x100, %r11d           # imm = 0x100
xorl %ecx, %ecx
movl 0x2e40(%rdi), %ebx
movl 0x2a40(%rdi,%rbx,4), %r14d
cmpq $0xff, %r14
ja 0xda72
imulq $0x758, %r14, %r15      # imm = 0x758
movq (%rax,%rsi,8), %r14
cmpq %r14, 0x40(%rdx,%r15)
ja 0xda67
addq %rdx, %r15
addq $0x40, %r15
movl $0x1, 0x38(%r15)
movl 0x7349c(%rip), %r12d    # 0x80ed4
addq %r12, %r14
movq %r14, (%r15)
incl %r8d
movl %r8d, 0x920(%rdi)
movl %r11d, 0x2a40(%rdi,%rbx,4)
movl 0x2e40(%rdi), %ebx
incl %ebx
cmpl %r11d, %ebx
cmovel %r9d, %ebx
movl %ebx, 0x2e40(%rdi)
incl %ecx
addl $-0x1, %r10d
jae 0xda72
cmpl $0x6, %ecx
jb 0xd9f9
cmpl $0x5, %ecx
ja 0xdb13
movq 0x9b8(%rdi), %rdx
movl (%rdi), %esi
movl 0x920(%rdi), %r8d
movl $0xfe, %r9d
movl $0x100, %r10d           # imm = 0x100
xorl %r11d, %r11d
movl 0x3248(%rdi), %ebx
movl 0x2e48(%rdi,%rbx,4), %r14d
cmpq $0xff, %r14
ja 0xdb13
imulq $0x758, %r14, %r15      # imm = 0x758
movq (%rax,%rsi,8), %r14
cmpq %r14, 0x40(%rdx,%r15)
ja 0xdb08
addq %rdx, %r15
addq $0x40, %r15
movl $0x1, 0x38(%r15)
movl 0x733fb(%rip), %r12d    # 0x80ed4
addq %r12, %r14
movq %r14, (%r15)
incl %r8d
movl %r8d, 0x920(%rdi)
movl %r10d, 0x2e48(%rdi,%rbx,4)
movl 0x3248(%rdi), %ebx
incl %ebx
cmpl %r10d, %ebx
cmovel %r11d, %ebx
movl %ebx, 0x3248(%rdi)
incl %ecx
addl $-0x1, %r9d
jae 0xdb13
cmpl $0x6, %ecx
jb 0xda9a
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop