//
// CustomSongLayer::onSearch from 0x140164a50 to 0x140164e3b (1003 bytes)
//
// 2 xrefs:
// > CustomSongLayer::init @ 0x1401647ae
// > ??> @ 0x140917e4c
//
// This function is hookable on this platform (idp: pc, 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:27:26 +0000
//
// Hidden C++ exception states: #wind=6
void __fastcall CustomSongLayer::onSearch(__int64 a1)
{
__int64 v2; // rcx
__int64 v3; // r8
__int64 v4; // rcx
_QWORD *v5; // r8
_OWORD *v6; // rcx
const char *v7; // rax
__int64 v8; // rdx
__int64 v9; // rax
cocos2d::CCObject *v10; // rbx
_QWORD *v11; // rbx
__int64 v12; // rcx
__int64 v13; // rcx
_BYTE *v14; // rax
size_t v15; // r8
const char *v16; // rcx
unsigned int v17; // eax
cocos2d::CCObject *v18; // rdi
__int64 v19; // rbx
__int64 v20; // rcx
cocos2d::CCObject *v21; // rax
cocos2d::CCObject *v22; // rcx
int v23; // ecx
char *v24; // rcx
void *v25; // [rsp+50h] [rbp-39h]
void *v26; // [rsp+50h] [rbp-39h]
__int128 v27; // [rsp+58h] [rbp-31h] BYREF
__int64 v28; // [rsp+68h] [rbp-21h]
__int64 v29; // [rsp+70h] [rbp-19h]
void *v30; // [rsp+78h] [rbp-11h]
_BYTE v31[32]; // [rsp+80h] [rbp-9h] BYREF
char *String[2]; // [rsp+A0h] [rbp+17h] BYREF
__int64 v33; // [rsp+B0h] [rbp+27h]
unsigned __int64 v34; // [rsp+B8h] [rbp+2Fh]
v2 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v25 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v2 = qword_14090BFD0;
}
if ( (unsigned __int8)GameManager::getGameVariable(v2, "0051") )
{
v11 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v30 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v11 = (_QWORD *)qword_14090BF60;
}
v12 = v11[69];
if ( v12 )
FMOD::ChannelControl::stop(v12);
sub_14003EB60(v11 + 137);
sub_14003EB60(v11 + 145);
sub_14003EB60(v11 + 153);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 688) + 1032LL))(*(_QWORD *)(a1 + 688), 0);
v13 = *(_QWORD *)(*(_QWORD *)(a1 + 688) + 592LL) + 600LL;
v14 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v13 + 8LL))(v13);
*(_OWORD *)String = 0;
v33 = 0;
v34 = 0;
v15 = -1;
do
++v15;
while ( v14[v15] );
sub_14003D230(String, v14, v15);
v16 = (const char *)String;
if ( v34 > 0xF )
v16 = String[0];
v17 = atoi(v16);
v18 = (cocos2d::CCObject *)SongInfoObject::create_1(v17);
v19 = *(_QWORD *)(a1 + 696);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v19 + 376) + 336LL))(*(_QWORD *)(v19 + 376), 0);
v20 = *(_QWORD *)(v19 + 480);
if ( v20 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v20 + 336LL))(v20, 0);
v21 = *(cocos2d::CCObject **)(v19 + 336);
if ( v21 != v18 )
{
if ( v18 )
cocos2d::CCObject::retain(v18);
v22 = *(cocos2d::CCObject **)(v19 + 336);
if ( v22 )
cocos2d::CCObject::release(v22);
*(_QWORD *)(v19 + 336) = v18;
v21 = v18;
}
if ( v21 )
v23 = *((_DWORD *)v21 + 80);
else
v23 = 0;
*(_DWORD *)(v19 + 504) = v23;
CustomSongWidget::updateSongInfo(v19);
CustomSongWidget::getSongInfoIfUnloaded(*(_QWORD *)(a1 + 696));
if ( v34 > 0xF )
{
v24 = String[0];
if ( v34 + 1 >= 0x1000 )
{
v24 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v24 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v24);
}
}
else
{
v4 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v26 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v4 = qword_14090BFD0;
}
LOBYTE(v3) = 1;
GameManager::setGameVariable(v4, "0051", v3);
v27 = 0;
v5 = sub_14003D460(0x120u);
*(_QWORD *)&v27 = v5;
v28 = 273;
v29 = 287;
v6 = v5;
v7 = "There are thousands of great custom songs for you to choose from Newgrounds. Please do not upload music you did"
" not create. You are only allowed to use songs from artists that have been scouted on Newgrounds. For more info"
"rmation, please check the Audio Guidelines.";
v8 = 2;
do
{
*v6 = *(_OWORD *)v7;
v6[1] = *((_OWORD *)v7 + 1);
v6[2] = *((_OWORD *)v7 + 2);
v6[3] = *((_OWORD *)v7 + 3);
v6[4] = *((_OWORD *)v7 + 4);
v6[5] = *((_OWORD *)v7 + 5);
v6[6] = *((_OWORD *)v7 + 6);
v6 += 8;
*(v6 - 1) = *((_OWORD *)v7 + 7);
v7 += 128;
--v8;
}
while ( v8 );
*v6 = *(_OWORD *)v7;
*((_BYTE *)v6 + 16) = v7[16];
*((_BYTE *)v5 + 273) = 0;
v9 = sub_14003F4F0((__int64)v31, (__int64)&v27);
v10 = FLAlertLayer::create(0, (int)"Newgrounds Info", v9, (__int64)"OK", 0, 1136525312, 0, 0, 1065353216);
sub_14003D310((__int64)&v27);
(*(void (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)v10 + 1064LL))(v10);
}
}