// File: /workspace/github_c_makefile_star2_O3/FredTheDino[P]Fog/src/engine/util/performance.cpp
// Function: Perf::report()
void report() {
    f64 frame_time = clocks[MAIN].last_time;
    const int buffer_size = 256;
    char buffer[buffer_size];

    f32 y = Util::debug_top_of_screen();
    f32 dy = Util::debug_line_height();

    Util::debug_text("=== PERFORMANCE ===", y -= dy);

    snprintf(buffer, buffer_size,
            "  %-17s- %5s %9s %9s %9s",
            "NAME", "C", "T/TOT", "T/C", "Avg. T/C");
    Util::debug_text(buffer, y -= dy);

    for (u64 i = 0; i < NUMBER_OF_MARKERS; i++) {
        // TODO(ed): Lock audio thread here.
        volatile Clock *clock = clocks + i;
        snprintf(buffer, buffer_size, "%s %-17s- %5llu %9.3f %9.3f %9.3f",
                clock->other_thread ? "*": " ",
                clock->name, clock->last_count,
                clock->last_time / frame_time,
                clock->last_time / clock->last_count,
                clock->total_time / clock->total_count);
        Util::debug_text(buffer, y -= dy);
    }
    y -= dy;

    Util::debug_text("=== MEMORY ===", y -= dy);
    snprintf(buffer, buffer_size, "  %-17s: %5lld",
             "FREE ARENAS", Util::global_memory.num_free_regions);
    Util::debug_text(buffer, y -= dy);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
leaq 0x2ce0f(%rip), %r12     # 0x50630
movsd 0x28(%r12), %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
cvtss2sd 0x47a1c(%rip), %xmm0    # 0x6b254
movsd %xmm0, -0x30(%rbp)
movss 0xc9eb(%rip), %xmm0     # 0x30230
divss 0x47a33(%rip), %xmm0    # 0x6b280
leaq 0x4112c(%rip), %r14     # 0x64980
movq (%r14), %rsi
leaq 0x13baa(%rip), %rbx     # 0x37408
movq %rbx, %rdi
callq 0xa218
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
mulsd 0xd1e2(%rip), %xmm0     # 0x30a58
addsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movss 0xc9a4(%rip), %xmm0     # 0x30230
divss 0x479ec(%rip), %xmm0    # 0x6b280
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xa218
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm0, -0x40(%rbp)
movss 0xc981(%rip), %xmm2     # 0x30230
divss 0x479c9(%rip), %xmm2    # 0x6b280
movss -0x30(%rbp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, -0x30(%rbp)
movq (%r14), %rsi
movsd 0x410c0(%rip), %xmm4    # 0x64990
movsd 0x410c0(%rip), %xmm5    # 0x64998
leaq 0xdf15(%rip), %rdi      # 0x317f4
movss 0xc941(%rip), %xmm0     # 0x30228
movss 0xc71d(%rip), %xmm6     # 0x3000c
xorpd %xmm3, %xmm3
movl $0x1, %edx
callq 0xa428
leaq 0xdf28(%rip), %r10      # 0x3182c
leaq 0xdf26(%rip), %r11      # 0x31831
leaq 0xdef6(%rip), %rdx      # 0x31808
leaq 0xdf08(%rip), %rcx      # 0x31821
leaq 0xdf13(%rip), %r8       # 0x31833
leaq 0xdeff(%rip), %r9       # 0x31826
leaq -0x150(%rbp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x22a0
addq $0x10, %rsp
movss 0xc8e3(%rip), %xmm2     # 0x30230
divss 0x4792b(%rip), %xmm2    # 0x6b280
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
movq (%r14), %rsi
movsd 0x41026(%rip), %xmm4    # 0x64990
movsd 0x41026(%rip), %xmm5    # 0x64998
xorpd %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc8a7(%rip), %xmm0     # 0x30228
movss %xmm1, -0x30(%rbp)
movss 0xc67e(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa428
movl $0x40, %r13d
leaq 0xdeb2(%rip), %r15      # 0x31857
leaq 0xde89(%rip), %r14      # 0x31835
cmpb $0x0, -0x37(%r12,%r13)
movq %r15, %rcx
leaq 0xd195(%rip), %rax      # 0x30b51
cmoveq %rax, %rcx
movq -0x40(%r12,%r13), %r8
movq -0x10(%r12,%r13), %r9
movsd -0x18(%r12,%r13), %xmm0
divsd -0x48(%rbp), %xmm0
movsd -0x18(%r12,%r13), %xmm1
movsd -0x10(%r12,%r13), %xmm2
movsd 0xc8d4(%rip), %xmm4     # 0x302c0
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movapd 0xc8d9(%rip), %xmm5     # 0x302d0
subpd %xmm5, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm3, %xmm1
movsd -0x8(%r12,%r13), %xmm2
movsd (%r12,%r13), %xmm3
unpcklps %xmm4, %xmm3            # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
subpd %xmm5, %xmm3
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
addsd %xmm3, %xmm4
divsd %xmm4, %xmm2
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
movq %r14, %rdx
movb $0x3, %al
callq 0x22a0
movss 0xc7e7(%rip), %xmm2     # 0x30230
divss 0x4782f(%rip), %xmm2    # 0x6b280
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
leaq 0x40f1e(%rip), %rax     # 0x64980
movq (%rax), %rsi
movsd 0x40f23(%rip), %xmm4    # 0x64990
movsd 0x40f23(%rip), %xmm5    # 0x64998
xorpd %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc7a4(%rip), %xmm0     # 0x30228
movss %xmm1, -0x30(%rbp)
movss 0xc57b(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa428
addq $0x48, %r13
cmpq $0x310, %r13            # imm = 0x310
jne 0x239ac
movss -0x30(%rbp), %xmm1
movaps -0x40(%rbp), %xmm3
subss %xmm3, %xmm1
movss 0xc76f(%rip), %xmm2     # 0x30230
divss 0x477b7(%rip), %xmm2    # 0x6b280
subss %xmm3, %xmm1
movss %xmm1, -0x30(%rbp)
leaq 0x40ea7(%rip), %r14     # 0x64980
movq (%r14), %rsi
movsd 0x40eac(%rip), %xmm4    # 0x64990
movsd 0x40eac(%rip), %xmm5    # 0x64998
leaq 0xdd66(%rip), %rdi      # 0x31859
movss 0xc72d(%rip), %xmm0     # 0x30228
movss 0xc509(%rip), %xmm6     # 0x3000c
xorps %xmm3, %xmm3
movl $0x1, %edx
callq 0xa428
leaq 0x2c301(%rip), %rax     # 0x4fe18
movq (%rax), %r8
leaq 0xdd47(%rip), %rdx      # 0x31868
leaq 0xdd4f(%rip), %rcx      # 0x31877
leaq -0x150(%rbp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a0
movss 0xc6ea(%rip), %xmm2     # 0x30230
divss 0x47732(%rip), %xmm2    # 0x6b280
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
movq (%r14), %rsi
movsd 0x40e2d(%rip), %xmm4    # 0x64990
movsd 0x40e2d(%rip), %xmm5    # 0x64998
xorps %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc6af(%rip), %xmm0     # 0x30228
movss 0xc48b(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa428
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq