//
// GJSmartTemplate::getTotalChanceForPrefab from 0x1403b8dd0 to 0x1403b8e90 (192 bytes)
//
// 4 xrefs:
// > GJSmartTemplate::getRandomPrefab @ 0x1403b8f2c
// > BrowseSmartKeyLayer::init @ 0x1405f1295
// > BrowseSmartKeyLayer::updateChanceValues @ 0x1405f1f92
// > ??> @ 0x140923d44
//
// 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 11:31:25 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GJSmartTemplate::getTotalChanceForPrefab(__int64 a1, __int64 a2)
{
cocos2d::CCArray *v4; // rdi
unsigned int v5; // ebx
unsigned int *v6; // rdx
__int64 v7; // rax
unsigned __int64 v8; // rdx
unsigned __int64 i; // r9
__int64 v11; // [rsp+20h] [rbp-48h]
_BYTE v12[32]; // [rsp+28h] [rbp-40h] BYREF
__int64 v13; // [rsp+48h] [rbp-20h]
v13 = a2;
v11 = sub_14003F4F0((__int64)v12, a2);
v4 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 56), v11);
sub_14003D310(v11);
v5 = 0;
if ( v4 )
{
if ( cocos2d::CCArray::count(v4) )
{
v6 = *((unsigned int **)v4 + 7);
v7 = *v6;
if ( (_DWORD)v7 )
{
v8 = *((_QWORD *)v6 + 2);
for ( i = v8 + 8 * (v7 - 1); v8 <= i; v8 += 8LL )
{
if ( !*(_QWORD *)v8 )
break;
v5 += *(_DWORD *)(*(_QWORD *)v8 + 124LL);
}
}
}
}
sub_14003D310(a2);
return v5;
}