LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/dram_controller.cc
// Function: MEMORY_CONTROLLER::get_size(unsigned char)
uint32_t MEMORY_CONTROLLER::get_size(uint8_t queue_type)
{
    if (queue_type == 1)
        return RQ.SIZE;
    else if (queue_type == 2)
        return WQ.SIZE;

    return 0;
}

// Assembly:
cmpl $0x2, %esi
je 0xc239
xorl %eax, %eax
cmpl $0x1, %esi
jne 0xc23f
movl 0x9f18(%rdi), %eax
retq
movl 0x8278(%rdi), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/block.cc
// Function: PACKET_QUEUE::add_queue(PACKET*)
void PACKET_QUEUE::add_queue(PACKET *packet)
{
#ifdef SANITY_CHECK
    if (occupancy && (head == tail))
        assert(0);
#endif

    // add entry
    memcpy(&entry[tail], packet, sizeof(PACKET));

    DP ( if (warmup_complete[packet->cpu]) {
    cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu << " instr_id: " << packet->instr_id;
    cout << " address: " << hex << entry[tail].address << " full_addr: " << entry[tail].full_addr << dec;
    cout << " head: " << head << " tail: " << tail << " occupancy: " << occupancy << " event_cycle: " << entry[tail].event_cycle << endl; });

    occupancy++;
    tail++;
    if (tail >= SIZE)
        tail = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x34(%rdi)
je 0xc3e7
movl 0x30(%rbx), %eax
cmpl %eax, 0x2c(%rbx)
jne 0xc3ea
leaq 0x7c98(%rip), %rdi      # 0x14067
leaq 0x87be(%rip), %rsi      # 0x14b94
leaq 0x87c4(%rip), %rcx      # 0x14ba1
movl $0x50, %edx
callq 0x3160
movl 0x30(%rbx), %eax
movl %eax, %eax
imulq $0x380, %rax, %rdi      # imm = 0x380
addq 0x98(%rbx), %rdi
movl $0x380, %edx            # imm = 0x380
callq 0x31c0
incl 0x34(%rbx)
movl 0x30(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl 0x20(%rbx), %eax
cmovbl %eax, %ecx
movl %ecx, 0x30(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/block.cc
// Function: PACKET_QUEUE::remove_queue(PACKET*)
void PACKET_QUEUE::remove_queue(PACKET *packet)
{
#ifdef SANITY_CHECK
    if ((occupancy == 0) && (head == tail))
        assert(0);
#endif

    DP ( if (warmup_complete[packet->cpu]) {
    cout << "[" << NAME << "] " << __func__ << " cpu: " << packet->cpu << " instr_id: " << packet->instr_id;
    cout << " address: " << hex << packet->address << " full_addr: " << packet->full_addr << dec << " fill_level: " << packet->fill_level;
    cout << " head: " << head << " tail: " << tail << " occupancy: " << occupancy << " event_cycle: " << packet->event_cycle << endl; });

    // reset entry
    PACKET empty_packet;
    memcpy(packet, &empty_packet, sizeof(PACKET));

    occupancy--;
    head++;
    if (head >= SIZE)
        head = 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x350, %rsp            # imm = 0x350
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x34(%rdi)
jne 0xc43d
movl 0x2c(%rbx), %eax
cmpl 0x30(%rbx), %eax
je 0xc4f3
xorl %ebp, %ebp
leaq 0x38(%rsp), %rdi
movl %ebp, -0x18(%rdi)
movl %ebp, -0x15(%rdi)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, -0x10(%rdi)
movl $0x314, %edx            # imm = 0x314
xorl %esi, %esi
callq 0x3130
pxor %xmm0, %xmm0
movdqu %xmm0, 0x8(%rsp)
movq $0x0, 0x18(%rsp)
leaq 0x20(%rsp), %rsi
movl $0x32c, %edx            # imm = 0x32C
movq %r14, %rdi
callq 0x31c0
movabsq $0x100ffff00, %rax      # imm = 0x100FFFF00
movq %rax, 0x32c(%r14)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x334(%r14)
movdqu %xmm0, 0x344(%r14)
movl %ebp, 0x354(%r14)
movups (%rsp), %xmm0
movups 0x10(%rsp), %xmm1
movups %xmm0, 0x358(%r14)
movups %xmm1, 0x368(%r14)
movq $-0x1, 0x378(%r14)
decl 0x34(%rbx)
movl 0x2c(%rbx), %eax
incl %eax
cmpl 0x20(%rbx), %eax
cmovael %ebp, %eax
movl %eax, 0x2c(%rbx)
addq $0x350, %rsp            # imm = 0x350
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x7b6d(%rip), %rdi      # 0x14067
leaq 0x8693(%rip), %rsi      # 0x14b94
leaq 0x86c0(%rip), %rcx      # 0x14bc8
movl $0x65, %edx
callq 0x3160
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::add_to_rob(ooo_model_instr*)
uint32_t O3_CPU::add_to_rob(ooo_model_instr *arch_instr)
{
    uint32_t index = ROB.tail;

    // sanity check
    if (ROB.entry[index].instr_id != 0) {
        cerr << "[ROB_ERROR] " << __func__ << " is not empty index: " << index;
        cerr << " instr_id: " << ROB.entry[index].instr_id << endl;
        assert(0);
    }

    memcpy (&ROB.entry[index], arch_instr, sizeof(ooo_model_instr));
    ROB.entry[index].event_cycle = current_core_cycle[cpu];

    ROB.occupancy++;
    ROB.tail++;
    if (ROB.tail >= ROB.SIZE)
        ROB.tail = 0;

    DP ( if (warmup_complete[cpu]) {
    cout << "[ROB] " <<  __func__ << " instr_id: " << ROB.entry[index].instr_id;
    cout << " ip: " << hex << ROB.entry[index].ip << dec;
    cout << " head: " << ROB.head << " tail: " << ROB.tail << " occupancy: " << ROB.occupancy;
    cout << " event: " << ROB.entry[index].event_cycle << " current: " << current_core_cycle[cpu] << endl; });

    return index;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x95c(%rdi), %r14d
movq 0x9b8(%rdi), %rdi
imulq $0x758, %r14, %r12      # imm = 0x758
cmpq $0x0, (%rdi,%r12)
jne 0xcd97
addq %r12, %rdi
movl $0x758, %edx            # imm = 0x758
callq 0x31c0
movl (%rbx), %eax
leaq 0x74167(%rip), %rcx     # 0x80ec0
movq (%rcx,%rax,8), %rax
movq 0x9b8(%rbx), %rcx
movq %rax, 0x40(%rcx,%r12)
incl 0x960(%rbx)
movl 0x95c(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl 0x950(%rbx), %eax
cmovbl %eax, %ecx
movl %ecx, 0x95c(%rbx)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xd252(%rip), %r15      # 0x19ff0
leaq 0x7f6d(%rip), %rsi      # 0x14d12
movq %r15, %rdi
callq 0x3250
leaq 0x7f6b(%rip), %rsi      # 0x14d1f
movq %rax, %rdi
callq 0x3250
leaq 0x7470(%rip), %rsi      # 0x14233
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
movl %r14d, %esi
callq 0x32d0
leaq 0x8173(%rip), %rsi      # 0x14f50
movq %r15, %rdi
callq 0x3250
movq 0x9b8(%rbx), %rcx
movq (%rcx,%r12), %rsi
movq %rax, %rdi
callq 0x3090
movq %rax, %rdi
callq 0x3110
leaq 0x7260(%rip), %rdi      # 0x14067
leaq 0x7ed8(%rip), %rsi      # 0x14ce6
leaq 0x7f15(%rip), %rcx      # 0x14d2a
movl $0x12c, %edx            # imm = 0x12C
callq 0x3160
nop
// File: /workspace/github_cpp_makefile_star2_O3/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), %eax
movl 0x95c(%rdi), %ecx
cmpl %ecx, %eax
jne 0xce4e
cmpl $0x0, 0x960(%rdi)
jne 0xce4e
movl 0x950(%rdi), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpl %ecx, %eax
jae 0xce74
imulq $0x758, %rax, %rdx      # imm = 0x758
addq 0x9b8(%rdi), %rdx
cmpq %rbx, (%rdx)
je 0xce46
incl %eax
addq $0x758, %rdx            # imm = 0x758
cmpl %eax, %ecx
jne 0xce60
jmp 0xcebd
movl 0x950(%rdi), %edx
cmpl %edx, %eax
jae 0xce9e
imulq $0x758, %rax, %rsi      # imm = 0x758
addq 0x9b8(%rdi), %rsi
cmpq %rbx, (%rsi)
je 0xce46
incl %eax
addq $0x758, %rsi            # imm = 0x758
cmpl %eax, %edx
jne 0xce8c
testl %ecx, %ecx
je 0xcebd
movq 0x9b8(%rdi), %rdx
xorl %eax, %eax
cmpq %rbx, (%rdx)
je 0xce46
incl %eax
addq $0x758, %rdx            # imm = 0x758
cmpl %eax, %ecx
jne 0xceab
movq 0xd12c(%rip), %r14      # 0x19ff0
leaq 0x7e47(%rip), %rsi      # 0x14d12
movq %r14, %rdi
callq 0x3250
leaq 0x7e7f(%rip), %rsi      # 0x14d59
movq %rax, %rdi
callq 0x3250
leaq 0x7e7a(%rip), %rsi      # 0x14d63
movq %rax, %rdi
callq 0x3250
leaq 0x8058(%rip), %rsi      # 0x14f50
movq %r14, %rdi
callq 0x3250
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3090
movq %rax, %rdi
callq 0x3110
leaq 0x714d(%rip), %rdi      # 0x14067
leaq 0x7dc5(%rip), %rsi      # 0x14ce6
leaq 0x7e5f(%rip), %rcx      # 0x14d87
movl $0x164, %edx            # imm = 0x164
callq 0x3160
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::do_scheduling(unsigned int)
void O3_CPU::do_scheduling(uint32_t rob_index)
{
    ROB.entry[rob_index].reg_ready = 1; // reg_ready will be reset to 0 if there is RAW dependency 

    reg_dependency(rob_index);
    ROB.next_schedule = (rob_index == (ROB.SIZE - 1)) ? 0 : (rob_index + 1);

    if (ROB.entry[rob_index].is_memory)
        ROB.entry[rob_index].scheduled = INFLIGHT;
    else {
        ROB.entry[rob_index].scheduled = COMPLETED;

        // ADD LATENCY
        if (ROB.entry[rob_index].event_cycle < current_core_cycle[cpu])
            ROB.entry[rob_index].event_cycle = current_core_cycle[cpu] + SCHEDULING_LATENCY;
        else
            ROB.entry[rob_index].event_cycle += SCHEDULING_LATENCY;

        if (ROB.entry[rob_index].reg_ready) {

#ifdef SANITY_CHECK
            if (RTE1[RTE1_tail] < ROB_SIZE)
                assert(0);
#endif
            // remember this rob_index in the Ready-To-Execute array 1
            RTE1[RTE1_tail] = rob_index;

            DP (if (warmup_complete[cpu]) {
            cout << "[RTE1] " << __func__ << " instr_id: " << ROB.entry[rob_index].instr_id << " rob_index: " << rob_index << " is added to RTE1";
            cout << " head: " << RTE1_head << " tail: " << RTE1_tail << endl; }); 

            RTE1_tail++;
            if (RTE1_tail == ROB_SIZE)
                RTE1_tail = 0;
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x9b8(%rdi), %rax
movl %esi, %ecx
imulq $0x758, %rcx, %r15      # imm = 0x758
movb $0x1, 0x59(%rax,%r15)
callq 0xd6a8
movl 0x950(%rbx), %eax
decl %eax
leal 0x1(%r14), %ecx
xorl %edx, %edx
cmpl %r14d, %eax
cmovnel %ecx, %edx
movl %edx, 0x980(%rbx)
movq 0x9b8(%rbx), %rax
leaq (%rax,%r15), %rcx
cmpb $0x0, 0x49(%rax,%r15)
je 0xd61a
movl $0x1, 0x68(%rcx)
jmp 0xd683
movl $0x2, 0x68(%rcx)
movq 0x40(%rax,%r15), %rcx
movl (%rbx), %edx
leaq 0x73891(%rip), %rsi     # 0x80ec0
movq (%rsi,%rdx,8), %rdx
movl 0x73897(%rip), %esi     # 0x80ed0
cmpq %rdx, %rcx
cmovaq %rcx, %rdx
addq %rsi, %rdx
movq %rdx, 0x40(%rax,%r15)
cmpb $0x0, 0x59(%rax,%r15)
je 0xd683
movl 0x324c(%rbx), %eax
cmpl $0xff, 0x2e48(%rbx,%rax,4)
jbe 0xd689
movl %r14d, 0x2e48(%rbx,%rax,4)
movl 0x324c(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl $0x100, %eax            # imm = 0x100
cmovnel %eax, %ecx
movl %ecx, 0x324c(%rbx)
popq %rbx
popq %r14
popq %r15
retq
leaq 0x69d7(%rip), %rdi      # 0x14067
leaq 0x764f(%rip), %rsi      # 0x14ce6
leaq 0x7762(%rip), %rcx      # 0x14e00
movl $0x22a, %edx            # imm = 0x22A
callq 0x3160
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::do_memory_scheduling(unsigned int)
void O3_CPU::do_memory_scheduling(uint32_t rob_index)
{
    uint32_t not_available = check_and_add_lsq(rob_index);
    if (not_available == 0) {
        ROB.entry[rob_index].scheduled = COMPLETED;
        if (ROB.entry[rob_index].executed == 0) // it could be already set to COMPLETED due to store-to-load forwarding
            ROB.entry[rob_index].executed  = INFLIGHT;

        DP (if (warmup_complete[cpu]) {
        cout << "[ROB] " << __func__ << " instr_id: " << ROB.entry[rob_index].instr_id << " rob_index: " << rob_index;
        cout << " scheduled all num_mem_ops: " << ROB.entry[rob_index].num_mem_ops << endl; });
    }

    num_searched++;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
callq 0xe1c4
testl %eax, %eax
jne 0xdc81
movq 0x9b8(%rbx), %rax
movl %ebp, %ecx
imulq $0x758, %rcx, %rcx      # imm = 0x758
movl $0x2, 0x68(%rax,%rcx)
cmpl $0x0, 0x78(%rax,%rcx)
jne 0xdc81
addq %rcx, %rax
addq $0x78, %rax
movl $0x1, (%rax)
incl 0x928(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::operate_cache()
void O3_CPU::operate_cache()
{
    ITLB.operate();
    DTLB.operate();
    STLB.operate();
    L1I.operate();
    L1D.operate();
    L2C.operate();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x3690, %rdi           # imm = 0x3690
callq 0x58e2
leaq 0x13a38(%rbx), %rdi
callq 0x58e2
leaq 0x23de0(%rbx), %rdi
callq 0x58e2
leaq 0x34188(%rbx), %rdi
callq 0x58e2
leaq 0x44530(%rbx), %rdi
callq 0x58e2
addq $0x548d8, %rbx          # imm = 0x548D8
movq %rbx, %rdi
popq %rbx
jmp 0x58e2
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::mem_RAW_dependency(unsigned int, unsigned int, unsigned int, unsigned int)
void O3_CPU::mem_RAW_dependency(uint32_t prior, uint32_t current, uint32_t data_index, uint32_t lq_index)
{
    for (uint32_t i=0; i<MAX_INSTR_DESTINATIONS; i++) {
        if (ROB.entry[prior].destination_memory[i] == 0)
            continue;

        if (ROB.entry[prior].destination_memory[i] == ROB.entry[current].source_memory[data_index]) { //  store-to-load forwarding check

            // we need to mark this dependency in the ROB since the producer might not be added in the store queue yet
            ROB.entry[prior].memory_instrs_depend_on_me[current] = 1;   // this load cannot be executed until the prior store gets executed
            ROB.entry[prior].is_producer = 1;
            LQ.entry[lq_index].producer_id = ROB.entry[prior].instr_id; 
            LQ.entry[lq_index].translated = INFLIGHT;

            DP (if(warmup_complete[cpu]) {
            cout << "[LQ] " << __func__ << " RAW producer instr_id: " << ROB.entry[prior].instr_id << " consumer_id: " << ROB.entry[current].instr_id << " lq_index: " << lq_index;
            cout << hex << " address: " << ROB.entry[prior].destination_memory[i] << dec << endl; });

            return;
        }
    }
}

// Assembly:
leaq 0xb949(%rip), %rax      # 0x1a210
movzbl (%rax), %eax
testq %rax, %rax
je 0xe919
movq 0x9b8(%rdi), %r10
movl %esi, %esi
imulq $0x758, %rsi, %rsi      # imm = 0x758
leaq (%r10,%rsi), %r9
movl %edx, %edx
movl %ecx, %ecx
imulq $0x758, %rdx, %r11      # imm = 0x758
addq %r10, %r11
leaq (%r11,%rcx,8), %rcx
addq $0x5c8, %rcx            # imm = 0x5C8
xorl %r10d, %r10d
movq 0x5a8(%r9,%r10,8), %r11
testq %r11, %r11
je 0xe911
cmpq (%rcx), %r11
je 0xe91a
incq %r10
cmpq %r10, %rax
jne 0xe8ff
retq
movb $0x1, %al
movb %al, 0x628(%r9,%rdx)
movq 0x9b8(%rdi), %rcx
movb %al, 0x56(%rcx,%rsi)
movq (%rcx,%rsi), %rcx
movq 0x9f0(%rdi), %rdx
movl %r8d, %esi
leaq (%rsi,%rsi,4), %rsi
shlq $0x6, %rsi
movq %rcx, 0x8(%rdx,%rsi)
movb %al, 0x3c(%rdx,%rsi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::execute_load(unsigned int, unsigned int, unsigned int)
int O3_CPU::execute_load(uint32_t rob_index, uint32_t lq_index, uint32_t data_index)
{
    // add it to L1D
    PACKET data_packet;
    data_packet.fill_level = FILL_L1;
    data_packet.cpu = cpu;
    data_packet.data_index = LQ.entry[lq_index].data_index;
    data_packet.lq_index = lq_index;
    data_packet.address = LQ.entry[lq_index].physical_address >> LOG2_BLOCK_SIZE;
    data_packet.full_addr = LQ.entry[lq_index].physical_address;
    data_packet.instr_id = LQ.entry[lq_index].instr_id;
    data_packet.rob_index = LQ.entry[lq_index].rob_index;
    data_packet.ip = LQ.entry[lq_index].ip;
    data_packet.type = LOAD;
    data_packet.asid[0] = LQ.entry[lq_index].asid[0];
    data_packet.asid[1] = LQ.entry[lq_index].asid[1];
    data_packet.event_cycle = LQ.entry[lq_index].event_cycle;

    int rq_index = L1D.add_rq(&data_packet);

    if (rq_index == -2)
        return rq_index;
    else 
        LQ.entry[lq_index].fetched = INFLIGHT;

    return rq_index;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x380, %rsp            # imm = 0x380
movl %edx, %ebp
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x18(%rsp), %r14
movb %r15b, 0x314(%r14)
movl %r15d, -0x18(%r14)
movl %r15d, -0x15(%r14)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, -0x10(%r14)
movl $0x314, %edx            # imm = 0x314
movq %r14, %rdi
xorl %esi, %esi
callq 0x3130
pxor %xmm0, %xmm0
movdqu %xmm0, 0x324(%r14)
movdqu %xmm0, 0x330(%r14)
movq $0x0, 0x348(%r14)
movl $0x1, -0x10(%r14)
movl (%rbx), %eax
movl %eax, 0x318(%r14)
movq 0x9f0(%rbx), %rax
movl %ebp, %ecx
leaq (%rcx,%rcx,4), %r12
shlq $0x6, %r12
movl 0x34(%rax,%r12), %ecx
movl %ecx, 0x31c(%r14)
movl %ebp, 0x320(%r14)
movq 0x18(%rax,%r12), %rcx
movq %rcx, %rdx
shrq $0x6, %rdx
movq %rdx, 0x328(%r14)
movq %rcx, 0x330(%r14)
movq (%rax,%r12), %rcx
movq %rcx, 0x350(%r14)
movl 0x30(%rax,%r12), %ecx
movl %ecx, -0x8(%r14)
movq 0x20(%rax,%r12), %rcx
movq %rcx, 0x358(%r14)
movb %r15b, 0x317(%r14)
movb 0x3e(%rax,%r12), %cl
movb %cl, 0x315(%r14)
movb 0x3f(%rax,%r12), %cl
movb %cl, 0x316(%r14)
movq 0x28(%rax,%r12), %rax
movq %rax, 0x360(%r14)
leaq 0x44530(%rbx), %rdi
movq %rsp, %rsi
callq 0x5ab4
cmpl $-0x2, %eax
je 0xee42
movq 0x9f0(%rbx), %rcx
movb $0x1, 0x3d(%rcx,%r12)
addq $0x380, %rsp            # imm = 0x380
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::complete_execution(unsigned int)
void O3_CPU::complete_execution(uint32_t rob_index)
{
    if (ROB.entry[rob_index].is_memory == 0) {
        if ((ROB.entry[rob_index].executed == INFLIGHT) && (ROB.entry[rob_index].event_cycle <= current_core_cycle[cpu])) {

            ROB.entry[rob_index].executed = COMPLETED; 
            inflight_reg_executions--;
            completed_executions++;

            if (ROB.entry[rob_index].reg_RAW_producer)
                reg_RAW_release(rob_index);

            if (ROB.entry[rob_index].branch_mispredicted) 
                fetch_stall = 0;

            DP(if(warmup_complete[cpu]) {
            cout << "[ROB] " << __func__ << " instr_id: " << ROB.entry[rob_index].instr_id;
            cout << " branch_mispredicted: " << +ROB.entry[rob_index].branch_mispredicted << " fetch_stall: " << +fetch_stall;
            cout << " event: " << ROB.entry[rob_index].event_cycle << endl; });
        }
    }
    else {
        if (ROB.entry[rob_index].num_mem_ops == 0) {
            if ((ROB.entry[rob_index].executed == INFLIGHT) && (ROB.entry[rob_index].event_cycle <= current_core_cycle[cpu])) {
                ROB.entry[rob_index].executed = COMPLETED;
                inflight_mem_executions--;
                completed_executions++;
                
                if (ROB.entry[rob_index].reg_RAW_producer)
                    reg_RAW_release(rob_index);

                if (ROB.entry[rob_index].branch_mispredicted) 
                    fetch_stall = 0;

                DP(if(warmup_complete[cpu]) {
                cout << "[ROB] " << __func__ << " instr_id: " << ROB.entry[rob_index].instr_id;
                cout << " is_memory: " << +ROB.entry[rob_index].is_memory << " branch_mispredicted: " << +ROB.entry[rob_index].branch_mispredicted;
                cout << " fetch_stall: " << +fetch_stall << " event: " << ROB.entry[rob_index].event_cycle << " current: " << current_core_cycle[cpu] << endl; });
            }
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x9b8(%rdi), %rax
movl %esi, %ecx
imulq $0x758, %rcx, %r14      # imm = 0x758
leaq (%rax,%r14), %rcx
cmpb $0x0, 0x49(%rax,%r14)
je 0xeea3
cmpl $0x0, 0x70(%rcx)
jne 0xeef6
cmpl $0x1, 0x78(%rcx)
jne 0xeef6
movq 0x40(%rcx), %rdx
movl (%rbx), %edi
leaq 0x72032(%rip), %r8      # 0x80ec0
cmpq (%r8,%rdi,8), %rdx
ja 0xeef6
movl $0x2, 0x78(%rcx)
decl 0x924(%rbx)
jmp 0xeec9
cmpl $0x1, 0x78(%rcx)
jne 0xeef6
movq 0x40(%rcx), %rdx
movl (%rbx), %edi
leaq 0x7200a(%rip), %r8      # 0x80ec0
cmpq (%r8,%rdi,8), %rdx
ja 0xeef6
movl $0x2, 0x78(%rcx)
decl 0x920(%rbx)
incq 0x8b8(%rbx)
cmpb $0x0, 0x58(%rax,%r14)
je 0xeee7
movq %rbx, %rdi
callq 0xeefe
movq 0x9b8(%rbx), %rax
cmpb $0x0, 0x4b(%rax,%r14)
je 0xeef6
movb $0x0, 0x3678(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/ooo_cpu.cc
// Function: O3_CPU::reg_RAW_release(unsigned int)
void O3_CPU::reg_RAW_release(uint32_t rob_index)
{
    for (uint32_t i=0; i<ROB.SIZE; i++) {
        if (ROB.entry[rob_index].registers_instrs_depend_on_me[i]) {
            for (uint32_t j=0; j<NUM_INSTR_SOURCES; j++) {
                if (ROB.entry[rob_index].registers_index_depend_on_me[i][j]) {
                    ROB.entry[i].num_reg_dependent--;

                    if (ROB.entry[i].num_reg_dependent == 0) {
                        ROB.entry[i].reg_ready = 1;
                        if (ROB.entry[i].is_memory)
                            ROB.entry[i].scheduled = INFLIGHT;
                        else {
                            ROB.entry[i].scheduled = COMPLETED;

#ifdef SANITY_CHECK
                            if (RTE0[RTE0_tail] < ROB_SIZE)
                                assert(0);
#endif
                            // remember this rob_index in the Ready-To-Execute array 0
                            RTE0[RTE0_tail] = i;

                            DP (if (warmup_complete[cpu]) {
                            cout << "[RTE0] " << __func__ << " instr_id: " << ROB.entry[i].instr_id << " rob_index: " << i << " is added to RTE0";
                            cout << " head: " << RTE0_head << " tail: " << RTE0_tail << endl; }); 

                            RTE0_tail++;
                            if (RTE0_tail == ROB_SIZE)
                                RTE0_tail = 0;

                        }
                    }

                    DP (if (warmup_complete[cpu]) {
                    cout << "[ROB] " << __func__ << " instr_id: " << ROB.entry[rob_index].instr_id << " releases instr_id: ";
                    cout << ROB.entry[i].instr_id << " reg_index: " << +ROB.entry[i].source_registers[j] << " num_reg_dependent: " << ROB.entry[i].num_reg_dependent << " cycle: " << current_core_cycle[cpu] << endl; });
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl 0x950(%rdi), %eax
testq %rax, %rax
je 0xefcb
movq 0x9b8(%rdi), %rcx
movl %esi, %edx
imulq $0x758, %rdx, %rdx      # imm = 0x758
leaq (%rdx,%rcx), %rsi
addq $0x184, %rsi            # imm = 0x184
xorl %r8d, %r8d
addq %rcx, %rdx
xorl %r9d, %r9d
cmpb $0x0, 0x84(%r9,%rdx)
je 0xefbb
imulq $0x758, %r9, %r10       # imm = 0x758
leaq (%rcx,%r10), %r11
addq $0x74, %r11
addq %rcx, %r10
xorl %ebx, %ebx
cmpb $0x0, (%rsi,%rbx)
je 0xefb2
decl (%r11)
jne 0xefb2
movb $0x1, 0x59(%r10)
cmpb $0x0, 0x49(%r10)
je 0xef75
movl $0x1, 0x68(%r10)
jmp 0xefb2
movl $0x2, 0x68(%r10)
movl 0x2e44(%rdi), %r14d
cmpl $0xff, 0x2a40(%rdi,%r14,4)
jbe 0xefd0
movl %r9d, 0x2a40(%rdi,%r14,4)
movl 0x2e44(%rdi), %ebp
incl %ebp
cmpl $0x100, %ebp            # imm = 0x100
cmovel %r8d, %ebp
movl %ebp, 0x2e44(%rdi)
incq %rbx
cmpq $0x4, %rbx
jne 0xef54
incq %r9
addq $0x4, %rsi
cmpq %rax, %r9
jne 0xef35
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x5090(%rip), %rdi      # 0x14067
leaq 0x5d08(%rip), %rsi      # 0x14ce6
leaq 0x5f77(%rip), %rcx      # 0x14f5c
movl $0x59a, %edx            # imm = 0x59A
callq 0x3160
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/inc/block.h
// Function: CORE_BUFFER::CORE_BUFFER(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned int)
CORE_BUFFER(string v1, uint32_t v2) : NAME(v1), SIZE(v2) {
        head = 0;
        tail = 0;
        occupancy = 0;

        last_read = SIZE-1;
        last_fetch = SIZE-1;
        last_scheduled = 0;

        inorder_fetch[0] = 0;
        inorder_fetch[1] = 0;
        next_fetch[0] = 0;
        next_fetch[1] = 0;
        next_schedule = 0;

        event_cycle = 0;
        fetch_event_cycle = UINT64_MAX;
        schedule_event_cycle = UINT64_MAX;
        execute_event_cycle = UINT64_MAX;
        lsq_event_cycle = UINT64_MAX;
        retire_event_cycle = UINT64_MAX;

        entry = new ooo_model_instr[SIZE];
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %edx, %r14d
movq %rdi, %rbx
leaq 0x10(%rdi), %r13
movq %r13, (%rdi)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
movq %rax, %rsi
callq 0x10ed0
movl %r14d, 0x20(%rbx)
xorl %eax, %eax
movq %rax, 0x28(%rbx)
movl $0x0, 0x30(%rbx)
leal -0x1(%r14), %ecx
movl %ecx, 0x34(%rbx)
movl %ecx, 0x38(%rbx)
movq %rax, 0x58(%rbx)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x3c(%rbx)
movq %rax, 0x4c(%rbx)
movl %r14d, %eax
imulq $0x758, %rax, %r15      # imm = 0x758
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x60(%rbx)
movdqu %xmm0, 0x70(%rbx)
movq $-0x1, 0x80(%rbx)
movq %r15, %rdi
callq 0x3030
movq %rax, %r12
testl %r14d, %r14d
je 0x106ce
movq %r12, %r14
movq %r14, %rdi
callq 0x10550
addq $0x758, %r14            # imm = 0x758
addq $-0x758, %r15           # imm = 0xF8A8
jne 0x106b6
movq %r12, 0x88(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r13, %rdi
je 0x106ef
callq 0x3220
movq %r14, %rdi
callq 0x33d0
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/inc/memory_class.h
// Function: MEMORY::MEMORY()
MEMORY() {
        for (uint32_t i=0; i<NUM_TYPES; i++) {
            ACCESS[i] = 0;
            HIT[i] = 0;
            MISS[i] = 0;
            MSHR_MERGED[i] = 0;
            STALL[i] = 0;
        }
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x80, %rsp
movq %rdi, %r14
leaq 0x8d80(%rip), %rax      # 0x19d00
movq %rax, (%rdi)
leaq 0x28(%rdi), %rbx
leaq 0x70(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x40f9(%rip), %rsi      # 0x15091
leaq 0x40f7(%rip), %rdx      # 0x15096
leaq 0x60(%rsp), %r15
movq %r15, %rdi
callq 0xad78
movq %rbx, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x11142
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x10fcb
callq 0x3220
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x40b5(%rip), %rsi      # 0x15091
leaq 0x40b3(%rip), %rdx      # 0x15096
leaq 0x40(%rsp), %rdi
callq 0xad78
leaq 0x1cc8(%r14), %r15
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
movl $0x1, %edx
callq 0x11142
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x11015
callq 0x3220
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x406c(%rip), %rsi      # 0x15091
leaq 0x406a(%rip), %rdx      # 0x15096
leaq 0x20(%rsp), %rdi
callq 0xad78
leaq 0x3968(%r14), %r12
leaq 0x20(%rsp), %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x11142
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x1105e
callq 0x3220
leaq 0x10(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x4023(%rip), %rsi      # 0x15091
leaq 0x4021(%rip), %rdx      # 0x15096
movq %rsp, %rdi
callq 0xad78
leaq 0x5608(%r14), %rdi
movq %rsp, %rsi
movl $0x1, %edx
callq 0x11142
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x1109f
callq 0x3220
addq $0x72a8, %r14           # imm = 0x72A8
movl $0xa0, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x3130
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x110dc
callq 0x3220
jmp 0x110dc
movq %rax, %r14
movq %r12, %rdi
callq 0x1131e
jmp 0x110fd
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x110fd
callq 0x3220
jmp 0x110fd
movq %rax, %r14
movq %r15, %rdi
callq 0x1131e
jmp 0x1111e
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x1111e
callq 0x3220
jmp 0x1111e
movq %rax, %r14
movq %rbx, %rdi
callq 0x1131e
movq %r14, %rdi
callq 0x33d0
movq %rax, %r14
movq 0x60(%rsp), %rdi
cmpq %r12, %rdi
je 0x11126
callq 0x3220
jmp 0x11126
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/inc/dram_controller.h
// Function: MEMORY_CONTROLLER::MEMORY_CONTROLLER(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
MEMORY_CONTROLLER(string v1) : NAME (v1) {
        for (uint32_t i=0; i<NUM_TYPES+1; i++) {
            for (uint32_t j=0; j<NUM_TYPES+1; j++) {
                dbus_congested[i][j] = 0;
            }
        }
        do_write = 0;
        processed_writes = 0;
        scheduled_reads = 0;
        scheduled_writes = 0;
        for (uint32_t i=0; i<DRAM_CHANNELS; i++) {
            dbus_cycle_available[i] = 0;
            dbus_cycle_congested[i] = 0;
            write_mode[i] = 0;

            for (uint32_t j=0; j<DRAM_RANKS; j++) {
                for (uint32_t k=0; k<DRAM_BANKS; k++)
                    bank_cycle_available[i][j][k] = 0;
            }
        }

        fill_level = FILL_DRAM;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x10f66
leaq 0x87d4(%rip), %rax      # 0x19c88
addq $0x10, %rax
movq %rax, (%rbx)
leaq 0x7348(%rbx), %r14
leaq 0x7358(%rbx), %r13
movq %r13, 0x7348(%rbx)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x10ed0
leaq 0x7368(%rbx), %rdi
xorl %r15d, %r15d
movl $0x200, %edx            # imm = 0x200
xorl %esi, %esi
callq 0x3130
leaq 0x787c(%rbx), %rax
xorps %xmm0, %xmm0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movups %xmm0, -0x24(%rax,%r15)
movq $0x0, -0x14(%rax,%r15)
movq %rcx, -0xc(%rax,%r15)
movw $0x0, -0x4(%rax,%r15)
movl $0xffffffff, (%rax,%r15) # imm = 0xFFFFFFFF
addq $0x28, %r15
cmpq $0xa00, %r15            # imm = 0xA00
jne 0x11507
leaq 0x38(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x7348(%rbx), %rsi
movq 0x7350(%rbx), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x10ed0
leaq 0x362d(%rip), %rsi      # 0x14b90
leaq 0x28(%rsp), %rdi
callq 0x33f0
leaq 0x8258(%rbx), %r15
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movl $0x30, %edx
callq 0x11142
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11595
callq 0x3220
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x7348(%rbx), %rsi
movq 0x7350(%rbx), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x10ed0
leaq 0x3ab8(%rip), %rsi      # 0x15078
leaq 0x8(%rsp), %rdi
callq 0x33f0
leaq 0x9ef8(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movl $0x30, %edx
callq 0x11142
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x115ef
callq 0x3220
leaq 0x7568(%rbx), %rdi
movl $0x2da, %edx            # imm = 0x2DA
xorl %esi, %esi
callq 0x3130
movaps 0x3a97(%rip), %xmm0     # 0x150a0
movups %xmm0, 0x7844(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11621
movq %rax, %r12
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x11638
callq 0x3220
jmp 0x11638
movq %rax, %r12
movq %r15, %rdi
callq 0x1131e
jmp 0x1165b
jmp 0x11644
movq %rax, %r12
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1165b
callq 0x3220
jmp 0x1165b
movq %rax, %r12
movq (%r14), %rdi
cmpq %r13, %rdi
je 0x1166d
callq 0x3220
jmp 0x1166d
movq %rax, %r12
movq %rbx, %rdi
callq 0x11348
movq %r12, %rdi
callq 0x33d0
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/drc_controller.cc
// Function: DRC_MEMORY_CONTROLLER::drc_check_hit(PACKET_QUEUE*, unsigned long, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)
uint32_t DRC_MEMORY_CONTROLLER::drc_check_hit(PACKET_QUEUE *queue, uint64_t address, uint32_t cpu, uint32_t channel, uint32_t rank, uint32_t bank, uint32_t row)
{
    // determine DRC set index for this row
    // TODO: check if this modulo works okay or not
    uint32_t set = address % DRC_SETS_PER_ROW; 

    if (drc_array[channel][rank][bank][row].block == NULL) { // never accessed this row, dynamically allocate DRC blocks
        drc_array[channel][rank][bank][row].block = new BLOCK* [DRC_SETS_PER_ROW];
        for (uint32_t i=0; i<DRC_SETS_PER_ROW; i++) {
            drc_array[channel][rank][bank][row].block[i] = new BLOCK[DRC_WAY];
            drc_blocks += DRC_WAY;
        }

        return DRC_WAY; // never accessed this row, this is a miss
    }

    for (uint32_t i=0; i<DRC_WAY; i++) {
        if (drc_array[channel][rank][bank][row].block[set][i].tag == address) {
            DP ( if (warmup_complete[cpu]) {
            cout << "[" << queue->NAME << "] " << __func__ << " found matching address: " << hex << address << dec << " set: " << set << " way: " << i << endl; });

            return i;
        }
    }

    return DRC_WAY; // cannot find any matching tag, this is a miss
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rcx
movl 0x38(%rsp), %eax
movl 0x30(%rsp), %edx
movl %r8d, %esi
shlq $0x14, %rsi
addq %rdi, %rsi
movl %r9d, %edi
shlq $0x13, %rdi
addq %rsi, %rdi
shlq $0xf, %rdx
addq %rdi, %rdx
movq 0x7370(%rdx,%rax,8), %rsi
testq %rsi, %rsi
je 0x12d64
movq %rcx, %rax
shrq $0x2, %rax
movabsq $0x4924924924924925, %rdx # imm = 0x4924924924924925
mulq %rdx
shrl %edx
leal (%rdx,%rdx,8), %eax
leal (%rax,%rax,2), %eax
addl %edx, %eax
movl %ecx, %edx
subl %eax, %edx
movq (%rsi,%rdx,8), %rdx
xorl %eax, %eax
cmpq %rcx, 0x28(%rdx)
setne %al
jmp 0x12dd0
leaq (%rdx,%rax,8), %rbx
addq $0x7370, %rbx           # imm = 0x7370
movl $0xe0, %edi
callq 0x3030
movq %rax, (%rbx)
movq 0x8a0b5(%rip), %r14     # 0x9ce38
incq %r14
xorl %r15d, %r15d
xorl %r12d, %r12d
movl $0x50, %edi
callq 0x3030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl %r15d, 0x10(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movl %r15d, 0x48(%rax)
movq (%rbx), %rcx
movq %rax, (%rcx,%r12,8)
leaq (%r14,%r12), %rax
movq %rax, 0x8a076(%rip)     # 0x9ce38
incq %r12
cmpq $0x1c, %r12
jne 0x12d8c
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/drc_controller.cc
// Function: DRC_MEMORY_CONTROLLER::add_wq(PACKET*)
int DRC_MEMORY_CONTROLLER::add_wq(PACKET *packet)
{
    // check for duplicates in the write queue
    int index = check_drc_queue(&WQ, packet);
    if (index != -1)
        return index; // merged index

    // search for the empty index
    for (index=0; index<DRC_WQ_SIZE; index++) {
        if (WQ.entry[index].address == 0) {
            
            memcpy(&WQ.entry[index], packet, sizeof(PACKET));
            WQ.occupancy++;

#ifdef DEBUG_PRINT
            uint32_t channel = drc_get_channel(packet->address),
                     rank = drc_get_rank(packet->address),
                     bank = drc_get_bank(packet->address),
                     row = drc_get_row(packet->address),
                     column = drc_get_column(packet->address); 
#endif

            DP ( if(warmup_complete[packet->cpu]) {
            cout << "[" << NAME << "_WQ] " <<  __func__ << " instr_id: " << packet->instr_id << " address: " << hex << packet->address;
            cout << " full_addr: " << packet->full_addr << dec << " ch: " << channel;
            cout << " rank: " << rank << " bank: " << bank << " row: " << row << " col: " << column;
            cout << " occupancy: " << WQ.occupancy << " current: " << current_core_cycle[packet->cpu] << " event: " << packet->event_cycle << endl; });

            break;
        }
    }

    update_schedule_cycle(&WQ);

    return -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x40a890(%rdi), %ecx
testq %rcx, %rcx
je 0x130a5
movq 0x340(%rsi), %rdx
movl $0x340, %edi            # imm = 0x340
addq 0x40a908(%rbx), %rdi
xorl %eax, %eax
cmpq %rdx, (%rdi)
je 0x1309b
incq %rax
addq $0x380, %rdi            # imm = 0x380
cmpq %rax, %rcx
jne 0x13085
jmp 0x130a5
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jne 0x130f0
leaq 0x40a870(%rbx), %r14
movq 0x40a908(%rbx), %rdi
xorl %eax, %eax
cmpq $0x0, 0x340(%rdi,%rax)
je 0x130d0
addq $0x380, %rax            # imm = 0x380
cmpq $0xa800, %rax           # imm = 0xA800
jne 0x130b5
jmp 0x130e3
addq %rax, %rdi
movl $0x380, %edx            # imm = 0x380
callq 0x31c0
incl 0x40a8a4(%rbx)
movq %r14, %rsi
callq 0x11996
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/drc_controller.cc
// Function: DRC_MEMORY_CONTROLLER::get_occupancy(unsigned char)
uint32_t DRC_MEMORY_CONTROLLER::get_occupancy(uint8_t queue_type)
{
    if (queue_type == 0)
        return MSHR.occupancy;
    else if (queue_type == 1)
        return RQ.occupancy;
    else if (queue_type == 2)
        return WQ.occupancy;

    return 0;
}

// Assembly:
cmpl $0x2, %esi
je 0x13386
cmpl $0x1, %esi
je 0x1337f
xorl %eax, %eax
testl %esi, %esi
jne 0x1338c
movl 0x4073a4(%rdi), %eax
retq
movl 0x40c544(%rdi), %eax
retq
movl 0x40a8a4(%rdi), %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/src/drc_controller.cc
// Function: DRC_MEMORY_CONTROLLER::get_size(unsigned char)
uint32_t DRC_MEMORY_CONTROLLER::get_size(uint8_t queue_type)
{
    if (queue_type == 0)
        return MSHR.SIZE;
    else if (queue_type == 1)
        return RQ.SIZE;
    else if (queue_type == 2)
        return WQ.SIZE;

    return 0;
}

// Assembly:
cmpl $0x2, %esi
je 0x133ac
cmpl $0x1, %esi
je 0x133a5
xorl %eax, %eax
testl %esi, %esi
jne 0x133b2
movl 0x407390(%rdi), %eax
retq
movl 0x40c530(%rdi), %eax
retq
movl 0x40a890(%rdi), %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/branch/branch_predictor.cc
// Function: O3_CPU::last_branch_result(unsigned long, unsigned char)
void O3_CPU::last_branch_result(uint64_t ip, uint8_t taken)
{
    int hash = ip % BIMODAL_PRIME;

    if (taken && (bimodal_table[cpu][hash] < MAX_COUNTER))
        bimodal_table[cpu][hash]++;
    else if ((taken == 0) && (bimodal_table[cpu][hash] > 0))
        bimodal_table[cpu][hash]--;
}

// Assembly:
movl %edx, %ecx
movabsq $0x4003002401b01441, %rdx # imm = 0x4003002401B01441
movq %rsi, %rax
mulq %rdx
shrq $0xc, %rdx
imull $0x3ffd, %edx, %eax     # imm = 0x3FFD
subl %eax, %esi
movl (%rdi), %edx
shlq $0x10, %rdx
leaq 0x899c7(%rip), %rax     # 0x9ce70
addq %rdx, %rax
movl (%rax,%rsi,4), %edx
testl %ecx, %ecx
je 0x134c6
movl $0x1, %ecx
cmpl $0x3, %edx
jge 0x134c5
leaq (%rax,%rsi,4), %rax
addl %ecx, %edx
movl %edx, (%rax)
retq
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testl %edx, %edx
jg 0x134bd
jmp 0x134c5
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/replacement/base_replacement.cc
// Function: CACHE::lru_victim(unsigned int, unsigned long, unsigned int, BLOCK const*, unsigned long, unsigned long, unsigned int)
uint32_t CACHE::lru_victim(uint32_t cpu, uint64_t instr_id, uint32_t set, const BLOCK *current_set, uint64_t ip, uint64_t full_addr, uint32_t type)
{
    uint32_t way = 0;

    // fill invalid line first
    for (way=0; way<NUM_WAY; way++) {
        if (block[set][way].valid == false) {

            DP ( if (warmup_complete[cpu]) {
            cout << "[" << NAME << "] " << __func__ << " instr_id: " << instr_id << " invalid set: " << set << " way: " << way;
            cout << hex << " address: " << (full_addr>>LOG2_BLOCK_SIZE) << " victim address: " << block[set][way].address << " data: " << block[set][way].data;
            cout << dec << " lru: " << block[set][way].lru << endl; });

            break;
        }
    }

    // LRU victim
    if (way == NUM_WAY) {
        for (way=0; way<NUM_WAY; way++) {
            if (block[set][way].lru == NUM_WAY-1) {

                DP ( if (warmup_complete[cpu]) {
                cout << "[" << NAME << "] " << __func__ << " instr_id: " << instr_id << " replace set: " << set << " way: " << way;
                cout << hex << " address: " << (full_addr>>LOG2_BLOCK_SIZE) << " victim address: " << block[set][way].address << " data: " << block[set][way].data;
                cout << dec << " lru: " << block[set][way].lru << endl; });

                break;
            }
        }
    }

    if (way == NUM_WAY) {
        cerr << "[" << NAME << "] " << __func__ << " no victim! set: " << set << endl;
        assert(0);
    }

    return way;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
movq %rdi, %r14
movl 0x7374(%rdi), %ecx
xorl %eax, %eax
movl %ebx, %edx
movl $0x0, %esi
testq %rcx, %rcx
je 0x13526
movq 0x7390(%r14), %rsi
movq (%rsi,%rdx,8), %rdi
xorl %esi, %esi
cmpb $0x0, (%rdi)
je 0x13526
incq %rsi
addq $0x50, %rdi
cmpq %rsi, %rcx
jne 0x1350c
testq %rcx, %rcx
jne 0x13547
xorl %eax, %eax
jmp 0x1353b
testq %rcx, %rcx
sete %dil
cmpl %ecx, %esi
setne %r8b
cmovnel %esi, %eax
orb %dil, %r8b
je 0x13547
cmpl %ecx, %eax
je 0x1356b
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x7390(%r14), %rax
movq (%rax,%rdx,8), %rdx
leal -0x1(%rcx), %esi
addq $0x48, %rdx
xorl %eax, %eax
cmpl %esi, (%rdx)
je 0x1353b
incq %rax
addq $0x50, %rdx
cmpq %rax, %rcx
jne 0x1355b
movq 0x6a7e(%rip), %rdi      # 0x19ff0
leaq 0xb17(%rip), %rsi       # 0x14090
callq 0x3250
addq $0x7350, %r14           # imm = 0x7350
movq %rax, %rdi
movq %r14, %rsi
callq 0x31e0
leaq 0x197d(%rip), %rsi      # 0x14f14
movq %rax, %rdi
callq 0x3250
leaq 0x1c64(%rip), %rsi      # 0x1520a
movq %rax, %rdi
callq 0x3250
leaq 0x1c60(%rip), %rsi      # 0x15215
movq %rax, %rdi
callq 0x3250
movq %rax, %rdi
movl %ebx, %esi
callq 0x32d0
movq %rax, %rdi
callq 0x3110
leaq 0xa91(%rip), %rdi       # 0x14067
leaq 0x1c4a(%rip), %rsi      # 0x15227
leaq 0x1c63(%rip), %rcx      # 0x15247
movl $0x37, %edx
callq 0x3160
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/replacement/base_replacement.cc
// Function: CACHE::update_replacement_state(unsigned int, unsigned int, unsigned int, unsigned long, unsigned long, unsigned long, unsigned int, unsigned char)
void CACHE::update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit)
{
    if (type == WRITEBACK) {
        if (hit) // wrietback hit does not update LRU state
            return;
    }

    return lru_update(set, way);
}

// Assembly:
cmpl $0x3, 0x10(%rsp)
sete %al
cmpb $0x0, 0x18(%rsp)
setne %sil
testb %sil, %al
jne 0x13662
movl 0x7374(%rdi), %esi
movq 0x7390(%rdi), %rax
movl %edx, %edx
movq (%rax,%rdx,8), %rax
movl %ecx, %ecx
testq %rsi, %rsi
je 0x13652
leaq (%rcx,%rcx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
addq $0x48, %rdx
shlq $0x4, %rsi
leaq (%rsi,%rsi,4), %rsi
xorl %edi, %edi
movl 0x48(%rax,%rdi), %r8d
cmpl (%rdx), %r8d
jae 0x13649
incl %r8d
movl %r8d, 0x48(%rax,%rdi)
addq $0x50, %rdi
cmpq %rdi, %rsi
jne 0x13637
leaq (%rcx,%rcx,4), %rcx
shlq $0x4, %rcx
movl $0x0, 0x48(%rax,%rcx)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/replacement/base_replacement.cc
// Function: CACHE::lru_update(unsigned int, unsigned int)
void CACHE::lru_update(uint32_t set, uint32_t way)
{
    // update lru replacement state
    for (uint32_t i=0; i<NUM_WAY; i++) {
        if (block[set][i].lru < block[set][way].lru) {
            block[set][i].lru++;
        }
    }
    block[set][way].lru = 0; // promote to the MRU position
}

// Assembly:
movl 0x7374(%rdi), %r8d
movq 0x7390(%rdi), %rax
movl %esi, %ecx
movq (%rax,%rcx,8), %rax
movl %edx, %ecx
testq %r8, %r8
je 0x136b3
leaq (%rcx,%rcx,4), %rdx
shlq $0x4, %rdx
addq %rax, %rdx
addq $0x48, %rdx
shlq $0x4, %r8
leaq (%r8,%r8,4), %rsi
xorl %edi, %edi
movl 0x48(%rax,%rdi), %r8d
cmpl (%rdx), %r8d
jae 0x136aa
incl %r8d
movl %r8d, 0x48(%rax,%rdi)
addq $0x50, %rdi
cmpq %rdi, %rsi
jne 0x13698
leaq (%rcx,%rcx,4), %rcx
shlq $0x4, %rcx
movl $0x0, 0x48(%rax,%rcx)
retq
// File: /workspace/github_cpp_makefile_star2_O3/NishadSaraf[P]Championship-Simulator/replacement/llc_replacement.cc
// Function: CACHE::llc_update_replacement_state(unsigned int, unsigned int, unsigned int, unsigned long, unsigned long, unsigned long, unsigned int, unsigned char)
void CACHE::llc_update_replacement_state(uint32_t cpu, uint32_t set, uint32_t way, uint64_t full_addr, uint64_t ip, uint64_t victim_addr, uint32_t type, uint8_t hit)
{
    string TYPE_NAME;
    if (type == LOAD)
        TYPE_NAME = "LOAD";
    else if (type == RFO)
        TYPE_NAME = "RFO";
    else if (type == PREFETCH)
        TYPE_NAME = "PF";
    else if (type == WRITEBACK)
        TYPE_NAME = "WB";
    else
        assert(0);

    if (hit)
        TYPE_NAME += "_HIT";
    else
        TYPE_NAME += "_MISS";

    if ((type == WRITEBACK) && ip)
        assert(0);

    // uncomment this line to see the LLC accesses
    // cout << "CPU: " << cpu << "  LLC " << setw(9) << TYPE_NAME << " set: " << setw(5) << set << " way: " << setw(2) << way;
    // cout << hex << " paddr: " << setw(12) << paddr << " ip: " << setw(8) << ip << " victim_addr: " << victim_addr << dec << endl;

    // baseline LRU
    if (hit && (type == WRITEBACK)) // writeback hit does not update LRU state
        return;

    return lru_update(set, way);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, 0x4(%rsp)
movl 0x68(%rsp), %r13d
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
cmpl $0x4, %r13d
jae 0x137ae
movq %r9, %r15
movl %edx, %ebp
movq %rdi, %r14
movl %r13d, %eax
leaq 0x1c41(%rip), %rdx      # 0x15360
movslq (%rdx,%rax,4), %rcx
addq %rdx, %rcx
leaq 0x1c43(%rip), %rdx      # 0x15370
movq (%rdx,%rax,8), %r8
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3350
movb 0x70(%rsp), %bl
testb %bl, %bl
leaq 0x1c07(%rip), %rax      # 0x15353
leaq 0x1c05(%rip), %rsi      # 0x15358
cmovneq %rax, %rsi
leaq 0x8(%rsp), %rdi
callq 0x33f0
cmpl $0x3, %r13d
setne %al
testq %r15, %r15
sete %cl
orb %al, %cl
je 0x137cd
cmpl $0x3, %r13d
sete %al
testb %bl, %bl
setne %cl
testb %cl, %al
jne 0x13790
movq %r14, %rdi
movl %ebp, %esi
movl 0x4(%rsp), %edx
callq 0x13664
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1379f
callq 0x3220
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8b2(%rip), %rdi       # 0x14067
leaq 0x1b00(%rip), %rsi      # 0x152bc
leaq 0x1b18(%rip), %rcx      # 0x152db
movl $0x1d, %edx
callq 0x3160
leaq 0x893(%rip), %rdi       # 0x14067
leaq 0x1ae1(%rip), %rsi      # 0x152bc
leaq 0x1af9(%rip), %rcx      # 0x152db
movl $0x25, %edx
callq 0x3160
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x137fe
callq 0x3220
movq %rbx, %rdi
callq 0x33d0