//
// cocos2d::CCTurnOffTiles::startWithTarget from 0x10089c640 to 0x10089c74f (271 bytes)
//
// 1 xrefs:
// > ??> @ 0x100ba8e98
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:37:09 +0000
//
unsigned __int64 __fastcall cocos2d::CCTurnOffTiles::startWithTarget(__int64 a1)
{
unsigned int v2; // edi
unsigned int v3; // r12d
unsigned __int64 result; // rax
_DWORD *v5; // rbx
__int64 v6; // rax
__m128i v7; // xmm0
unsigned __int64 v8; // rcx
__m128i v9; // xmm1
__m128i v10; // xmm2
__int64 v11; // r14
int v12; // eax
__int64 v13; // rdx
cocos2d::CCGridAction::startWithTarget(a1);
v2 = *(_DWORD *)(a1 + 100);
if ( v2 != -1 )
srand(v2);
v3 = (int)(float)(*(float *)(a1 + 92) * *(float *)(a1 + 96));
*(_DWORD *)(a1 + 104) = v3;
result = (unsigned __int64)operator new[](4LL * v3);
*(_QWORD *)(a1 + 112) = result;
if ( v3 )
{
v5 = (_DWORD *)result;
if ( v3 >= 8 )
{
v6 = v3 & 0xFFFFFFF8;
v7 = _mm_cvtepi8_epi32(50462976);
v8 = 0;
v9 = _mm_cvtepi8_epi32(67372036);
v10 = _mm_cvtepi8_epi32(134744072);
do
{
*(__m128i *)&v5[v8 / 4] = v7;
*(__m128i *)&v5[v8 / 4 + 4] = _mm_add_epi32(v7, v9);
v7 = _mm_add_epi32(v7, v10);
v8 += 32LL;
}
while ( ((4LL * v3) & 0xFFFFFFFFFFFFFFE0LL) != v8 );
if ( (_DWORD)v6 == v3 )
{
LABEL_10:
result = v3 - 1;
if ( (int)(v3 - 1) >= 0 )
{
v11 = (unsigned int)result;
do
{
v12 = rand();
v13 = (unsigned int)(v12 >> 31);
LODWORD(v13) = v12 % (int)v3;
result = (unsigned int)v5[v11];
v5[v11] = v5[v13];
v5[v13] = result;
--v3;
}
while ( v11-- != 0 );
}
return result;
}
}
else
{
v6 = 0;
}
do
{
v5[v6] = v6;
++v6;
}
while ( v3 != v6 );
goto LABEL_10;
}
return result;
}