// File: /workspace/github_cpp_makefile_star2_O1/NishadSaraf[P]Championship-Simulator/src/main.cc
// Function: finish_warmup()
void finish_warmup()
{
    uint64_t elapsed_second = (uint64_t)(time(NULL) - start_time),
             elapsed_minute = elapsed_second / 60,
             elapsed_hour = elapsed_minute / 60;
    elapsed_minute -= elapsed_hour*60;
    elapsed_second -= (elapsed_hour*3600 + elapsed_minute*60);

    // reset core latency
    SCHEDULING_LATENCY = 6;
    EXEC_LATENCY = 1;
    PAGE_TABLE_LATENCY = 100;
    SWAP_LATENCY = 100000;

    cout << endl;
    for (uint32_t i=0; i<NUM_CPUS; i++) {
        cout << "Warmup complete CPU " << i << " instructions: " << ooo_cpu[i].num_retired << " cycles: " << current_core_cycle[i];
        cout << " (Simulation time: " << elapsed_hour << " hr " << elapsed_minute << " min " << elapsed_second << " sec) " << endl;

        ooo_cpu[i].begin_sim_cycle = current_core_cycle[i]; 
        ooo_cpu[i].begin_sim_instr = ooo_cpu[i].num_retired;

        // reset branch stats
        ooo_cpu[i].num_branch = 0;
        ooo_cpu[i].branch_mispredictions = 0;

        reset_cache_stats(i, &ooo_cpu[i].L1I);
        reset_cache_stats(i, &ooo_cpu[i].L1D);
        reset_cache_stats(i, &ooo_cpu[i].L2C);
        reset_cache_stats(i, &uncore.LLC);
    }
    cout << endl;

    // reset DRAM stats
    uncore.DRAM.RQ.ROW_BUFFER_HIT = 0;
    uncore.DRAM.RQ.ROW_BUFFER_MISS = 0;
    uncore.DRAM.WQ.ROW_BUFFER_HIT = 0;
    uncore.DRAM.WQ.ROW_BUFFER_MISS = 0;

    // set actual cache latency
    for (uint32_t i=0; i<NUM_CPUS; i++) {
        ooo_cpu[i].ITLB.LATENCY = ITLB_LATENCY;
        ooo_cpu[i].DTLB.LATENCY = DTLB_LATENCY;
        ooo_cpu[i].STLB.LATENCY = STLB_LATENCY;
        ooo_cpu[i].L1I.LATENCY  = L1I_LATENCY;
        ooo_cpu[i].L1D.LATENCY  = L1D_LATENCY;
        ooo_cpu[i].L2C.LATENCY  = L2C_LATENCY;
    }
    uncore.LLC.LATENCY = LLC_LATENCY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %edi, %edi
callq 0x31f0
movq %rax, %rcx
subq 0x11e98(%rip), %rcx     # 0x1a348
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
movq %rcx, %rax
mulq %rdx
movq %rdx, %rsi
movq %rcx, %rax
shrq $0x4, %rax
movabsq $0x91a2b3c4d5e6f81, %rdx # imm = 0x91A2B3C4D5E6F81
mulq %rdx
movq %rdx, %r12
shrq $0x5, %rsi
shrq $0x3, %r12
imulq $-0x3c, %r12, %r15
addq %rsi, %r15
imulq $-0xe10, %r12, %r14     # imm = 0xF1F0
imulq $-0x3c, %r15, %rax
addq %rcx, %r14
addq %rax, %r14
leaq 0x789cf(%rip), %rax     # 0x80ed0
movl $0x6, (%rax)
leaq 0x789c6(%rip), %rax     # 0x80ed4
movl $0x1, %ecx
movl %ecx, (%rax)
movl $0x64, 0x11e39(%rip)    # 0x1a358
movl $0x186a0, 0x11e33(%rip) # imm = 0x186A0
movq 0x11aa0(%rip), %rbx     # 0x19fd0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
leaq 0xc00f(%rip), %rsi      # 0x1456d
movl $0x14, %edx
movq %rbx, %rdi
callq 0x3280
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3170
movq %rax, %r13
leaq 0xc003(%rip), %rsi      # 0x14582
movl $0xf, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x13cad(%rip), %rbp     # 0x1c240
movq 0x918(%rbp), %rsi
movq %r13, %rdi
callq 0x3170
movq %rax, %r13
leaq 0xbfe6(%rip), %rsi      # 0x14592
movl $0x9, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x78900(%rip), %rax     # 0x80ec0
movq (%rax), %rsi
movq %r13, %rdi
callq 0x3170
leaq 0xbfca(%rip), %rsi      # 0x1459c
movl $0x13, %edx
movq %rbx, %rdi
callq 0x3280
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3170
movq %rax, %r12
leaq 0xbfbc(%rip), %rsi      # 0x145b0
movl $0x4, %edx
movq %rax, %rdi
callq 0x3280
movq %r12, %rdi
movq %r15, %rsi
callq 0x3170
movq %rax, %r15
leaq 0xbf9f(%rip), %rsi      # 0x145b5
movl $0x5, %edx
movq %rax, %rdi
callq 0x3280
movq %r15, %rdi
movq %r14, %rsi
callq 0x3170
movq %rax, %r14
leaq 0xbf83(%rip), %rsi      # 0x145bb
movl $0x6, %edx
movq %rax, %rdi
callq 0x3280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
leaq 0x7884d(%rip), %rax     # 0x80ec0
movq (%rax), %rax
movq %rax, 0x8c0(%rbp)
movq 0x918(%rbp), %rax
movq %rax, 0x8c8(%rbp)
leaq 0x3b430(%rbp), %rdi
movl $0xa0, %edx
xorl %esi, %esi
callq 0x3130
xorl %r14d, %r14d
movq %r14, 0x3d230(%rbp)
movq %r14, 0x3b5c0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x3b590(%rbp)
movaps %xmm0, 0x3b5a0(%rbp)
movaps %xmm0, 0x3d240(%rbp)
leaq 0x4b7d8(%rbp), %rdi
movl $0xa0, %edx
xorl %esi, %esi
callq 0x3130
movq %r14, 0x4d5d8(%rbp)
movq %r14, 0x4b968(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x4b938(%rbp)
movups %xmm0, 0x4b948(%rbp)
movups %xmm0, 0x4d5e8(%rbp)
leaq 0x5bb80(%rbp), %rdi
movl $0xa0, %edx
xorl %esi, %esi
callq 0x3130
movq %r14, 0x5d980(%rbp)
movq %r14, 0x5bd10(%rbp)
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, 0x5bce0(%rbp)
movaps %xmm0, 0x5bcf0(%rbp)
movaps %xmm0, 0x5d990(%rbp)
movaps %xmm0, 0x3680(%rbp)
movaps %xmm0, 0x44470(%rbp)
movaps %xmm0, 0x44480(%rbp)
movaps %xmm0, 0x44490(%rbp)
movaps %xmm0, 0x444a0(%rbp)
movaps %xmm0, 0x444b0(%rbp)
movaps %xmm0, 0x444c0(%rbp)
movups %xmm0, 0x54818(%rbp)
movups %xmm0, 0x54828(%rbp)
movups %xmm0, 0x54838(%rbp)
movups %xmm0, 0x54848(%rbp)
movups %xmm0, 0x54858(%rbp)
movups %xmm0, 0x54868(%rbp)
movaps %xmm0, 0x64c10(%rbp)
movaps %xmm0, 0x64c00(%rbp)
movaps %xmm0, 0x64bf0(%rbp)
movaps %xmm0, 0x64be0(%rbp)
movaps %xmm0, 0x64bd0(%rbp)
movaps %xmm0, 0x64bc0(%rbp)
leaq 0x78718(%rip), %r14     # 0x80ee0
leaq 0x72a8(%r14), %rdi
movl $0xa0, %edx
xorl %esi, %esi
callq 0x3130
movq %r15, 0x90a8(%r14)
movq %r15, 0x7438(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x7408(%r14)
movups %xmm0, 0x7418(%r14)
movups %xmm0, 0x90b8(%r14)
movups %xmm0, 0x102e8(%r14)
movups %xmm0, 0x102f8(%r14)
movups %xmm0, 0x10308(%r14)
movups %xmm0, 0x10318(%r14)
movups %xmm0, 0x10328(%r14)
movups %xmm0, 0x10338(%r14)
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3180
xorps %xmm0, %xmm0
movups %xmm0, 0x18680(%r14)
movups %xmm0, 0x1a320(%r14)
movl $0x1, %eax
movl %eax, 0xaa1c(%rbp)
movl %eax, 0x1adc4(%rbp)
movl $0x1, %ecx
movl $0x8, %eax
movl %eax, 0x2b16c(%rbp)
movl %ecx, 0x3b514(%rbp)
movl $0x4, 0x4b8bc(%rbp)
movl %eax, 0x5bc64(%rbp)
movl $0x14, 0x738c(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq