// File: /workspace/github_cpp_makefile_star2_O1/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::check_rob(unsigned long)
uint32_t O3_CPU::check_rob(uint64_t instr_id)
{
    if ((ROB.head == ROB.tail) && ROB.occupancy == 0)
        return ROB.SIZE;

    if (ROB.head < ROB.tail) {
        for (uint32_t i=ROB.head; i<ROB.tail; i++) {
            if (ROB.entry[i].instr_id == instr_id) {
                DP ( if (warmup_complete[ROB.cpu]) {
                cout << "[ROB] " << __func__ << " same instr_id: " << ROB.entry[i].instr_id;
                cout << " rob_index: " << i << endl; });
                return i;
            }
        }
    }
    else {
        for (uint32_t i=ROB.head; i<ROB.SIZE; i++) {
            if (ROB.entry[i].instr_id == instr_id) {
                DP ( if (warmup_complete[cpu]) {
                cout << "[ROB] " << __func__ << " same instr_id: " << ROB.entry[i].instr_id;
                cout << " rob_index: " << i << endl; });
                return i;
            }
        }
        for (uint32_t i=0; i<ROB.tail; i++) {
            if (ROB.entry[i].instr_id == instr_id) {
                DP ( if (warmup_complete[cpu]) {
                cout << "[ROB] " << __func__ << " same instr_id: " << ROB.entry[i].instr_id;
                cout << " rob_index: " << i << endl; });
                return i;
            }
        }
    }

    cerr << "[ROB_ERROR] " << __func__ << " does not have any matching index! ";
    cerr << " instr_id: " << instr_id << endl;
    assert(0);

    return ROB.SIZE;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl 0x958(%rdi), %ecx
movl 0x95c(%rdi), %edx
cmpl %edx, %ecx
jne 0xce57
cmpl $0x0, 0x960(%rdi)
jne 0xce57
movl 0x950(%rdi), %eax
jmp 0xcf55
cmpl %edx, %ecx
jae 0xceae
movq 0x9b8(%rdi), %rdi
imulq $0x758, %rcx, %rax      # imm = 0x758
movb $0x1, %sil
cmpq %rbx, (%rdi,%rax)
je 0xce9e
addq $0x758, %rdi            # imm = 0x758
addq %rdi, %rax
leal -0x1(%rdx), %esi
cmpl %ecx, %esi
je 0xcf5d
leaq 0x758(%rax), %rdi
incl %ecx
cmpq %rbx, (%rax)
movq %rdi, %rax
jne 0xce7f
cmpl %edx, %ecx
setb %sil
movl %ecx, %eax
testb %sil, %sil
jne 0xcf55
jmp 0xcf5d
movl 0x950(%rdi), %eax
cmpl %eax, %ecx
setb %r8b
jae 0xcf0a
movq 0x9b8(%rdi), %r9
imulq $0x758, %rcx, %rsi      # imm = 0x758
cmpq %rbx, (%r9,%rsi)
je 0xceff
negl %ecx
addq $0x758, %r9             # imm = 0x758
addq %r9, %rsi
leal (%rax,%rcx), %r8d
cmpl $0x1, %r8d
je 0xcf08
decl %ecx
leaq 0x758(%rsi), %r8
cmpq %rbx, (%rsi)
movq %r8, %rsi
jne 0xcedc
negl %ecx
cmpl %eax, %ecx
setb %r8b
movl %ecx, %eax
testb %r8b, %r8b
je 0xcf0a
jmp 0xcf55
movl %eax, %ecx
testl %edx, %edx
setne %r8b
je 0xcf4e
movq 0x9b8(%rdi), %rsi
xorl %eax, %eax
cmpq %rbx, (%rsi)
je 0xcf50
addq $0x758, %rsi            # imm = 0x758
movl $0x1, %edi
movl %edi, %eax
cmpl %edi, %edx
je 0xcf48
leal 0x1(%rax), %edi
leaq 0x758(%rsi), %r8
cmpq %rbx, (%rsi)
movq %r8, %rsi
jne 0xcf2c
decl %edi
movl %edi, %ecx
cmpl %edx, %eax
setb %r8b
movl %ecx, %eax
testb %r8b, %r8b
je 0xcf5d
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0xd08c(%rip), %r14      # 0x19ff0
leaq 0x7d77(%rip), %rsi      # 0x14ce2
movq %r14, %rdi
callq 0x3250
leaq 0x7daf(%rip), %rsi      # 0x14d29
movq %rax, %rdi
callq 0x3250
leaq 0x7daa(%rip), %rsi      # 0x14d33
movq %rax, %rdi
callq 0x3250
leaq 0x7f88(%rip), %rsi      # 0x14f20
movq %r14, %rdi
callq 0x3250
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3090
movq %rax, %rdi
callq 0x3110
leaq 0x70ad(%rip), %rdi      # 0x14067
leaq 0x7cf5(%rip), %rsi      # 0x14cb6
leaq 0x7d8f(%rip), %rcx      # 0x14d57
movl $0x164, %edx            # imm = 0x164
callq 0x3160