// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
movq %rsi, %rbx
movl %edi, %r12d
movq %r12, %rax
shlq $0x5, %rax
addq %rsi, %rax
addq $0x10388, %rax          # imm = 0x10388
pxor %xmm1, %xmm1
movq $-0x4, %rcx
pxor %xmm2, %xmm2
pxor %xmm0, %xmm0
movdqu -0x20(%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm1
movdqu (%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm2
movdqu 0x20(%rax,%rcx,8), %xmm3
paddq %xmm3, %xmm0
addq $0x2, %rcx
jne 0x757a
pshufd $0xee, %xmm1, %xmm3     # xmm3 = xmm1[2,3,2,3]
paddq %xmm1, %xmm3
movq %xmm3, %r15
pshufd $0xee, %xmm2, %xmm1     # xmm1 = xmm2[2,3,2,3]
paddq %xmm2, %xmm1
movq %xmm1, %r13
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddq %xmm0, %xmm1
movq %xmm1, (%rsp)
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq 0x129f4(%rip), %r14     # 0x19fd0
movq %r14, %rdi
callq 0x3280
leaq 0xcdf0(%rip), %rsi      # 0x143db
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%r14,%rax)
movq %r14, %rdi
movq %r15, %rsi
callq 0x3170
movq %rax, %rbp
leaq 0xcdd1(%rip), %rsi      # 0x143ef
movl $0x7, %edx
movq %rax, %rdi
callq 0x3280
movq (%rbp), %rax
movq -0x18(%rax), %rax
movl $0xa, %ecx
movq %rcx, 0x10(%rbp,%rax)
movl $0xa, %r15d
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3170
movq %rax, %rbp
leaq 0xcd9f(%rip), %rsi      # 0x143f7
movl $0x8, %edx
movq %rax, %rdi
callq 0x3280
movq (%rbp), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%rbp,%rax)
movq %rbp, %rdi
movq (%rsp), %rsi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcd5e(%rip), %rsi      # 0x14423
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %ebp
movq %rbp, 0x10(%r14,%rax)
shlq $0x5, %r12
movq 0x10348(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcce6(%rip), %rsi      # 0x143ef
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %rbp, 0x10(%r13,%rax)
movl $0xa, %r15d
movq 0x10368(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
leaq 0xccb4(%rip), %rbp      # 0x143f7
movq %rbp, %rsi
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movq 0x10388(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcc88(%rip), %rsi      # 0x14437
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r14,%rax)
movq 0x10350(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcc05(%rip), %rsi      # 0x143ef
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movq 0x10370(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movq 0x10390(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcbc8(%rip), %rsi      # 0x1444b
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r14,%rax)
movq 0x10358(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0xcb31(%rip), %rsi      # 0x143ef
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movq 0x10378(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movl $0x8, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3280
movq (%r13), %rax
movq -0x18(%rax), %rax
movq %r15, 0x10(%r13,%rax)
movq 0x10398(%rbx,%r12), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
movq 0x7350(%rbx), %rsi
movq 0x7358(%rbx), %rdx
movq %r14, %rdi
callq 0x3280
leaq 0xcb08(%rip), %rsi      # 0x1445f
movl $0x13, %edx
movq %r14, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movl $0xa, %r13d
movq %r13, 0x10(%r14,%rax)
movq 0x10360(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r14
movl $0x7, %edx
movq %rax, %rdi
leaq 0xca57(%rip), %rsi      # 0x143ef
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r13, 0x10(%r14,%rax)
movl $0xa, %r13d
movq 0x10380(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r13, 0x10(%r14,%rax)
movq 0x103a0(%rbx,%r12), %rsi
movq %r14, %rdi
callq 0x3170
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3180