// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/engine/util/performance.cpp
// Function: Perf::_stop_perf_clock(Perf::MarkerID)
void _stop_perf_clock(MarkerID id) {
    ASSERT(0 <= id && id < NUMBER_OF_MARKERS, "Invalid perf ID");
    volatile Clock *clock = clocks + id;
    CHECK(clock->active, "Stopping allready stopped clock");
    if (!clock->active) return;
    clock->active = false;
    u64 now = highp_now();
    if (now < clock->start) {
        ERR("Performance clock error, invalid times for %s", clock->name);
        return;
    }
    clock->time += now - clock->start;

    if (clock->other_thread) {
        f64 time = clock->time / 1000.0f;
        clock->total_time += time;
        clock->last_time = time;
        clock->time = 0;
        clock->total_count += clock->count;
        clock->last_count = clock->count;
        clock->count = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl -0x4(%rbp), %ecx
movb %al, -0x21(%rbp)
jg 0x2e691
cmpl $0xa, -0x4(%rbp)
setl %al
movb %al, -0x21(%rbp)
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x18006(%rip), %rdi     # 0x466ae
movl $0x21, %esi
leaq 0x1803b(%rip), %rdx     # 0x466ef
movzbl %al, %ecx
callq 0xb210
movslq -0x4(%rbp), %rcx
leaq 0x3bfa9(%rip), %rax     # 0x6a670
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb 0x8(%rax), %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x17fc3(%rip), %rdi     # 0x466ae
movl $0x23, %esi
leaq 0x1805d(%rip), %rdx     # 0x46754
movzbl %al, %ecx
callq 0xb270
movq -0x10(%rbp), %rax
movb 0x8(%rax), %al
cmpb $0x0, %al
jne 0x2e70f
jmp 0x2e844
movq -0x10(%rbp), %rax
movb $0x0, 0x8(%rax)
callq 0x30da0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq %rcx, %rax
jae 0x2e773
movq 0x3a8a8(%rip), %rax     # 0x68fe0
movq (%rax), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rax
leaq 0x17526(%rip), %rdi     # 0x45c6f
leaq 0x17f5e(%rip), %rdx     # 0x466ae
movl $0x28, %ecx
leaq 0x18029(%rip), %r8      # 0x46785
leaq 0x18033(%rip), %r9      # 0x46796
movq %rax, (%rsp)
movb $0x0, %al
callq 0xb100
jmp 0x2e844
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
subq %rcx, %rax
movq %rax, %xmm1
movaps 0x17282(%rip), %xmm0    # 0x45a10
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x17286(%rip), %xmm0    # 0x45a20
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x10(%rbp), %rax
movb 0x9(%rax), %al
cmpb $0x0, %al
je 0x2e844
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd 0x17271(%rip), %xmm1    # 0x45a48
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm1
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rax)
movsd -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rcx
addq %rdx, %rcx
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x10(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)