//
// sub_10065F750 from 0x10065f750 to 0x10065f8fb (427 bytes)
//
// 1 xrefs:
// > sub_10065F920 @ 0x10065fa8f
//
// 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_10065F750(char **a1, unsigned __int64 a2, unsigned int **a3, unsigned __int64 a4, int a5)
{
char *v5; // r15
unsigned int *v6; // r12
unsigned int v7; // eax
__int64 v8; // r14
signed __int64 v9; // rbx
unsigned int v10; // r13d
int v11; // eax
int v12; // ecx
int v13; // ecx
int v14; // ecx
int v15; // ecx
int v16; // edx
unsigned __int64 v19; // [rsp+8h] [rbp-48h]
unsigned int v22; // [rsp+24h] [rbp-2Ch]
v5 = *a1;
v6 = *a3;
if ( (unsigned __int64)*a1 >= a2 )
{
v22 = 0;
}
else
{
v22 = 0;
v19 = a2;
while ( 1 )
{
v8 = (unsigned __int8)*v5;
v9 = (unsigned __int16)byte_1008230B0[v8];
if ( (__int64)(a2 - (_QWORD)v5) <= v9 )
{
v22 = 1;
goto LABEL_23;
}
v10 = v9 + 1;
if ( !sub_10065F320(v5, (int)v9 + 1) )
goto LABEL_21;
v11 = 0;
switch ( (char)v9 )
{
case 0:
v12 = (unsigned __int8)v9;
goto LABEL_14;
case 1:
goto LABEL_13;
case 2:
goto LABEL_12;
case 3:
goto LABEL_11;
case 4:
goto LABEL_10;
case 5:
v11 = (_DWORD)v8 << 6;
LOBYTE(v8) = *++v5;
LABEL_10:
v13 = v11 + (unsigned __int8)v8;
LOBYTE(v8) = *++v5;
v11 = v13 << 6;
LABEL_11:
v14 = v11 + (unsigned __int8)v8;
LOBYTE(v8) = *++v5;
v11 = v14 << 6;
LABEL_12:
v15 = v11 + (unsigned __int8)v8;
LOBYTE(v8) = *++v5;
v11 = v15 << 6;
LABEL_13:
v12 = (v11 + (unsigned __int8)v8) << 6;
LOBYTE(v8) = *++v5;
LABEL_14:
++v5;
v11 = v12 + (unsigned __int8)v8;
break;
default:
break;
}
if ( (unsigned __int64)v6 >= a4 )
break;
v7 = v11 - dword_1008231B0[v9];
if ( v7 > 0x10FFFF )
{
v22 = 3;
v7 = 65533;
}
else
{
v16 = v7 & 0x1FF800;
if ( (v7 & 0x1FF800) == 0xD800 )
v7 = 65533;
if ( a5 == 0 && v16 == 55296 )
{
v5 -= v10;
LABEL_21:
v22 = 3;
goto LABEL_23;
}
}
*v6++ = v7;
a2 = v19;
if ( (unsigned __int64)v5 >= v19 )
goto LABEL_23;
}
v5 -= v10;
v22 = 2;
}
LABEL_23:
*a1 = v5;
*a3 = v6;
return v22;
}