//
// GJSmartTemplate::getTotalChanceForPrefab from 0x100412a40 to 0x100412adf (159 bytes)
//
// 3 xrefs:
// > GJSmartTemplate::getRandomPrefab @ 0x10041136c
// > BrowseSmartKeyLayer::init @ 0x1004e5a27
// > BrowseSmartKeyLayer::updateChanceValues @ 0x1004e696b
//
// 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:30:10 +0000
//
__int64 __fastcall GJSmartTemplate::getTotalChanceForPrefab(__int64 a1, __int128 *a2)
{
__int64 v2; // r14
unsigned int v3; // ebx
unsigned int *v4; // rax
__int64 v5; // rcx
unsigned __int64 v6; // rax
unsigned __int64 v7; // rcx
__int128 v9; // [rsp+0h] [rbp-30h] BYREF
void *__p; // [rsp+10h] [rbp-20h]
if ( (*(_BYTE *)a2 & 1) != 0 )
{
sub_10001AD30(&v9, *((const void **)a2 + 2), *((_QWORD *)a2 + 1));
}
else
{
__p = *((void **)a2 + 2);
v9 = *a2;
}
v2 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 56), (char *)&v9);
if ( (v9 & 1) != 0 )
operator delete(__p);
v3 = 0;
if ( v2 )
{
if ( (unsigned int)sub_1007FEF90(v2) )
{
v4 = *(unsigned int **)(v2 + 56);
v5 = *v4;
if ( *v4 )
{
v6 = *((_QWORD *)v4 + 2);
v7 = v6 + 8 * v5 - 8;
v3 = 0;
do
{
if ( !*(_QWORD *)v6 )
break;
v3 += *(_DWORD *)(*(_QWORD *)v6 + 108LL);
v6 += 8LL;
}
while ( v6 <= v7 );
}
}
}
return v3;
}