//
// sub_10065EC90 from 0x10065ec90 to 0x10065edb9 (297 bytes)
//
// 0 xrefs:
//
// 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
//
__int64 __fastcall sub_10065EC90(_WORD **a1, unsigned __int64 a2, int **a3, unsigned __int64 a4, int a5)
{
_WORD *v5; // r10
int *v6; // r9
__int64 result; // rax
_WORD *v8; // r8
int v9; // r11d
int v10; // r11d
int v11; // r8d
unsigned __int16 *v12; // r11
int v13; // ebx
v5 = *a1;
v6 = *a3;
result = 0;
if ( (unsigned __int64)*a1 < a2 )
{
if ( a5 )
{
while ( 1 )
{
v8 = v5 + 1;
v9 = (unsigned __int16)*v5;
if ( (*v5 & 0xFC00) == 0xD800 )
{
if ( (unsigned __int64)v8 >= a2 )
goto LABEL_18;
if ( (*v8 & 0xFC00) == 0xDC00 )
{
v9 = (unsigned __int16)*v8 + (v9 << 10) - 56613888;
v8 = v5 + 2;
}
}
if ( (unsigned __int64)v6 >= a4 )
break;
*v6++ = v9;
v5 = v8;
if ( (unsigned __int64)v8 >= a2 )
{
v5 = v8;
goto LABEL_21;
}
}
LABEL_17:
result = 2;
}
else
{
do
{
v12 = v5 + 1;
v11 = (unsigned __int16)*v5;
v13 = *v5 & 0xFC00;
if ( v13 == 55296 )
{
if ( (unsigned __int64)v12 >= a2 )
{
LABEL_18:
result = 1;
goto LABEL_21;
}
v10 = *v12;
if ( (v10 & 0xFC00) != 0xDC00 )
{
LABEL_19:
result = 3;
goto LABEL_21;
}
v11 = v10 + (v11 << 10) - 56613888;
v12 = v5 + 2;
if ( (unsigned __int64)v6 >= a4 )
goto LABEL_17;
}
else
{
if ( v13 == 56320 )
goto LABEL_19;
if ( (unsigned __int64)v6 >= a4 )
goto LABEL_17;
}
*v6++ = v11;
v5 = v12;
}
while ( (unsigned __int64)v12 < a2 );
v5 = v12;
}
}
LABEL_21:
*a1 = v5;
*a3 = v6;
return result;
}