//
// SecretRewardsLayer::switchToOpenedState from 0x100384bf4 to 0x100384cd4 (224 bytes)
//
// 5 xrefs:
// > SecretRewardsLayer::init @ 0x100383d14
// > SecretRewardsLayer::init @ 0x1003842a4
// > sub_100385500 @ 0x1003856dc
// > SecretRewardsLayer::generateChestItems @ 0x100386464
// > SecretRewardsLayer::onSelectItem @ 0x100386684
//
// 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
//
__int64 __fastcall SecretRewardsLayer::switchToOpenedState(__int64 a1, __int64 a2)
{
_DWORD *v3; // x20
__int64 v4; // x0
unsigned int *v5; // x9
__int64 v6; // x8
_QWORD *v7; // x21
unsigned __int64 v8; // x22
__int64 v9; // x20
__int16 v11; // [xsp+Ch] [xbp-34h] BYREF
char v12; // [xsp+Eh] [xbp-32h]
v3 = (_DWORD *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1072LL))(a2);
GJChestSprite::switchToState(v3, 4, 1);
v4 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)v3 + 488LL))(v3);
if ( v4 )
{
v5 = *(unsigned int **)(v4 + 56);
v6 = *v5;
if ( (_DWORD)v6 )
{
v7 = *((_QWORD **)v5 + 2);
v8 = (unsigned __int64)&v7[v6 - 1];
do
{
v9 = *v7;
if ( !*v7 )
break;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)v9 + 912LL))(*v7, 100);
v12 = -106;
v11 = -26986;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v9 + 960LL))(v9, &v11);
++v7;
}
while ( (unsigned __int64)v7 <= v8 );
}
}
return (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a2 + 1056LL))(a2, 0);
}