//
// sub_1005121E4 from 0x1005121e4 to 0x100512480 (668 bytes)
//
// 1 xrefs:
// > ThreadSearchPopup::init @ 0x100511cb4
//
// 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 11:07:03 +0000
//
void __fastcall sub_1005121E4(_QWORD *a1)
{
__int64 v2; // x0
std::string::size_type size; // x8
std::string *p_str; // x9
std::string::size_type v5; // x2
char *v6; // x9
int v7; // w10
std::string::size_type v8; // x8
unsigned int v9; // w9
std::string *v10; // x10
std::string::value_type v11; // t1
__int64 v12; // x19
_QWORD *v13; // x0
void **v14; // x8
__int64 v15; // x0
__int64 v16; // x19
_QWORD *v17; // x0
__int64 v18; // x20
void *v19[2]; // [xsp+8h] [xbp-A8h] BYREF
char v20; // [xsp+1Fh] [xbp-91h]
_QWORD v21[2]; // [xsp+20h] [xbp-90h] BYREF
char v22; // [xsp+37h] [xbp-79h]
void *__p[2]; // [xsp+38h] [xbp-78h] BYREF
char v24; // [xsp+4Fh] [xbp-61h]
_QWORD v25[2]; // [xsp+50h] [xbp-60h] BYREF
char v26; // [xsp+67h] [xbp-49h]
std::string v27; // [xsp+68h] [xbp-48h] BYREF
std::string __str; // [xsp+80h] [xbp-30h] BYREF
std::allocator __a; // [xsp+9Fh] [xbp-11h] BYREF
v2 = a1[128];
if ( v2 )
CCTextInputNode::getString(v2, &__str);
else
sub_100009900(&__str, "");
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
p_str = &__str;
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
{
size = __str.__r_.__value_.__l.__size_;
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
}
if ( size )
{
v5 = 0;
while ( p_str->__r_.__value_.__s.__data_[v5] == 32 )
{
if ( size == ++v5 )
goto LABEL_10;
}
}
else
{
LABEL_10:
v5 = -1;
}
v6 = (char *)&p_str[-1].__r_.__value_.__r.__words[2] + 7;
while ( size )
{
v7 = (unsigned __int8)v6[size--];
if ( v7 != 32 )
goto LABEL_16;
}
size = -1;
LABEL_16:
if ( v5 == -1 )
sub_100009900(&v27, "");
else
std::string::basic_string(&v27, &__str, v5, size - v5 + 1, &__a);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
__str = v27;
v8 = HIBYTE(v27.__r_.__value_.__r.__words[2]);
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v8 = __str.__r_.__value_.__l.__size_;
if ( !v8 )
goto LABEL_30;
v9 = 0;
v10 = &__str;
if ( (v27.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v10 = (std::string *)__str.__r_.__value_.__r.__words[0];
do
{
v11 = v10->__r_.__value_.__s.__data_[0];
v10 = (std::string *)((char *)v10 + 1);
if ( (v11 & 0xC0) != 0x80 )
++v9;
--v8;
}
while ( v8 );
if ( v9 >= 2 )
{
v15 = GameLevelManager::sharedState();
if ( (unsigned int)sub_1000ADD00(v15, "threadSearch", 3.0) - 1 > 2 )
{
v18 = a1[127];
(*(void (__fastcall **)(_QWORD *, _QWORD))(*a1 + 1368LL))(a1, 0);
sub_1004FB1D8(v18, (__int64)&__str);
}
else
{
v16 = *(_QWORD *)(cocos2d::CCDirector::sharedDirector() + 272);
sub_100009900(v21, "Please wait");
sub_100009900(v19, "");
v17 = TextAlertPopup::create((__int64)v21, 150, (__int64)v19, 0.5, 0.6);
(*(void (__fastcall **)(__int64, _QWORD *, __int64))(*(_QWORD *)v16 + 464LL))(v16, v17, 1000);
if ( v20 < 0 )
operator delete(v19[0]);
if ( v22 < 0 )
{
v14 = (void **)v21;
goto LABEL_34;
}
}
}
else
{
LABEL_30:
v12 = *(_QWORD *)(cocos2d::CCDirector::sharedDirector() + 272);
sub_100009900(v25, "Enter at least 2 characters");
sub_100009900(__p, "");
v13 = TextAlertPopup::create((__int64)v25, 150, (__int64)__p, 0.5, 0.6);
(*(void (__fastcall **)(__int64, _QWORD *, __int64))(*(_QWORD *)v12 + 464LL))(v12, v13, 1000);
if ( v24 < 0 )
operator delete(__p[0]);
if ( v26 < 0 )
{
v14 = (void **)v25;
LABEL_34:
operator delete(*v14);
}
}
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}