//
// LevelBrowserLayer::onSearch from 0x6e6fcc to 0x6e739c (976 bytes)
//
// 3 xrefs:
// > ??> @ 0x847f8
// > LevelBrowserLayer::init @ 0x6eb984
// > ??> @ 0x122c788
//
// 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
//
void LevelBrowserLayer::onSearch(LevelBrowserLayer *a1, cocos2d::CCObject *a2)
{
GJSearchObject *m_searchObject; // x0
char *v4; // x1
bool v5; // w6
__int64 v6; // x22
void *v7; // x0
void *v8; // x0
void *v9; // x0
void *v10; // x0
_BOOL4 m_isOverlay; // w0
void *v12; // x0
unsigned int *v13; // x1
int v14; // w2
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x1
int v18; // w2
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
__int64 v23; // [xsp+70h] [xbp+70h] BYREF
__int64 v24; // [xsp+78h] [xbp+78h] BYREF
__int64 v25; // [xsp+80h] [xbp+80h] BYREF
__int64 v26; // [xsp+88h] [xbp+88h] BYREF
__int64 v27; // [xsp+90h] [xbp+90h] BYREF
m_searchObject = a1->m_searchObject;
if ( m_searchObject && m_searchObject->m_searchType == SmartTemplates )
v4 = "Find Template";
else
v4 = "Find Level";
sub_D153B8((int)&v23, v4);
sub_D153B8((int)&v24, &byte_F288A0);
sub_D153B8((int)&v25, "Search");
sub_D18D28(&v26, &v23);
sub_D153B8((int)&v27, "OK");
v6 = SetTextPopup::create(
(SetTextPopup *)&v24,
(std::string)&v25,
(std::string)20LL,
(int)&v26,
(std::string)&v27,
(std::string)1LL,
v5,
60.0);
v7 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v27 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v7);
}
v8 = (void *)(v26 - 24);
if ( (__int64 *)(v26 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v26 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v26 - 8);
*(_DWORD *)(v26 - 8) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v8);
}
v9 = (void *)(v25 - 24);
if ( (__int64 *)(v25 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v25 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v25 - 8);
*(_DWORD *)(v25 - 8) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v9);
}
v10 = (void *)(v24 - 24);
if ( (__int64 *)(v24 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v24 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v24 - 8);
*(_DWORD *)(v24 - 8) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v10);
}
m_isOverlay = a1->m_isOverlay;
*(_QWORD *)(v6 + 664) = &a1->SetTextPopupDelegate;
if ( m_isOverlay )
*(_DWORD *)(v6 + 584) = ((__int64 (__fastcall *)(LevelBrowserLayer *))a1->getZOrder)(a1) + 1;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 1288LL))(v6);
v12 = (void *)(v23 - 24);
if ( (__int64 *)(v23 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v23 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *(_DWORD *)(v23 - 8);
*(_DWORD *)(v23 - 8) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v12);
}
}