//
// GJBaseGameLayer::claimParticle from 0x1402409d0 to 0x140240bd1 (513 bytes)
//
// 2 xrefs:
// > GameObject::claimParticle @ 0x140198ef8
// > ??> @ 0x1406ce3dc
//
// 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
//
// Hidden C++ exception states: #wind=3
struct cocos2d::CCObject *__fastcall GJBaseGameLayer::claimParticle(__int64 a1, _QWORD *a2)
{
__int64 v2; // rdi
size_t v4; // r8
cocos2d::CCArray *v5; // r14
void *v6; // rcx
struct cocos2d::CCObject *Object; // rsi
const char *v8; // rax
__int64 v9; // rcx
_QWORD *ParticleKey2; // rax
cocos2d::CCArray *v11; // rbx
__int64 *v12; // r14
__int64 v13; // rax
__int64 v14; // rbx
unsigned int v15; // eax
__int64 v16; // rdx
_BYTE v18[32]; // [rsp+28h] [rbp-90h] BYREF
_QWORD *v19; // [rsp+48h] [rbp-70h]
void *Block[2]; // [rsp+50h] [rbp-68h] BYREF
__m128i si128; // [rsp+60h] [rbp-58h]
_QWORD v22[4]; // [rsp+70h] [rbp-48h] BYREF
v2 = (__int64)a2;
v19 = a2;
if ( a2[3] > 0xFu )
a2 = (_QWORD *)*a2;
*(_OWORD *)Block = 0;
si128 = 0;
v4 = -1;
do
++v4;
while ( *((_BYTE *)a2 + v4) );
sub_14003A930(Block, a2, v4);
v5 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 12480), Block);
if ( si128.m128i_i64[1] > 0xFuLL )
{
v6 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v6 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v6 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v6);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Block[0]) = 0;
if ( v5 && cocos2d::CCArray::count(v5) )
{
Object = cocos2d::CCArray::lastObject(v5);
v8 = (const char *)sub_14003BDB0((__int64)v18, v2);
ParticleKey2 = GJBaseGameLayer::getParticleKey2(v9, v22, v8);
v11 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 12480), ParticleKey2);
sub_14003A830((__int64)v22);
cocos2d::CCArray::addObject(v11, Object);
cocos2d::CCArray::removeLastObject(v5, 1);
if ( !((__int64 (__fastcall *)(struct cocos2d::CCObject *))Object->__vftable[6].getTag)(Object) )
{
v12 = *(__int64 **)(a1 + 4072);
v13 = *(_QWORD *)(a1 + 12664);
if ( v13 && *(_BYTE *)(v13 + 1118) && (unsigned int)(*(_DWORD *)(v13 + 1108) - 2) <= 5 )
v12 = *(__int64 **)(a1 + 4080);
v14 = *v12;
v15 = Object->getTag(Object);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCObject *, _QWORD))(v14 + 440))(v12, Object, v15);
}
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 12576), Object);
LOBYTE(v16) = 1;
((void (__fastcall *)(struct cocos2d::CCObject *, __int64))Object->__vftable[4].update)(Object, v16);
sub_14003A830(v2);
return Object;
}
else
{
sub_14003A830(v2);
return nullptr;
}
}