// File: /workspace/github_c_makefile_star2_O1/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 0x2cb75(%rip), %r12     # 0x50640
movsd 0x28(%r12), %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
cvtss2sd 0x47782(%rip), %xmm0    # 0x6b264
movsd %xmm0, -0x30(%rbp)
movss 0xc741(%rip), %xmm0     # 0x30230
divss 0x47799(%rip), %xmm0    # 0x6b290
leaq 0x40e92(%rip), %r14     # 0x64990
movq (%r14), %rsi
leaq 0x13910(%rip), %rbx     # 0x37418
movq %rbx, %rdi
callq 0xa46d
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
mulsd 0xcf48(%rip), %xmm0     # 0x30a68
addsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movss 0xc6fa(%rip), %xmm0     # 0x30230
divss 0x47752(%rip), %xmm0    # 0x6b290
movq (%r14), %rsi
movq %rbx, %rdi
callq 0xa46d
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm0, -0x40(%rbp)
movss 0xc6d7(%rip), %xmm2     # 0x30230
divss 0x4772f(%rip), %xmm2    # 0x6b290
movss -0x30(%rbp), %xmm1
subss %xmm0, %xmm1
movss %xmm1, -0x30(%rbp)
movq (%r14), %rsi
movsd 0x40e26(%rip), %xmm4    # 0x649a0
movsd 0x40e26(%rip), %xmm5    # 0x649a8
leaq 0xdc7b(%rip), %rdi      # 0x31804
movss 0xc697(%rip), %xmm0     # 0x30228
movss 0xc473(%rip), %xmm6     # 0x3000c
xorpd %xmm3, %xmm3
movl $0x1, %edx
callq 0xa67d
leaq 0xdc8e(%rip), %r10      # 0x3183c
leaq 0xdc8c(%rip), %r11      # 0x31841
leaq 0xdc5c(%rip), %rdx      # 0x31818
leaq 0xdc6e(%rip), %rcx      # 0x31831
leaq 0xdc79(%rip), %r8       # 0x31843
leaq 0xdc65(%rip), %r9       # 0x31836
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 0xc639(%rip), %xmm2     # 0x30230
divss 0x47691(%rip), %xmm2    # 0x6b290
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
movq (%r14), %rsi
movsd 0x40d8c(%rip), %xmm4    # 0x649a0
movsd 0x40d8c(%rip), %xmm5    # 0x649a8
xorpd %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc5fd(%rip), %xmm0     # 0x30228
movss %xmm1, -0x30(%rbp)
movss 0xc3d4(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa67d
movl $0x40, %r13d
leaq 0xdc18(%rip), %r15      # 0x31867
leaq 0xdbef(%rip), %r14      # 0x31845
cmpb $0x0, -0x37(%r12,%r13)
movq %r15, %rcx
leaq 0xcefb(%rip), %rax      # 0x30b61
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 0xc62a(%rip), %xmm4     # 0x302c0
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
movapd 0xc62f(%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 0xc53d(%rip), %xmm2     # 0x30230
divss 0x47595(%rip), %xmm2    # 0x6b290
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
leaq 0x40c84(%rip), %rax     # 0x64990
movq (%rax), %rsi
movsd 0x40c89(%rip), %xmm4    # 0x649a0
movsd 0x40c89(%rip), %xmm5    # 0x649a8
xorpd %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc4fa(%rip), %xmm0     # 0x30228
movss %xmm1, -0x30(%rbp)
movss 0xc2d1(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa67d
addq $0x48, %r13
cmpq $0x310, %r13            # imm = 0x310
jne 0x23c56
movss -0x30(%rbp), %xmm1
movaps -0x40(%rbp), %xmm3
subss %xmm3, %xmm1
movss 0xc4c5(%rip), %xmm2     # 0x30230
divss 0x4751d(%rip), %xmm2    # 0x6b290
subss %xmm3, %xmm1
movss %xmm1, -0x30(%rbp)
leaq 0x40c0d(%rip), %r14     # 0x64990
movq (%r14), %rsi
movsd 0x40c12(%rip), %xmm4    # 0x649a0
movsd 0x40c12(%rip), %xmm5    # 0x649a8
leaq 0xdacc(%rip), %rdi      # 0x31869
movss 0xc483(%rip), %xmm0     # 0x30228
movss 0xc25f(%rip), %xmm6     # 0x3000c
xorps %xmm3, %xmm3
movl $0x1, %edx
callq 0xa67d
leaq 0x2c067(%rip), %rax     # 0x4fe28
movq (%rax), %r8
leaq 0xdaad(%rip), %rdx      # 0x31878
leaq 0xdab5(%rip), %rcx      # 0x31887
leaq -0x150(%rbp), %rbx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x22a0
movss 0xc440(%rip), %xmm2     # 0x30230
divss 0x47498(%rip), %xmm2    # 0x6b290
movss -0x30(%rbp), %xmm1
subss -0x40(%rbp), %xmm1
movq (%r14), %rsi
movsd 0x40b93(%rip), %xmm4    # 0x649a0
movsd 0x40b93(%rip), %xmm5    # 0x649a8
xorps %xmm3, %xmm3
movq %rbx, %rdi
movss 0xc405(%rip), %xmm0     # 0x30228
movss 0xc1e1(%rip), %xmm6     # 0x3000c
movl $0x1, %edx
callq 0xa67d
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq