//
// SecretLayer4::selectAThread from 0x10039d7d0 to 0x10039d8bd (237 bytes)
//
// 3 xrefs:
// > SecretLayer4::init @ 0x10039a5ce
// > sub_10039B170 @ 0x10039b1c4
// > SecretLayer4::onSubmit @ 0x10039ba88
//
// 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:29:19 +0000
//
__int64 __fastcall SecretLayer4::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 + 480));
v2 = v1;
v3 = *(_DWORD *)(a1 + 432);
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 + 432) = v4;
if ( v4 >= (unsigned int)sub_1007FEF90(v2) )
*(_DWORD *)(a1 + 432) = 0;
result = cocos2d::CCDictionary::count(*(_QWORD *)(a1 + 480));
if ( (_DWORD)result )
{
v8 = sub_1007FEFE0(v2, *(unsigned int *)(a1 + 432));
v9 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a1 + 480), *(int *)(v8 + 56));
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 64LL))(v9);
*(_DWORD *)(a1 + 440) = result;
}
*(_DWORD *)(a1 + 444) = 0;
return result;
}