//
// sub_1004C71E4 from 0x1004c71e4 to 0x1004c7328 (324 bytes)
//
// 10 xrefs:
// > sub_10043CE30 @ 0x10043cffc
// > sub_1004A97F4 @ 0x1004a9880
// > sub_1004B2360 @ 0x1004b238c
// > sub_1004B2A00 @ 0x1004b2b74
// > sub_1004B3ED4 @ 0x1004b3fac
// > sub_1004B3ED4 @ 0x1004b3fbc
// > sub_1004B3ED4 @ 0x1004b4028
// > sub_1004B3ED4 @ 0x1004b4064
// > sub_1004D1B5C @ 0x1004d1bf8
// > sub_1004D41B4 @ 0x1004d45c0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
_BYTE *__fastcall sub_1004C71E4(char *a1)
{
__int64 v2; // x19
_BYTE *result; // x0
int v5; // w8
int v6; // w8
int v7; // w9
_BYTE *v8; // x10
_BYTE *v9; // x9
int v10; // w15
v2 = 0;
while ( a1[v2++] )
;
result = sub_1004B11FC(
*((__int64 **)off_1008524C8 + 54),
v2,
(char)"/opt/teamcity-agent/work/570ad728b1678096/core_api/src/fmod_string.cpp",
362,
0,
0);
if ( (((_DWORD)v2 - 1) & 0x80000000) == 0 && result )
{
v5 = *a1;
if ( v5 < 0 )
{
if ( (v5 & 0xE0) == 0xC0 )
{
v6 = 2;
}
else
{
v7 = v5 & 0xF0;
if ( (v5 & 0xF8) == 0xF0 )
v6 = 4;
else
v6 = 1;
if ( v7 == 224 )
v6 = 3;
}
}
else
{
v6 = 1;
}
v8 = result;
if ( v6 < (unsigned int)v2 )
{
v9 = a1 + 1;
v8 = result;
do
{
if ( !*(v9 - 1) )
break;
*v8++ = *(v9 - 1);
LODWORD(v2) = v2 - 1;
if ( v6 < 2 )
{
if ( (*v9 & 0xF8) == 0xF0 )
v10 = 4;
else
v10 = 1;
if ( (*v9 & 0xF0) == 0xE0 )
v10 = 3;
if ( (*v9 & 0xE0) == 0xC0 )
v10 = 2;
v6 = (char)*v9 < 0 ? v10 : 1;
}
else
{
--v6;
}
++v9;
}
while ( v6 < (int)v2 );
}
*v8 = 0;
}
return result;
}