//
// sub_10050A580 from 0x10050a580 to 0x10050aea0 (2336 bytes)
//
// 2 xrefs:
// > NewThreadPopup::keyDown @ 0x10050b59c
// > sub_100508F28 @ 0x100509ee4
//
// 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:06:59 +0000
//
void __fastcall sub_10050A580(__int64 a1)
{
__int64 v2; // x0
int v3; // w20
const char *v4; // x21
__int64 v6; // x0
__int64 v7; // x0
void *v8; // x0
unsigned __int128 v9; // kr00_16
std::string::size_type v10; // x2
std::string::size_type size; // x8
std::string *v12; // x9
char *v13; // x9
int v14; // w10
std::string::size_type v15; // x1
__int64 v16; // x0
unsigned __int128 v17; // kr10_16
__int64 v18; // x10
int v19; // w11
__int64 v21; // x0
void *v22; // x0
std::string::size_type v23; // x8
int v24; // w1
int v25; // w0
int v26; // w9
char *v27; // x1
__int64 v28; // x0
__int64 v29; // x0
char v30; // w8
int v31; // w20
void *v32; // x0
const std::string::value_type *v33; // x0
unsigned int i; // w21
std::string::size_type v35; // x8
__int64 v36; // x0
void *v37; // x0
const std::string::value_type *CString; // x0
size_t v39; // x21
std::string *v40; // x22
std::string *v41; // x1
void *v42; // x0
char *v43; // x0
std::string *v44; // x1
std::string::size_type v45; // x2
std::string *v46; // x0
__int128 v47; // q0
std::string *v48; // x0
__int128 v49; // q0
int v50; // w23
size_t v51; // x21
std::string *v52; // x22
std::string *v53; // x1
std::string *p_dst; // x1
std::string::size_type v55; // x2
std::string *v56; // x0
__int128 v57; // q0
std::string *v58; // x0
__int128 v59; // q0
int v60; // w10
const std::string::value_type *v61; // x1
std::string::size_type v62; // x2
std::string *v63; // x0
__int128 v64; // q0
void **v65; // x1
std::string::size_type v66; // x2
std::string *v67; // x0
__int128 v68; // q0
size_t v69; // x2
__int64 v70; // x10
int v71; // w9
std::string *p_str; // x0
const void *v73; // x1
time_t v74; // x21
__int64 v75; // x21
__int64 v76; // x22
int v77; // w23
char v78; // w20
std::string v79; // [xsp+18h] [xbp-208h] BYREF
std::string v80; // [xsp+30h] [xbp-1F0h] BYREF
std::string v81; // [xsp+50h] [xbp-1D0h] BYREF
void *__p[2]; // [xsp+70h] [xbp-1B0h] BYREF
signed __int64 v83; // [xsp+80h] [xbp-1A0h]
std::string v84; // [xsp+90h] [xbp-190h] BYREF
std::string v85; // [xsp+A8h] [xbp-178h] BYREF
std::string v86; // [xsp+C0h] [xbp-160h] BYREF
std::string v87; // [xsp+E0h] [xbp-140h] BYREF
std::string __str; // [xsp+100h] [xbp-120h] BYREF
std::string v89; // [xsp+118h] [xbp-108h] BYREF
std::string __dst; // [xsp+130h] [xbp-F0h] BYREF
_QWORD v91[2]; // [xsp+148h] [xbp-D8h] BYREF
char v92; // [xsp+15Fh] [xbp-C1h]
_QWORD v93[2]; // [xsp+160h] [xbp-C0h] BYREF
char v94; // [xsp+177h] [xbp-A9h]
_QWORD v95[2]; // [xsp+178h] [xbp-A8h] BYREF
char v96; // [xsp+18Fh] [xbp-91h]
std::string v97; // [xsp+190h] [xbp-90h] BYREF
std::string v98; // [xsp+1A8h] [xbp-78h] BYREF
_QWORD v99[2]; // [xsp+1C0h] [xbp-60h] BYREF
char v100; // [xsp+1D7h] [xbp-49h]
if ( (*(_BYTE *)(a1 + 736) & 1) != 0 )
return;
v2 = *(_QWORD *)(a1 + 728);
if ( v2 )
v3 = sub_1002E757C(v2);
else
v3 = 0;
if ( *(_BYTE *)(a1 + 737) )
v4 = "New Direct Message";
else
v4 = "New Group Chat";
if ( *(int *)(a1 + 696) <= 0 && v3 == 0 )
{
sub_100009900(v99, "Please select a recipient.");
v7 = sub_10034A8F8(0, (__int64)v4, (__int64)v99, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v7 + 1312LL))(v7);
if ( (v100 & 0x80000000) == 0 )
return;
v8 = (void *)v99[0];
goto LABEL_192;
}
if ( *(_BYTE *)(a1 + 737) || (v6 = *(_QWORD *)(a1 + 880)) == 0 )
sub_100009900(&v98, "");
else
CCTextInputNode::getString(v6, &v98);
v9 = __PAIR128__(HIBYTE(v98.__r_.__value_.__r.__words[2]), &v98);
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v9 = *(_OWORD *)&v98.__r_.__value_.__l.__data_;
if ( *((_QWORD *)&v9 + 1) )
{
v10 = 0;
while ( *(_BYTE *)(v9 + v10) == 32 )
{
if ( *((_QWORD *)&v9 + 1) == ++v10 )
goto LABEL_24;
}
}
else
{
LABEL_24:
v10 = -1;
}
std::string::erase(&v98, 0, v10);
size = HIBYTE(v98.__r_.__value_.__r.__words[2]);
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v12 = &v98;
else
v12 = (std::string *)v98.__r_.__value_.__r.__words[0];
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = v98.__r_.__value_.__l.__size_;
v13 = (char *)&v12[-1].__r_.__value_.__r.__words[2] + 7;
while ( size )
{
v14 = (unsigned __int8)v13[size--];
if ( v14 != 32 )
{
v15 = size + 1;
goto LABEL_35;
}
}
v15 = 0;
LABEL_35:
std::string::erase(&v98, v15, 0xFFFFFFFFFFFFFFFFLL);
v16 = *(_QWORD *)(a1 + 888);
if ( v16 )
CCTextInputNode::getString(v16, &v97);
else
sub_100009900(&v97, "");
if ( (*(_BYTE *)(a1 + 737) & 1) != 0 )
{
v17 = __PAIR128__(HIBYTE(v97.__r_.__value_.__r.__words[2]), &v97);
if ( (v97.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v17 = *(_OWORD *)&v97.__r_.__value_.__l.__data_;
if ( !*((_QWORD *)&v17 + 1) )
goto LABEL_49;
v18 = 0;
while ( 1 )
{
v19 = *(unsigned __int8 *)(v17 + v18);
if ( v19 != 32 && v19 != 10 )
break;
if ( *((_QWORD *)&v17 + 1) == ++v18 )
goto LABEL_49;
}
if ( v18 == -1 )
{
LABEL_49:
sub_100009900(v93, "Please enter a message.");
v21 = sub_10034A8F8(0, (__int64)v4, (__int64)v93, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v21 + 1312LL))(v21);
if ( (v94 & 0x80000000) == 0 )
goto LABEL_188;
v22 = (void *)v93[0];
goto LABEL_187;
}
v24 = EmoteSprite::maxEmotesMessage();
}
else
{
v23 = HIBYTE(v98.__r_.__value_.__r.__words[2]);
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v23 = v98.__r_.__value_.__l.__size_;
if ( !v23 )
{
sub_100009900(v95, "Please enter a subject.");
v29 = sub_10034A8F8(0, (__int64)v4, (__int64)v95, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v29 + 1312LL))(v29);
if ( (v96 & 0x80000000) == 0 )
goto LABEL_188;
v22 = (void *)v95[0];
goto LABEL_187;
}
v24 = EmoteSprite::maxEmotesComment();
}
v25 = EmoteSprite::effectiveLength(&v97, v24);
if ( *(_BYTE *)(a1 + 737) )
v26 = 500;
else
v26 = 300;
if ( v25 > v26 )
{
if ( *(_BYTE *)(a1 + 737) )
v27 = "Message is too long.";
else
v27 = "Description is too long.";
sub_100009900(v91, v27);
v28 = sub_10034A8F8(0, (__int64)v4, (__int64)v91, (__int64)"OK", 0);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v28 + 1312LL))(v28);
if ( v92 < 0 )
{
v22 = (void *)v91[0];
LABEL_187:
operator delete(v22);
goto LABEL_188;
}
goto LABEL_188;
}
if ( *(_BYTE *)(a1 + 737) )
{
sub_100009900(&__dst, "");
}
else if ( SHIBYTE(v97.__r_.__value_.__r.__words[2]) < 0 )
{
sub_1000097D0(&__dst, v97.__r_.__value_.__l.__data_, v97.__r_.__value_.__l.__size_);
}
else
{
__dst = v97;
}
if ( (*(_BYTE *)(a1 + 737) & 1) != 0 )
{
memset(&v89, 0, sizeof(v89));
goto LABEL_76;
}
std::string::assign(&v97, "");
v30 = *(_BYTE *)(a1 + 737);
memset(&v89, 0, sizeof(v89));
if ( (v30 & 1) != 0 )
{
LABEL_76:
v31 = *(_DWORD *)(a1 + 696);
if ( v31 <= 0 )
v31 = *(_DWORD *)(sub_1002E75A0(*(_QWORD *)(a1 + 728), 0) + 376);
goto LABEL_88;
}
if ( *(int *)(a1 + 696) <= 0 )
{
if ( v3 >= 1 )
{
for ( i = 0; i != v3; ++i )
{
v35 = HIBYTE(v89.__r_.__value_.__r.__words[2]);
if ( (v89.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v35 = v89.__r_.__value_.__l.__size_;
if ( v35 )
std::string::append(&v89, ",");
v36 = sub_1002E75A0(*(_QWORD *)(a1 + 728), i);
v37 = sub_1003065B0("%i", *(_DWORD *)(v36 + 376));
CString = (const std::string::value_type *)cocos2d::CCString::getCString((__int64)v37);
std::string::append(&v89, CString);
}
}
}
else
{
v32 = sub_1003065B0("%i", *(_DWORD *)(a1 + 696));
v33 = (const std::string::value_type *)cocos2d::CCString::getCString((__int64)v32);
std::string::assign(&v89, v33);
}
v31 = 0;
LABEL_88:
if ( (v97.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v39 = HIBYTE(v97.__r_.__value_.__r.__words[2]);
else
v39 = v97.__r_.__value_.__l.__size_;
v40 = &v85;
sub_100026068((__int64)&v85, v39 + 1);
if ( (v85.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v40 = (std::string *)v85.__r_.__value_.__r.__words[0];
if ( v39 )
{
if ( (v97.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v41 = &v97;
else
v41 = (std::string *)v97.__r_.__value_.__r.__words[0];
memmove(v40, v41, v39);
}
*(_WORD *)((char *)&v40->__r_.__value_.__l.__data_ + v39) = 124;
if ( *(_BYTE *)(a1 + 737) == 1 )
{
v42 = sub_1003065B0("%i", v31);
v43 = (char *)cocos2d::CCString::getCString((__int64)v42);
sub_100009900(&v84, v43);
}
else if ( SHIBYTE(v89.__r_.__value_.__r.__words[2]) < 0 )
{
sub_1000097D0(&v84, v89.__r_.__value_.__l.__data_, v89.__r_.__value_.__l.__size_);
}
else
{
v84 = v89;
}
if ( (v84.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v44 = &v84;
else
v44 = (std::string *)v84.__r_.__value_.__r.__words[0];
if ( (v84.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v45 = HIBYTE(v84.__r_.__value_.__r.__words[2]);
else
v45 = v84.__r_.__value_.__l.__size_;
v46 = std::string::append(&v85, (const std::string::value_type *)v44, v45);
v47 = *(_OWORD *)&v46->__r_.__value_.__l.__data_;
v86.__r_.__value_.__r.__words[2] = v46->__r_.__value_.__r.__words[2];
*(_OWORD *)&v86.__r_.__value_.__l.__data_ = v47;
v46->__r_.__value_.__l.__size_ = 0;
v46->__r_.__value_.__r.__words[2] = 0;
v46->__r_.__value_.__r.__words[0] = 0;
v48 = std::string::append(&v86, "|");
v49 = *(_OWORD *)&v48->__r_.__value_.__l.__data_;
v87.__r_.__value_.__r.__words[2] = v48->__r_.__value_.__r.__words[2];
*(_OWORD *)&v87.__r_.__value_.__l.__data_ = v49;
v48->__r_.__value_.__l.__size_ = 0;
v48->__r_.__value_.__r.__words[2] = 0;
v48->__r_.__value_.__r.__words[0] = 0;
v50 = *(unsigned __int8 *)(a1 + 737);
if ( v50 == 1 )
{
sub_100009900(__p, "m");
}
else
{
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v51 = HIBYTE(v98.__r_.__value_.__r.__words[2]);
else
v51 = v98.__r_.__value_.__l.__size_;
v52 = &v79;
sub_100026068((__int64)&v79, v51 + 1);
if ( (v79.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v52 = (std::string *)v79.__r_.__value_.__r.__words[0];
if ( v51 )
{
if ( (v98.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v53 = &v98;
else
v53 = (std::string *)v98.__r_.__value_.__r.__words[0];
memmove(v52, v53, v51);
}
*(_WORD *)((char *)&v52->__r_.__value_.__l.__data_ + v51) = 124;
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_dst = &__dst;
else
p_dst = (std::string *)__dst.__r_.__value_.__r.__words[0];
if ( (__dst.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v55 = HIBYTE(__dst.__r_.__value_.__r.__words[2]);
else
v55 = __dst.__r_.__value_.__l.__size_;
v56 = std::string::append(&v79, (const std::string::value_type *)p_dst, v55);
v57 = *(_OWORD *)&v56->__r_.__value_.__l.__data_;
v80.__r_.__value_.__r.__words[2] = v56->__r_.__value_.__r.__words[2];
*(_OWORD *)&v80.__r_.__value_.__l.__data_ = v57;
v56->__r_.__value_.__l.__size_ = 0;
v56->__r_.__value_.__r.__words[2] = 0;
v56->__r_.__value_.__r.__words[0] = 0;
v58 = std::string::append(&v80, "|");
v59 = *(_OWORD *)&v58->__r_.__value_.__l.__data_;
v81.__r_.__value_.__r.__words[2] = v58->__r_.__value_.__r.__words[2];
*(_OWORD *)&v81.__r_.__value_.__l.__data_ = v59;
v58->__r_.__value_.__l.__size_ = 0;
v58->__r_.__value_.__r.__words[2] = 0;
v58->__r_.__value_.__r.__words[0] = 0;
v60 = *(char *)(a1 + 807);
if ( v60 >= 0 )
v61 = (const std::string::value_type *)(a1 + 784);
else
v61 = *(const std::string::value_type **)(a1 + 784);
if ( v60 >= 0 )
v62 = *(unsigned __int8 *)(a1 + 807);
else
v62 = *(_QWORD *)(a1 + 792);
v63 = std::string::append(&v81, v61, v62);
v64 = *(_OWORD *)&v63->__r_.__value_.__l.__data_;
v83 = v63->__r_.__value_.__r.__words[2];
*(_OWORD *)__p = v64;
v63->__r_.__value_.__l.__size_ = 0;
v63->__r_.__value_.__r.__words[2] = 0;
v63->__r_.__value_.__r.__words[0] = 0;
}
if ( v83 >= 0 )
v65 = __p;
else
v65 = (void **)__p[0];
if ( v83 >= 0 )
v66 = HIBYTE(v83);
else
v66 = (std::string::size_type)__p[1];
v67 = std::string::append(&v87, (const std::string::value_type *)v65, v66);
v68 = *(_OWORD *)&v67->__r_.__value_.__l.__data_;
__str.__r_.__value_.__r.__words[2] = v67->__r_.__value_.__r.__words[2];
*(_OWORD *)&__str.__r_.__value_.__l.__data_ = v68;
v67->__r_.__value_.__l.__size_ = 0;
v67->__r_.__value_.__r.__words[2] = 0;
v67->__r_.__value_.__r.__words[0] = 0;
if ( SHIBYTE(v83) < 0 )
operator delete(__p[0]);
if ( (v50 & 1) == 0 )
{
if ( SHIBYTE(v81.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v81.__r_.__value_.__l.__data_);
if ( SHIBYTE(v80.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v80.__r_.__value_.__l.__data_);
if ( SHIBYTE(v79.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v79.__r_.__value_.__l.__data_);
}
if ( SHIBYTE(v87.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v87.__r_.__value_.__l.__data_);
if ( SHIBYTE(v86.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v86.__r_.__value_.__l.__data_);
if ( SHIBYTE(v84.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v84.__r_.__value_.__l.__data_);
if ( SHIBYTE(v85.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v85.__r_.__value_.__l.__data_);
if ( !*(_QWORD *)(a1 + 904) )
goto LABEL_171;
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v69 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
else
v69 = __str.__r_.__value_.__l.__size_;
v70 = *(unsigned __int8 *)(a1 + 935);
v71 = (char)v70;
if ( (v70 & 0x80u) != 0LL )
v70 = *(_QWORD *)(a1 + 920);
if ( v69 != v70
|| ((__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? (p_str = &__str)
: (p_str = (std::string *)__str.__r_.__value_.__r.__words[0]),
v71 >= 0 ? (v73 = (const void *)(a1 + 912)) : (v73 = *(const void **)(a1 + 912)),
memcmp(p_str, v73, v69)) )
{
LABEL_171:
v74 = time(nullptr);
*(_QWORD *)(a1 + 904) = rand() & 0xFFFFF | (unsigned __int64)(v74 << 20);
std::string::operator=((std::string *)(a1 + 912), &__str);
}
v75 = GameLevelManager::sharedState();
v76 = *(_QWORD *)(a1 + 904);
v77 = *(unsigned __int8 *)(a1 + 737);
if ( v77 == 1 )
{
sub_100009900(&v87, "");
}
else if ( *(char *)(a1 + 807) < 0 )
{
sub_1000097D0(&v87, *(void **)(a1 + 784), *(_QWORD *)(a1 + 792));
}
else
{
v87 = *(std::string *)(a1 + 784);
}
v78 = sub_1000C4DD0(
v75,
0,
v31,
(__int128 *)&v98,
(__int64)&v97,
v76,
(__int128 *)&v89,
v77,
(__int128 *)&__dst,
(__int64)&v87);
if ( SHIBYTE(v87.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v87.__r_.__value_.__l.__data_);
if ( (v78 & 1) != 0 )
{
*(_QWORD *)(GameLevelManager::sharedState() + 1264) = a1 + 664;
sub_10050C060(a1, 1);
}
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( SHIBYTE(v89.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v89.__r_.__value_.__l.__data_);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
{
v22 = (void *)__dst.__r_.__value_.__r.__words[0];
goto LABEL_187;
}
LABEL_188:
if ( SHIBYTE(v97.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v97.__r_.__value_.__l.__data_);
if ( SHIBYTE(v98.__r_.__value_.__r.__words[2]) < 0 )
{
v8 = (void *)v98.__r_.__value_.__r.__words[0];
LABEL_192:
operator delete(v8);
}
}