//
// SecretLayer::selectAThread from 0x1006d4940 to 0x1006d4a2d (237 bytes)
//
// 3 xrefs:
// > SecretLayer::init @ 0x1006d1f2f
// > SecretLayer::getMessage @ 0x1006d2430
// > SecretLayer::onSubmit @ 0x1006d307b
//
// 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:35:40 +0000
//
__int64 __fastcall SecretLayer::selectAThread(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r14
int v3; // r15d
unsigned int v4; // r15d
__m128 v5; // xmm0
__m128 v6; // xmm1
__int64 result; // rax
__int64 v8; // rax
__int64 v9; // rax
float v10; // [rsp+0h] [rbp-1Ch]
v1 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(a1 + 472));
v2 = v1;
v3 = *(_DWORD *)(a1 + 480);
if ( v3 < 0 )
{
v10 = (float)(int)(sub_1007FEF90(v1) - 1);
v5 = 0;
v5.f32[0] = (float)((float)rand() * 4.6566129e-10) * v10;
v6 = _mm_or_ps(_mm_and_ps((__m128)xmmword_100A035F0, v5), (__m128)xmmword_100A03600);
v6.f32[0] = v6.f32[0] + v5.f32[0];
v4 = (int)_mm_round_ss((__m128)0LL, v6, 11).f32[0];
}
else
{
v4 = v3 + 1;
}
*(_DWORD *)(a1 + 480) = v4;
if ( v4 >= (unsigned int)sub_1007FEF90(v2) )
*(_DWORD *)(a1 + 480) = 0;
result = cocos2d::CCDictionary::count(*(_QWORD *)(a1 + 472));
if ( (_DWORD)result )
{
v8 = sub_1007FEFE0(v2, *(unsigned int *)(a1 + 480));
v9 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a1 + 472), *(int *)(v8 + 56));
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 64LL))(v9);
*(_DWORD *)(a1 + 428) = result;
}
*(_DWORD *)(a1 + 432) = 0;
return result;
}