//
// sub_100385500 from 0x100385500 to 0x100385738 (568 bytes)
//
// 1 xrefs:
// > sub_100384BA0 @ 0x100384bdc
//
// 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 11:03:32 +0000
//
void __fastcall sub_100385500(__int64 a1, __int64 a2)
{
int v4; // w0
std::string *v5; // x0
int v6; // w21
__int64 v7; // x0
__int64 v8; // x0
bool v9; // vf
int v10; // w21
_QWORD *v11; // x20
const char *v12; // x8
void *v13; // x0
char *CString; // x0
void *v15; // x20
__int64 v16; // x21
__int64 v17; // x0
__int64 v18; // x21
_QWORD *v19; // x20
std::string __dst; // [xsp+10h] [xbp-80h] BYREF
void *__p[2]; // [xsp+28h] [xbp-68h] BYREF
char v22; // [xsp+3Fh] [xbp-51h]
void *v23[2]; // [xsp+40h] [xbp-50h] BYREF
char v24; // [xsp+57h] [xbp-39h]
std::string v25; // [xsp+58h] [xbp-38h] BYREF
v4 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
memset(&v25, 0, sizeof(v25));
switch ( v4 )
{
case 8:
v5 = std::string::assign(&v25, "0006");
v6 = 200;
break;
case 7:
v5 = std::string::assign(&v25, "0005");
v6 = 100;
break;
case 6:
v5 = std::string::assign(&v25, "0004");
v6 = 50;
break;
default:
goto LABEL_23;
}
v7 = GameStatsManager::sharedState(v5);
v8 = cocos2d::CCDictionary::count(*(_QWORD *)(v7 + 760));
v9 = __OFSUB__(v6, (_DWORD)v8);
v10 = v6 - v8;
if ( (v10 < 0) ^ v9 | (v10 == 0) )
{
v16 = GameStatsManager::sharedState(v8);
if ( SHIBYTE(v25.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, v25.__r_.__value_.__l.__data_, v25.__r_.__value_.__l.__size_);
else
__dst = v25;
v17 = GameStatsManager::unlockSpecialChest(v16, &__dst);
v18 = v17;
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__dst.__r_.__value_.__l.__data_);
if ( !v18 )
goto LABEL_23;
}
else if ( !v17 )
{
goto LABEL_23;
}
SecretRewardsLayer::switchToOpenedState(v17, a2);
v19 = RewardUnlockLayer::create(*(unsigned int *)(v18 + 64), 0);
(*(void (__fastcall **)(__int64, _QWORD *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v19, 100);
RewardUnlockLayer::showCollectReward((__int64)v19, v18);
goto LABEL_23;
}
v11 = sub_1002E736C();
sub_100009900(v23, "The Keymaster");
v12 = "Chests";
if ( v10 == 1 )
v12 = "Chest";
v13 = sub_1003065B0("Unlock %i more %s, and you can collect this bonus.", v10, v12);
CString = (char *)cocos2d::CCString::getCString((__int64)v13);
sub_100009900(__p, CString);
DialogObject::create((__int64)v23, (__int64)__p, 2, 0, 0xFFFFFF, 1.0);
sub_1002E74E0((__int64)v11);
if ( v22 < 0 )
operator delete(__p[0]);
if ( v24 < 0 )
operator delete(v23[0]);
v15 = DialogLayer::createWithObjects((__int64)v11, 2);
(*(void (__fastcall **)(__int64, void *, __int64))(*(_QWORD *)a1 + 464LL))(a1, v15, 100);
DialogLayer::updateChatPlacement((__int64)v15, 0);
DialogLayer::animateInRandomSide((__int64)v15);
LABEL_23:
if ( SHIBYTE(v25.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v25.__r_.__value_.__l.__data_);
}