// File: /workspace/github_c_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
leaq 0x29c9e(%rip), %r15     # 0x4b640
movsd 0x28(%r15), %xmm0
movsd %xmm0, -0x38(%rbp)
callq 0x911d
movss %xmm0, -0x2c(%rbp)
callq 0x902c
movaps %xmm0, %xmm1
movss %xmm0, -0x30(%rbp)
movss -0x2c(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq 0xadf3(%rip), %rdi      # 0x2c7cc
xorl %esi, %esi
callq 0x955e
leaq 0xae1d(%rip), %r10      # 0x2c804
leaq 0xae1b(%rip), %r11      # 0x2c809
leaq 0xadeb(%rip), %rdx      # 0x2c7e0
leaq 0xadfd(%rip), %rcx      # 0x2c7f9
leaq 0xae08(%rip), %r8       # 0x2c80b
leaq 0xadf4(%rip), %r9       # 0x2c7fe
leaq -0x140(%rbp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x22a0
addq $0x10, %rsp
movss -0x2c(%rbp), %xmm0
subss -0x30(%rbp), %xmm0
movq %rbx, %rdi
movss %xmm0, -0x2c(%rbp)
xorl %esi, %esi
callq 0x955e
pushq $0x40
popq %r12
leaq 0xade3(%rip), %r13      # 0x2c82f
leaq 0xadba(%rip), %r14      # 0x2c80d
cmpq $0x310, %r12            # imm = 0x310
je 0x21b1c
cmpb $0x0, -0x37(%r15,%r12)
movss -0x2c(%rbp), %xmm0
subss -0x30(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movq %r13, %rcx
leaq 0xa0aa(%rip), %rax      # 0x2bb29
cmoveq %rax, %rcx
movq -0x40(%r15,%r12), %r8
movq -0x10(%r15,%r12), %r9
movsd -0x18(%r15,%r12), %xmm0
divsd -0x38(%rbp), %xmm0
movsd -0x18(%r15,%r12), %xmm1
movsd -0x10(%r15,%r12), %xmm2
movsd 0x9801(%rip), %xmm4     # 0x2b2b0
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movapd 0x9806(%rip), %xmm5     # 0x2b2c0
subpd %xmm5, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
divsd %xmm3, %xmm1
movsd -0x8(%r15,%r12), %xmm2
movsd (%r15,%r12), %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
movq %rbx, %rdi
movss -0x2c(%rbp), %xmm0
xorl %esi, %esi
callq 0x955e
addq $0x48, %r12
jmp 0x21a53
movss -0x2c(%rbp), %xmm0
movss -0x30(%rbp), %xmm1
subss %xmm1, %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
leaq 0xacf7(%rip), %rdi      # 0x2c831
xorl %esi, %esi
callq 0x955e
leaq 0x292e0(%rip), %rax     # 0x4ae28
movq (%rax), %r8
leaq 0xacee(%rip), %rdx      # 0x2c840
leaq 0xacf6(%rip), %rcx      # 0x2c84f
leaq -0x140(%rbp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a0
movss -0x2c(%rbp), %xmm0
subss -0x30(%rbp), %xmm0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x955e
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq