//
// sub_10065EB10 from 0x10065eb10 to 0x10065ec85 (373 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_10065EB10(unsigned int **a1, unsigned __int64 a2, _WORD **a3, unsigned __int64 a4, int a5)
{
unsigned int *v5; // r9
_WORD *v6; // r10
__int64 result; // rax
unsigned int v8; // r8d
unsigned int v9; // r8d
v5 = *a1;
v6 = *a3;
result = 0;
if ( (unsigned __int64)*a1 < a2 )
{
if ( a5 )
{
while ( (unsigned __int64)v6 < a4 )
{
v8 = *v5;
if ( *v5 > 0xFFFF )
{
if ( v8 >= 0x110000 )
{
*v6++ = -3;
}
else
{
if ( (unsigned __int64)(v6 + 1) >= a4 )
break;
*v6 = ((v8 + 67043328) >> 10) - 10240;
v6[1] = v8 & 0x3FF | 0xDC00;
v6 += 2;
}
}
else
{
if ( (*v5 & 0xF800) == 0xD800 )
*v6 = -3;
else
*v6 = v8;
++v6;
}
if ( (unsigned __int64)++v5 >= a2 )
goto LABEL_25;
}
}
else
{
result = 0;
while ( (unsigned __int64)v6 < a4 )
{
v9 = *v5;
if ( *v5 >= 0x10000 )
{
if ( v9 > 0x10FFFF )
{
result = 3;
}
else
{
if ( (unsigned __int64)(v6 + 1) >= a4 )
break;
*v6 = ((v9 + 67043328) >> 10) - 10240;
v6[1] = v9 & 0x3FF | 0xDC00;
v6 += 2;
}
}
else
{
if ( (*v5 & 0xF800) == 0xD800 )
{
result = 3;
goto LABEL_25;
}
*v6++ = v9;
}
if ( (unsigned __int64)++v5 >= a2 )
goto LABEL_25;
}
}
result = 2;
}
LABEL_25:
*a1 = v5;
*a3 = v6;
return result;
}