//
// GJSmartTemplate::getTotalChanceForPrefab from 0xb0d35c to 0xb0d484 (296 bytes)
//
// 4 xrefs:
// > GJSmartTemplate::getRandomPrefab @ 0xb0d570
// > BrowseSmartKeyLayer::updateChanceValues @ 0xb16410
// > BrowseSmartKeyLayer::init @ 0xb18040
// > ??> @ 0xee678
//
// This function is hookable on this platform (idp: arm, 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 13:01:26 +0000
//
__int64 __fastcall GJSmartTemplate::getTotalChanceForPrefab(__int64 a1, char *a2)
{
char v4; // w0
__int64 v5; // x0
__int64 v6; // x1
cocos2d::CCArray *Prefabs; // x20
__int64 result; // x0
unsigned int *v9; // x1
unsigned int v10; // w2
__int64 *v11; // x1
__int64 *i; // x3
__int64 v13; // x2
__int64 v14; // [xsp+30h] [xbp+30h] BYREF
__int64 v15; // [xsp+38h] [xbp+38h]
void *v16; // [xsp+40h] [xbp+40h]
v14 = 0;
v4 = *a2;
v15 = 0;
v16 = nullptr;
if ( (v4 & 1) != 0 )
{
std::string::__init(&v14, *((void **)a2 + 2), *((_QWORD *)a2 + 1));
}
else
{
v5 = *(_QWORD *)a2;
v6 = *((_QWORD *)a2 + 1);
v16 = *((void **)a2 + 2);
v14 = v5;
v15 = v6;
}
Prefabs = (cocos2d::CCArray *)GJSmartTemplate::getPrefabs(a1, (__int64)&v14);
if ( (v14 & 1) != 0 )
operator delete(v16);
if ( !Prefabs || !(unsigned int)cocos2d::CCArray::count(Prefabs) )
return 0;
v9 = *((unsigned int **)Prefabs + 7);
result = 0;
v10 = *v9;
if ( *v9 )
{
v11 = *((__int64 **)v9 + 2);
for ( i = &v11[v10 - 1]; i >= v11; result = (unsigned int)(result + *(_DWORD *)(v13 + 108)) )
{
v13 = *v11;
if ( !*v11 )
break;
++v11;
}
}
return result;
}