//
// sub_D1FEAC from 0xd1feac to 0xd1ff74 (200 bytes)
//
// 2 xrefs:
// > ??> @ 0x121e358
// > ??> @ 0x121ed68
//
// 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_D1FEAC(int a1, mbstate_t *a2, char *s, unsigned __int64 a4, __int64 a5)
{
const char *v5; // x19
__int64 v8; // x20
unsigned int v9; // w22
size_t v10; // x0
mbstate_t p; // [xsp+48h] [xbp+48h] BYREF
v5 = s;
p = *a2;
v8 = a5;
v9 = 0;
if ( (unsigned __int64)s < a4 && a5 )
{
do
{
v10 = mbrtowc(nullptr, v5, a4 - (_QWORD)v5, &p);
if ( v10 + 2 <= 1 )
break;
if ( v10 )
{
v5 += v10;
*a2 = p;
--v8;
v9 += v10;
if ( a4 <= (unsigned __int64)v5 )
return v9;
}
else
{
--v8;
++v5;
*a2 = p;
++v9;
if ( a4 <= (unsigned __int64)v5 )
return v9;
}
}
while ( v8 );
}
return v9;
}