//
// sub_1004EE050 from 0x1004ee050 to 0x1004ee25a (522 bytes)
//
// 9 xrefs:
// > CommentCell::loadFromComment @ 0x10022e0b5
// > ShareLevelLayer::init @ 0x10026ce09
// > FriendRequestPopup::loadFromGJFriendRequest @ 0x100291b65
// > ShareListLayer::init @ 0x10034dd12
// > sub_1004EE280 @ 0x1004ee2cd
// > InfoLayer::init @ 0x100891fc9
// > sub_1009543D0 @ 0x100954d43
// > CommentOptionsPopup::init @ 0x100968085
// > sub_1009685B0 @ 0x1009685fe
//
// 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 12:31:23 +0000
//
void __fastcall sub_1004EE050(std::string *__str)
{
unsigned int v2; // esi
std::string::size_type size; // rsi
std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0 v4; // al
std::string::size_type v5; // rcx
bool v6; // di
std::string::size_type v7; // rsi
std::string::size_type v8; // rdx
std::string::size_type v9; // r12
std::string::size_type v10; // rcx
std::string::pointer data; // r8
int v12; // r9d
int v13; // r10d
std::string::size_type v14; // rcx
char v15; // r11
std::string::size_type v16; // r13
std::string::size_type v17; // r8
std::string v18; // [rsp+20h] [rbp-40h] BYREF
std::string v19; // 0:^0.24
memset(&v18, 0, sizeof(v18));
v2 = (unsigned int)__str->__r_.__value_.__l.0;
if ( (v2 & 1) != 0 )
size = __str->__r_.__value_.__l.__size_;
else
size = v2 >> 1;
std::string::reserve(&v18, size);
v4 = __str->__r_.__value_.__s.0;
v5 = *(_BYTE *)&__str->__r_.__value_.__l.0 >> 1;
v6 = (*(_BYTE *)&__str->__r_.__value_.__s.0 & 1) == 0;
v7 = __str->__r_.__value_.__l.__size_;
if ( (*(_BYTE *)&v4 & 1) != 0 )
v5 = __str->__r_.__value_.__l.__size_;
if ( v5 )
{
v8 = 0;
while ( 1 )
{
data = __str->__r_.__value_.__s.__data_;
if ( !v6 )
data = __str->__r_.__value_.__l.__data_;
v12 = (unsigned __int8)data[v8];
v13 = v12 & 0xE0;
if ( v13 == 192 )
{
v14 = 2;
goto LABEL_16;
}
if ( (v12 & 0xFFFFFFF0) == 0xE0 )
break;
if ( (v12 & 0xFFFFFFF8) == 0xF0 )
{
v14 = 4;
LABEL_16:
v15 = 0;
LABEL_19:
v9 = v14 + v8;
v16 = *(unsigned __int8 *)&v4 >> 1;
if ( !v6 )
v16 = v7;
if ( v9 <= v16
&& __OFSUB__(-(data[v8 + 1] & 0xC0), 1)
&& (v13 == 192 || __OFSUB__(-(data[v8 + 2] & 0xC0), 1) && (v15 || __OFSUB__(-(data[v8 + 3] & 0xC0), 1))) )
{
if ( v12 == 194 && data[v8 + 1] == -96 )
goto LABEL_9;
LABEL_33:
std::string::append(&v18, __str, v8, v14);
v4 = __str->__r_.__value_.__s.0;
v7 = __str->__r_.__value_.__l.__size_;
goto LABEL_9;
}
goto LABEL_8;
}
v9 = v8 + 1;
if ( (v12 & 0x80u) != 0 )
goto LABEL_9;
v17 = *(unsigned __int8 *)&v4 >> 1;
if ( !v6 )
v17 = v7;
v14 = 1;
if ( v8 < v17 )
goto LABEL_33;
LABEL_8:
v9 = v8 + 1;
LABEL_9:
v6 = (*(_BYTE *)&v4 & 1) == 0;
v10 = *(unsigned __int8 *)&v4 >> 1;
if ( (*(_BYTE *)&v4 & 1) != 0 )
v10 = v7;
v8 = v9;
if ( v9 >= v10 )
goto LABEL_38;
}
v14 = 3;
v15 = 1;
goto LABEL_19;
}
LABEL_38:
v19 = *__str;
*__str = v18;
v18 = v19;
if ( (*(_BYTE *)&v19.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v18.__r_.__value_.__l.__data_);
}