//
// GameToolbox::stripNonBreakingSpaces from 0x140070150 to 0x140070350 (512 bytes)
//
// 10 xrefs:
// > GameToolbox::singleLineSnippet @ 0x14007038e
// > CommentOptionsPopup::init @ 0x1400c25b2
// > CommentOptionsPopup::onCopy @ 0x1400c2918
// > ThreadRequestPopup::init @ 0x1400ff6d0
// > CommentCell::loadFromComment @ 0x140152c50
// > FriendRequestPopup::loadFromGJFriendRequest @ 0x1403a1ff7
// > InfoLayer::init @ 0x1403ce9f7
// > ShareListLayer::init @ 0x1404321fa
// > ShareLevelLayer::init @ 0x140630aa7
// > ??> @ 0x1409117d4
//
// 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 11:25:49 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall GameToolbox::stripNonBreakingSpaces(unsigned __int64 *a1)
{
unsigned __int64 v2; // rdi
unsigned __int64 v3; // rcx
unsigned __int8 *v4; // rax
unsigned __int64 v5; // r8
__int64 v6; // r9
unsigned __int64 v7; // rsi
__int64 v8; // rdx
unsigned __int8 *v9; // rax
unsigned __int8 *v10; // rax
unsigned __int64 v11; // rax
size_t v12; // rax
size_t v13; // r8
unsigned __int8 *v14; // rax
__int128 v15; // xmm2
__m128i v16; // xmm3
void *v17; // rcx
void *Block[2]; // [rsp+30h] [rbp-38h] BYREF
__m128i si128; // [rsp+40h] [rbp-28h]
*(_OWORD *)Block = 0;
si128 = _mm_load_si128((const __m128i *)&Size);
LOBYTE(Block[0]) = 0;
sub_140059AB0(Block, a1[2]);
v2 = 0;
v3 = a1[2];
if ( v3 )
{
do
{
v4 = (unsigned __int8 *)a1;
v5 = a1[3];
if ( v5 > 0xF )
v4 = (unsigned __int8 *)*a1;
v6 = v4[v2];
v7 = 1;
if ( (v6 & 0xE0) == 0xC0 )
{
v7 = 2;
}
else if ( (v6 & 0xF0) == 0xE0 )
{
v7 = 3;
}
else if ( (v6 & 0xF8) == 0xF0 )
{
v7 = 4;
}
else if ( (unsigned __int8)v6 >= 0x80u )
{
goto LABEL_13;
}
if ( v7 + v2 <= v3 )
{
v8 = 1;
if ( v7 <= 1 )
{
LABEL_19:
if ( v7 != 2 || (_BYTE)v6 != 0xC2 )
goto LABEL_24;
v10 = (unsigned __int8 *)a1;
if ( v5 > 0xF )
v10 = (unsigned __int8 *)*a1;
if ( v10[v2 + 1] != 0xA0 )
{
LABEL_24:
v11 = a1[2];
if ( v11 < v2 )
sub_14003F4D0(v3, v8, v5, v6);
v12 = v11 - v2;
v13 = v7;
if ( v12 < v7 )
v13 = v12;
v14 = (unsigned __int8 *)a1;
if ( a1[3] > 0xF )
v14 = (unsigned __int8 *)*a1;
sub_140044D80(Block, &v14[v2], v13);
}
v2 += v7;
goto LABEL_31;
}
while ( 1 )
{
v9 = (unsigned __int8 *)a1;
if ( v5 > 0xF )
v9 = (unsigned __int8 *)*a1;
v3 = v9[v8 + v2];
LOBYTE(v3) = v3 & 0xC0;
if ( (_BYTE)v3 != 0x80 )
break;
if ( ++v8 >= v7 )
goto LABEL_19;
}
LABEL_13:
++v2;
goto LABEL_31;
}
++v2;
LABEL_31:
v3 = a1[2];
}
while ( v2 < v3 );
}
if ( a1 != (unsigned __int64 *)Block )
{
v15 = *(_OWORD *)a1;
v16 = *((__m128i *)a1 + 1);
*(_OWORD *)a1 = *(_OWORD *)Block;
*((__m128i *)a1 + 1) = si128;
*(_OWORD *)Block = v15;
si128 = v16;
}
if ( si128.m128i_i64[1] > 0xFuLL )
{
v17 = Block[0];
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v17 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v17 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v17);
}
}