//
// localStorageInit from 0xaaeaf0 to 0xaaedbc (716 bytes)
//
// 1 xrefs:
// > ??> @ 0xba018
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall localStorageInit(char *a1)
{
__int64 v3; // x0
__int64 v4; // x2
unsigned __int64 v5; // x3
void *v6; // x0
unsigned int *v7; // x1
int v8; // w2
__int64 v9; // x24
__int64 v10; // x22
int v11; // w25
void *v12; // x0
unsigned int *v13; // x21
int v14; // w1
__int64 v15; // [xsp+0h] [xbp+0h] BYREF
__int64 v16; // [xsp+60h] [xbp+60h] BYREF
__int64 v17; // [xsp+68h] [xbp+68h] BYREF
__int64 v18; // [xsp+70h] [xbp+70h] BYREF
__int64 v19; // [xsp+78h] [xbp+78h]
__int64 v20; // [xsp+80h] [xbp+80h]
if ( a1
&& *a1
&& !dword_1244BF8
&& (unsigned __int8)cocos2d::JniHelper::getStaticMethodInfo(
&v18,
"org/cocos2dx/lib/Cocos2dxLocalStorage",
"init",
"(Ljava/lang/String;Ljava/lang/String;)Z") )
{
sub_D153B8((int)&v16, a1);
v3 = sub_D16A88((unsigned int)&v15 + 96, "/\\", -1, 2u);
if ( v3 != -1 )
{
v4 = v3 + 1;
v5 = *(_QWORD *)(v16 - 24);
if ( v3 + 1 > v5 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v4, v5);
sub_D14F84(&v17, &v16, v4, -1);
sub_D163D4(&v16, &v17);
v6 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v7 = (unsigned int *)(v17 - 8);
do
v8 = __ldaxr(v7);
while ( __stlxr(v8 - 1, v7) );
}
else
{
v8 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v8 - 1;
}
if ( v8 <= 0 )
operator delete(v6);
}
}
v9 = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v18 + 1336LL))(v18, v16);
v10 = (*(__int64 (__fastcall **)(__int64, char *))(*(_QWORD *)v18 + 1336LL))(v18, "data");
v11 = (unsigned __int8)_JNIEnv::CallStaticBooleanMethod(v18, v19, v20, v9, v10);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v18 + 184LL))(v18, v9);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v18 + 184LL))(v18, v10);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v18 + 184LL))(v18, v19);
if ( v11 )
dword_1244BF8 = 1;
v12 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v16 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v12);
}
}
return _stack_chk_guard;
}