// File: /workspace/github_c_makefile_star2_O0/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
subq $0x150, %rsp            # imm = 0x150
leaq 0x3981e(%rip), %rax     # 0x6a670
movsd 0x28(%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
movl $0x100, -0xc(%rbp)      # imm = 0x100
callq 0xf930
movss %xmm0, -0x114(%rbp)
callq 0xf7b0
movss %xmm0, -0x118(%rbp)
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
leaq 0x15924(%rip), %rdi     # 0x467c4
xorl %esi, %esi
callq 0x10110
leaq -0x110(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
leaq 0x1591e(%rip), %rdx     # 0x467d8
leaq 0x15930(%rip), %rcx     # 0x467f1
leaq 0x1593b(%rip), %r8      # 0x46803
leaq 0x15927(%rip), %r9      # 0x467f6
leaq 0x1592b(%rip), %r10     # 0x46801
leaq 0x1591f(%rip), %rax     # 0x467fc
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x22a0
leaq -0x110(%rbp), %rdi
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
xorl %esi, %esi
callq 0x10110
movq $0x0, -0x120(%rbp)
cmpq $0xa, -0x120(%rbp)
jae 0x3107e
leaq 0x39739(%rip), %rax     # 0x6a670
imulq $0x48, -0x120(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x128(%rbp)
leaq -0x110(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rax
movb 0x9(%rax), %al
cmpb $0x0, %al
je 0x30f75
leaq 0x158bb(%rip), %rax     # 0x46827
movq %rax, -0x138(%rbp)
jmp 0x30f85
leaq 0x14ba5(%rip), %rax     # 0x45b21
movq %rax, -0x138(%rbp)
jmp 0x30f85
movq -0x130(%rbp), %rdi
movq -0x138(%rbp), %rcx
movq -0x128(%rbp), %rax
movq (%rax), %r8
movq -0x128(%rbp), %rax
movq 0x30(%rax), %r9
movq -0x128(%rbp), %rax
movsd 0x28(%rax), %xmm0
movsd -0x8(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x128(%rbp), %rax
movsd 0x28(%rax), %xmm1
movq -0x128(%rbp), %rax
movq 0x30(%rax), %xmm2
movaps 0x14a34(%rip), %xmm5    # 0x45a10
punpckldq %xmm5, %xmm2    # xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
movapd 0x14a38(%rip), %xmm4    # 0x45a20
subpd %xmm4, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
divsd %xmm2, %xmm1
movq -0x128(%rbp), %rax
movsd 0x38(%rax), %xmm2
movq -0x128(%rbp), %rax
movq 0x40(%rax), %xmm3
punpckldq %xmm5, %xmm3    # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
subpd %xmm4, %xmm3
movaps %xmm3, %xmm4
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
addsd %xmm4, %xmm3
divsd %xmm3, %xmm2
movl $0x100, %esi            # imm = 0x100
leaq 0x157cf(%rip), %rdx     # 0x46805
movb $0x3, %al
callq 0x22a0
leaq -0x110(%rbp), %rdi
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
xorl %esi, %esi
callq 0x10110
movq -0x120(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x120(%rbp)
jmp 0x30f22
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
leaq 0x1576c(%rip), %rdi     # 0x46829
xorl %esi, %esi
callq 0x10110
leaq -0x110(%rbp), %rdi
leaq 0x38d86(%rip), %rax     # 0x69e58
movq (%rax), %r8
movl $0x100, %esi            # imm = 0x100
leaq 0x15757(%rip), %rdx     # 0x46838
leaq 0x1575f(%rip), %rcx     # 0x46847
movb $0x0, %al
callq 0x22a0
leaq -0x110(%rbp), %rdi
movss -0x118(%rbp), %xmm1
movss -0x114(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x114(%rbp)
xorl %esi, %esi
callq 0x10110
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)