//
// AudioEffectsLayer::init from 0x1003c4418 to 0x1003c4674 (604 bytes)
//
// 1 xrefs:
// > AudioEffectsLayer::create @ 0x1003c439c
//
// 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
//
bool __fastcall AudioEffectsLayer::init(__int64 a1, char *a2)
{
_BOOL8 v4; // x20
cocos2d::CCObject *v5; // x21
std::string *p_str; // x8
std::string::size_type size; // x23
std::string *v8; // x9
std::string::size_type v9; // x11
std::string *v10; // x10
__int64 v11; // x8
__int64 v12; // x24
std::string::size_type v13; // x22
std::string *v14; // x1
__int64 v15; // x26
bool v16; // zf
std::string::size_type v17; // x11
std::string *v18; // x8
_BYTE *v19; // x9
_BYTE *v20; // x10
std::string::size_type v21; // x11
__int64 v22; // x8
cocos2d::CCTextureCache *v23; // x0
cocos2d::CCTexture2D *v24; // x0
cocos2d::CCSpriteBatchNode *v25; // x0
std::string __str; // [xsp+8h] [xbp-88h] BYREF
std::allocator __a[24]; // [xsp+20h] [xbp-70h] BYREF
std::string v29; // [xsp+38h] [xbp-58h] BYREF
LODWORD(v29.__r_.__value_.__l.__data_) = 0;
v4 = cocos2d::CCLayerColor::initWithColor((cocos2d::CCLayerColor *)a1, (const cocos2d::ccColor4B *)&v29);
if ( !v4 )
return v4;
if ( a2[23] < 0 )
a2 = *(char **)a2;
sub_100009900(&__str, a2);
v5 = sub_10024A15C();
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_str = &__str;
else
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
else
size = __str.__r_.__value_.__l.__size_;
if ( size )
{
v8 = (std::string *)((char *)p_str + size);
v9 = size;
v10 = p_str;
while ( v10->__r_.__value_.__s.__data_[0] != 126 )
{
v10 = (std::string *)((char *)v10 + 1);
if ( !--v9 )
{
v10 = (std::string *)((char *)p_str + size);
break;
}
}
v11 = (char *)v10 - (char *)p_str;
if ( v10 == v8 )
v12 = -1;
else
v12 = v11;
}
else
{
v12 = -1;
}
v13 = 0;
do
{
std::string::basic_string(&v29, &__str, v13, v12 - v13, __a);
if ( SHIBYTE(v29.__r_.__value_.__r.__words[2]) < 0 )
{
if ( v13 == size && !v29.__r_.__value_.__l.__size_ )
goto LABEL_29;
v14 = (std::string *)v29.__r_.__value_.__r.__words[0];
}
else
{
if ( v13 == size && !*((_BYTE *)&v29.__r_.__value_.__s + 23) )
goto LABEL_29;
v14 = &v29;
}
sub_100009900(__a, (char *)v14);
sub_100268E48((__int128 *)__a);
sub_10024A2D0((__int64)v5);
if ( (*(_BYTE *)&__a[23].std::__non_trivial_if & 0x80000000) != 0 )
operator delete(*(void **)&__a[0].std::__non_trivial_if);
LABEL_29:
if ( v12 == -1 )
goto LABEL_30;
v13 = v12 + 1;
v17 = __str.__r_.__value_.__l.__size_;
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = &__str;
else
v18 = (std::string *)__str.__r_.__value_.__r.__words[0];
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v17 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( v17 <= v13 )
{
LABEL_30:
v15 = -1;
}
else
{
v19 = (char *)v18 + v17;
v20 = (char *)v18 + v13;
v21 = ~v12 + v17;
while ( *v20 != 126 )
{
++v20;
if ( !--v21 )
{
v20 = v19;
break;
}
}
v22 = v20 - (_BYTE *)v18;
if ( v20 == v19 )
v15 = -1;
else
v15 = v22;
}
if ( SHIBYTE(v29.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v29.__r_.__value_.__l.__data_);
v16 = v12 == -1;
v12 = v15;
}
while ( !v16 );
*(_QWORD *)(a1 + 552) = v5;
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(__str.__r_.__value_.__l.__data_);
v5 = *(cocos2d::CCObject **)(a1 + 552);
}
cocos2d::CCObject::retain(v5);
AudioEffectsLayer::resetAudioVars((AudioEffectsLayer *)a1);
v23 = cocos2d::CCTextureCache::sharedTextureCache();
v24 = cocos2d::CCTextureCache::addImage(v23, "GJ_GameSheet.png", 0);
v25 = cocos2d::CCSpriteBatchNode::createWithTexture(v24, 0x1Du);
*(_QWORD *)(a1 + 544) = v25;
(*(void (__fastcall **)(__int64, cocos2d::CCSpriteBatchNode *))(*(_QWORD *)a1 + 440LL))(a1, v25);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 544) + 896LL))(*(_QWORD *)(a1 + 544), 0x100000302LL);
*(_DWORD *)(a1 + 580) = 1036831949;
return v4;
}