//
// AudioEffectsLayer::init from 0x50a618 to 0x50a874 (604 bytes)
//
// 1 xrefs:
// > AudioEffectsLayer::create @ 0x50a942
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:51:27 +0000
//
int __fastcall AudioEffectsLayer::init(AudioEffectsLayer *a1, int a2)
{
bool v4; // nf
size_t v5; // r0
cocos2d::CCArray *v6; // r0
int v7; // r3
unsigned __int8 *v8; // r2
unsigned __int8 *v9; // r3
unsigned __int8 *v10; // r1
unsigned __int8 *v11; // r4
int v12; // r5
int v13; // r4
int v14; // r6
unsigned int v15; // r5
size_t v16; // r2
unsigned int v17; // r3
std::logic_error *exception; // r4
char *v19; // r1
size_t v20; // r3
char *v21; // r1
char *v22; // r1
size_t v23; // r0
cocos2d::CCObject *v24; // r0
unsigned __int8 *v25; // r2
unsigned int v26; // r3
unsigned __int8 *v27; // r1
unsigned __int8 *v28; // r3
unsigned __int8 *v29; // r4
int v30; // r0
cocos2d::CCArray *v31; // r1
cocos2d::CCTextureCache *v32; // r0
cocos2d::CCTextureCache *v33; // r0
cocos2d::CCSpriteBatchNode *v34; // r0
unsigned int v35; // r2
int v36; // r0
int v37; // r3
int v39; // [sp+0h] [bp-44h]
cocos2d::CCArray *v40; // [sp+4h] [bp-40h]
char *v41; // [sp+Ch] [bp-38h]
_DWORD v42[2]; // [sp+10h] [bp-34h] BYREF
int v43; // [sp+18h] [bp-2Ch] BYREF
unsigned int v44; // [sp+1Ch] [bp-28h]
char *v45; // [sp+20h] [bp-24h]
int v46; // [sp+24h] [bp-20h] BYREF
int v47; // [sp+28h] [bp-1Ch]
char *v48; // [sp+2Ch] [bp-18h]
int v49[3]; // [sp+30h] [bp-14h] BYREF
v42[0] = 0;
v39 = cocos2d::CCLayerColor::initWithColor(a1, v42);
if ( v39 )
{
v4 = (*(_BYTE *)a2 & 1) != 0;
if ( (*(_BYTE *)a2 & 1) == 0 )
++a2;
v43 = 0;
if ( v4 )
a2 = *(_DWORD *)(a2 + 8);
v44 = 0;
v45 = nullptr;
v5 = strlen((const char *)a2);
v6 = (cocos2d::CCArray *)std::string::__init(&v43, (const void *)a2, v5);
v40 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
if ( (v43 & 1) != 0 )
{
v7 = v44;
v8 = (unsigned __int8 *)v45;
if ( !v44 )
{
v13 = -1;
LABEL_16:
v14 = v44;
LABEL_20:
v15 = 0;
while ( 1 )
{
v16 = v13 - v15;
v46 = 0;
v47 = 0;
v48 = nullptr;
if ( (v43 & 1) != 0 )
{
v17 = v44;
if ( v15 > v44 )
goto LABEL_25;
v19 = v45;
}
else
{
v17 = (int)(unsigned __int8)v43 >> 1;
if ( v15 > v17 )
{
LABEL_25:
exception = (std::logic_error *)_cxa_allocate_exception(8u);
std::logic_error::logic_error(exception, "basic_string");
*(_DWORD *)exception = &off_D1548C;
_cxa_throw(
exception,
(struct type_info *)&`typeinfo for'std::out_of_range,
(void (*)(void *))std::length_error::~length_error);
}
v19 = (char *)&v43 + 1;
}
v20 = v17 - v15;
v21 = &v19[v15];
if ( v16 >= v20 )
v16 = v20;
std::string::__init(&v46, v21, v16);
if ( (v46 & 1) != 0 )
{
if ( v47 || v15 != v14 )
{
v22 = v48;
LABEL_39:
v41 = v22;
memset(v49, 0, sizeof(v49));
v23 = strlen(v22);
std::string::__init(v49, v41, v23);
v24 = (cocos2d::CCObject *)cocos2d::CCString::create(v49);
cocos2d::CCArray::addObject(v40, v24);
std::string::~string((int)v49);
}
}
else if ( (unsigned __int8)v46 >> 1 || v15 != v14 )
{
v22 = (char *)&v46 + 1;
goto LABEL_39;
}
if ( v13 == -1 )
{
std::string::~string((int)&v46);
*((_DWORD *)a1 + 111) = v40;
std::string::~string((int)&v43);
cocos2d::CCObject::retain(*((cocos2d::CCObject **)a1 + 111));
v32 = (cocos2d::CCTextureCache *)AudioEffectsLayer::resetAudioVars(a1, v31);
v33 = (cocos2d::CCTextureCache *)cocos2d::CCTextureCache::sharedTextureCache(v32);
v34 = (cocos2d::CCSpriteBatchNode *)cocos2d::CCTextureCache::addImage(v33, "GJ_GameSheet.png", 0);
v36 = cocos2d::CCSpriteBatchNode::createWithTexture(
v34,
(cocos2d::CCTexture2D *)((char *)&dword_1C + 1),
v35);
v37 = *(_DWORD *)a1;
*((_DWORD *)a1 + 110) = v36;
(*(void (__fastcall **)(AudioEffectsLayer *, int))(v37 + 228))(a1, v36);
v42[0] = 770;
v42[1] = 1;
(*(void (__fastcall **)(int, int, int))(**((_DWORD **)a1 + 110) + 456))(*((_DWORD *)a1 + 110), 770, 1);
*((_DWORD *)a1 + 116) = 1036831949;
return v39;
}
v15 = v13 + 1;
if ( (v43 & 1) != 0 )
{
v25 = (unsigned __int8 *)v45;
v26 = v44;
}
else
{
v26 = (int)(unsigned __int8)v43 >> 1;
v25 = (unsigned __int8 *)&v43 + 1;
}
if ( v15 < v26 )
{
v27 = &v25[v15];
v28 = &v25[v26];
while ( 1 )
{
v29 = v27;
if ( v27 == v28 )
break;
v30 = *v27++;
if ( v30 == 126 )
{
v13 = v29 - v25;
goto LABEL_49;
}
}
}
v13 = -1;
LABEL_49:
std::string::~string((int)&v46);
}
}
}
else
{
v7 = (int)(unsigned __int8)v43 >> 1;
if ( !v7 )
{
v13 = -1;
goto LABEL_19;
}
v8 = (unsigned __int8 *)&v43 + 1;
}
v9 = &v8[v7];
v10 = v8;
while ( 1 )
{
v11 = v10;
if ( v10 == v9 )
break;
v12 = *v10++;
if ( v12 == 126 )
{
v13 = v11 - v8;
goto LABEL_13;
}
}
v13 = -1;
LABEL_13:
if ( (v43 & 1) != 0 )
goto LABEL_16;
LABEL_19:
v14 = (int)(unsigned __int8)v43 >> 1;
goto LABEL_20;
}
return v39;
}