//
// ThreadSearchPopup::onSearch from 0xc78b98 to 0xc79028 (1168 bytes)
//
// 3 xrefs:
// > ??> @ 0xe1370
// > ThreadSearchPopup::init @ 0xc6fc08
// > ??> @ 0x1546c28
//
// This function is hookable on this platform (idp: arm, 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 13:05:34 +0000
//
__int64 __fastcall ThreadSearchPopup::onSearch(ThreadSearchPopup *this, cocos2d::CCObject *a2)
{
CCTextInputNode *v3; // x0
unsigned __int64 v4; // x0
char *v5; // x3
_BYTE *v6; // x2
unsigned __int64 v7; // x2
char *v8; // x0
int v9; // w1
char *v10; // x0
int v11; // t1
__int64 v12; // x0
cocos2d::CCDirector *v13; // x0
int v14; // w2
char *i; // x1
char v16; // w1
__int64 *v17; // x1
_BYTE *v18; // x3
GameLevelManager *v19; // x0
cocos2d::CCDirector *v20; // x0
__int64 *v21; // x19
__int64 v22; // x3
void (__fastcall *v23)(__int64 *, __int64, __int64); // x23
__int64 v24; // x0
__int64 v26; // x2
ThreadSearchPopup *v27; // x0
__int64 v28; // x21
__int64 *v29; // x19
__int64 v30; // x3
void (__fastcall *v31)(__int64 *, __int64, __int64); // x23
__int64 v32; // x0
__int64 v33; // [xsp+48h] [xbp+48h] BYREF
unsigned __int64 v34; // [xsp+50h] [xbp+50h]
void *v35; // [xsp+58h] [xbp+58h]
__int64 v36; // [xsp+60h] [xbp+60h] BYREF
unsigned __int64 v37; // [xsp+68h] [xbp+68h]
char *v38; // [xsp+70h] [xbp+70h]
__int64 v39[2]; // [xsp+78h] [xbp+78h] BYREF
void *v40; // [xsp+88h] [xbp+88h]
__int64 v41[2]; // [xsp+90h] [xbp+90h] BYREF
void *v42; // [xsp+A0h] [xbp+A0h]
__int64 v43[2]; // [xsp+A8h] [xbp+A8h] BYREF
void *v44; // [xsp+B8h] [xbp+B8h]
__int64 v45[2]; // [xsp+C0h] [xbp+C0h] BYREF
void *v46; // [xsp+D0h] [xbp+D0h]
v3 = *((CCTextInputNode **)this + 128);
if ( v3 )
{
CCTextInputNode::getString(v3, &v33);
}
else
{
v33 = 0;
v34 = 0;
v35 = nullptr;
std::string::__init(&v33, &byte_11B8890, 0);
}
if ( (v33 & 1) != 0 )
{
v4 = v34;
v5 = (char *)v35;
v6 = v35;
if ( !v34 || (v17 = (__int64 *)((char *)v35 + v34), v35 == (char *)v35 + v34) )
{
v7 = -1;
goto LABEL_6;
}
goto LABEL_28;
}
LODWORD(v4) = (int)(unsigned __int8)v33 >> 1;
if ( (_DWORD)v4 )
{
v6 = (char *)&v33 + 1;
v17 = (__int64 *)((char *)&v33 + (int)v4 + 1);
if ( v17 == (__int64 *)((char *)&v33 + 1) )
{
v7 = -1;
goto LABEL_26;
}
LABEL_28:
v18 = v6;
if ( *v6 == 32 )
{
do
{
if ( v17 == (__int64 *)++v18 )
{
v7 = -1;
goto LABEL_33;
}
}
while ( *v18 == 32 );
v7 = v18 - v6;
}
else
{
v7 = 0;
}
LABEL_33:
LODWORD(v4) = (int)(unsigned __int8)v33 >> 1;
if ( (v33 & 1) != 0 )
{
v5 = (char *)v35;
v4 = v34;
goto LABEL_6;
}
LABEL_26:
v4 = (int)v4;
v5 = (char *)&v33 + 1;
goto LABEL_6;
}
v4 = 0;
v7 = -1;
v5 = (char *)&v33 + 1;
LABEL_6:
v8 = &v5[v4];
if ( v5 != v8 )
{
v9 = (unsigned __int8)*(v8 - 1);
v10 = v8 - 1;
if ( v9 != 32 )
{
LABEL_45:
v12 = v10 - v5;
if ( v7 == -1 )
goto LABEL_46;
LABEL_12:
std::string::basic_string(&v36, (__int64)&v33, v7, v12 - v7 + 1);
goto LABEL_13;
}
while ( v10 != v5 )
{
v11 = (unsigned __int8)*--v10;
if ( v11 != 32 )
goto LABEL_45;
}
}
v12 = -1;
if ( v7 != -1 )
goto LABEL_12;
LABEL_46:
v36 = 0;
v37 = 0;
v38 = nullptr;
std::string::__init(&v36, &byte_11B8890, 0);
LABEL_13:
if ( (v33 & 1) != 0 )
{
*(_BYTE *)v35 = 0;
v34 = 0;
}
else
{
LOWORD(v33) = 0;
}
std::string::reserve(&v33, 0);
v33 = v36;
v34 = v37;
v13 = nullptr;
v14 = 0;
v35 = v38;
if ( (v36 & 1) == 0 )
goto LABEL_21;
while ( (unsigned __int64)v13 < v37 )
{
for ( i = v38; ; i = (char *)&v33 + 1 )
{
v16 = *((_BYTE *)v13 + (_QWORD)i);
v13 = (cocos2d::CCDirector *)((char *)v13 + 1);
if ( (v16 & 0xC0) != 0x80 )
++v14;
if ( (v36 & 1) != 0 )
break;
LABEL_21:
if ( (unsigned __int64)v13 >= (unsigned __int8)v36 >> 1 )
goto LABEL_36;
}
}
LABEL_36:
if ( v14 <= 1 )
{
v29 = *(__int64 **)(cocos2d::CCDirector::sharedDirector(v13) + 272);
v30 = *v29;
v39[0] = 0;
v39[1] = 0;
v31 = *(void (__fastcall **)(__int64 *, __int64, __int64))(v30 + 464);
v40 = nullptr;
std::string::__init(v39, "Enter at least 2 characters", 0x1Bu);
v41[0] = 0;
v41[1] = 0;
v42 = nullptr;
std::string::__init(v41, &byte_11B8890, 0);
v32 = TextAlertPopup::create((char *)v39, 150, (char *)v41, 0.5, 0.6);
v31(v29, v32, 1000);
if ( (v41[0] & 1) != 0 )
operator delete(v42);
if ( (v39[0] & 1) != 0 )
operator delete(v40);
}
else
{
v19 = (GameLevelManager *)GameLevelManager::sharedState(v13);
v20 = (cocos2d::CCDirector *)((unsigned int)GameLevelManager::getTimeLeft(v19, "threadSearch", 3.0) - 1);
if ( (unsigned int)v20 > 2 )
{
v26 = *(_QWORD *)this;
v27 = this;
v28 = *((_QWORD *)this + 127);
(*(void (__fastcall **)(ThreadSearchPopup *, _QWORD))(v26 + 1368))(v27, 0);
ThreadViewPopup::startSearch(v28, (__int64)&v33);
if ( (v33 & 1) == 0 )
return _stack_chk_guard;
LABEL_48:
operator delete(v35);
return _stack_chk_guard;
}
v21 = *(__int64 **)(cocos2d::CCDirector::sharedDirector(v20) + 272);
v22 = *v21;
v43[0] = 0;
v43[1] = 0;
v23 = *(void (__fastcall **)(__int64 *, __int64, __int64))(v22 + 464);
v44 = nullptr;
std::string::__init(v43, "Please wait", 0xBu);
v45[0] = 0;
v45[1] = 0;
v46 = nullptr;
std::string::__init(v45, &byte_11B8890, 0);
v24 = TextAlertPopup::create((char *)v43, 150, (char *)v45, 0.5, 0.6);
v23(v21, v24, 1000);
if ( (v45[0] & 1) != 0 )
operator delete(v46);
if ( (v43[0] & 1) != 0 )
operator delete(v44);
}
if ( (v33 & 1) != 0 )
goto LABEL_48;
return _stack_chk_guard;
}