// File: /workspace/github_cpp_makefile_star2_O2/NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: print_roi_stats(unsigned int, CACHE*)
void print_roi_stats(uint32_t cpu, CACHE *cache)
{
    uint64_t TOTAL_ACCESS = 0, TOTAL_HIT = 0, TOTAL_MISS = 0;

    for (uint32_t i=0; i<NUM_TYPES; i++) {
        TOTAL_ACCESS += cache->roi_access[cpu][i];
        TOTAL_HIT += cache->roi_hit[cpu][i];
        TOTAL_MISS += cache->roi_miss[cpu][i];
    }

    cout << cache->NAME;
    cout << " TOTAL     ACCESS: " << setw(10) << TOTAL_ACCESS << "  HIT: " << setw(10) << TOTAL_HIT << "  MISS: " << setw(10) << TOTAL_MISS << endl;

    cout << cache->NAME;
    cout << " LOAD      ACCESS: " << setw(10) << cache->roi_access[cpu][0] << "  HIT: " << setw(10) << cache->roi_hit[cpu][0] << "  MISS: " << setw(10) << cache->roi_miss[cpu][0] << endl;

    cout << cache->NAME;
    cout << " RFO       ACCESS: " << setw(10) << cache->roi_access[cpu][1] << "  HIT: " << setw(10) << cache->roi_hit[cpu][1] << "  MISS: " << setw(10) << cache->roi_miss[cpu][1] << endl;

    cout << cache->NAME;
    cout << " PREFETCH  ACCESS: " << setw(10) << cache->roi_access[cpu][2] << "  HIT: " << setw(10) << cache->roi_hit[cpu][2] << "  MISS: " << setw(10) << cache->roi_miss[cpu][2] << endl;

    cout << cache->NAME;
    cout << " WRITEBACK ACCESS: " << setw(10) << cache->roi_access[cpu][3] << "  HIT: " << setw(10) << cache->roi_hit[cpu][3] << "  MISS: " << setw(10) << cache->roi_miss[cpu][3] << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
leaq 0x10348(%rsi), %rax
movq %rax, (%rsp)
movl %edi, %ebp
leaq 0x10368(%rsi), %rax
movq %rax, 0x8(%rsp)
leaq 0x10388(%rsi), %rax
movq %rax, 0x10(%rsp)
shlq $0x5, %rbp
leaq (%rsi,%rbp), %rax
addq $0x10388, %rax          # imm = 0x10388
pushq $-0x20
popq %rcx
xorl %r13d, %r13d
xorl %r12d, %r12d
xorl %r15d, %r15d
testq %rcx, %rcx
je 0x5ed6
addq -0x20(%rax,%rcx), %r15
addq (%rax,%rcx), %r12
addq 0x20(%rax,%rcx), %r13
addq $0x8, %rcx
jmp 0x5ebd
addq $0x7350, %rbx           # imm = 0x7350
movq 0x100ec(%rip), %r14     # 0x15fd0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa4f5(%rip), %rsi      # 0x103eb
movq %r14, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
pushq $0xa
popq %r14
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2170
leaq 0xa4df(%rip), %rsi      # 0x103ff
movq %rax, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r12, %rsi
callq 0x2170
leaq 0xa4c1(%rip), %rsi      # 0x10407
movq %rax, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r13, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0x1005c(%rip), %r15     # 0x15fd0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa4ad(%rip), %rsi      # 0x10433
movq %r15, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq (%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rcx, %r12
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa448(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa424(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%rsp), %rcx
movq (%rcx,%rbp), %rsi
movq %rcx, %r13
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa425(%rip), %rsi      # 0x10447
movq %r15, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa3b2(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%rsp), %r15
movq 0x8(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa38d(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x8(%r13,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0xff29(%rip), %r12      # 0x15fd0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa3a2(%rip), %rsi      # 0x1045b
movq %r12, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq (%rsp), %r12
movq 0x10(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa317(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa2f7(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%r13,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x2110
movq 0xfe93(%rip), %r13      # 0x15fd0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x21d0
leaq 0xa320(%rip), %rsi      # 0x1046f
movq %r13, %rdi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x18(%r12,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa285(%rip), %rsi      # 0x103ff
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x18(%r15,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xa265(%rip), %rsi      # 0x10407
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r14, 0x10(%rax,%rcx)
movq 0x10(%rsp), %rcx
movq 0x18(%rcx,%rbp), %rsi
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110