//
// cocos2d::CCProfilingEndTimingBlock from 0xb1ec80 to 0xb1edd8 (344 bytes)
//
// 1 xrefs:
// > ??> @ 0xa0ae8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void cocos2d::CCProfilingEndTimingBlock(const char *a1)
{
cocos2d::CCProfiler_vtbl *v2; // x21
__int64 v3; // x19
char *v4; // x0
int v5; // w4
__int64 v6; // x5
int v7; // w0
int v8; // w1
int v9; // w2
__int64 v10; // x3
__int64 v11; // x3
unsigned int *v12; // x2
int v13; // w1
const char *v14; // [xsp+40h] [xbp+40h] BYREF
struct timeval tv; // [xsp+48h] [xbp+48h] BYREF
gettimeofday(&tv, nullptr);
v2 = cocos2d::CCProfiler::sharedProfiler()[1].__vftable;
sub_D153B8((int)&v14, (char *)a1);
v3 = cocos2d::CCDictionary::objectForKey((__int64)v2, &v14);
v4 = (char *)(v14 - 24);
if ( v14 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v14 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v4);
}
v5 = *(_DWORD *)(v3 + 92);
v6 = *(int *)(v3 + 64);
v7 = LODWORD(tv.tv_usec) - *(_DWORD *)(v3 + 104) + 1000000 * (LODWORD(tv.tv_sec) - *(_QWORD *)(v3 + 96));
v8 = *(_DWORD *)(v3 + 88);
v9 = v7 + *(_DWORD *)(v3 + 68);
if ( v7 >= v5 )
v5 = LODWORD(tv.tv_usec) - *(_DWORD *)(v3 + 104) + 1000000 * (LODWORD(tv.tv_sec) - *(_QWORD *)(v3 + 96));
v10 = *(_QWORD *)(v3 + 80) + v7;
*(_QWORD *)(v3 + 80) = v10;
v11 = v10 / v6;
if ( v7 <= v8 )
v8 = v7;
*(_DWORD *)(v3 + 72) = v11;
*(_DWORD *)(v3 + 88) = v8;
*(_DWORD *)(v3 + 92) = v5;
*(_DWORD *)(v3 + 68) = (int)(float)((float)v9 * 0.5);
}