//
// sub_D1FD68 from 0xd1fd68 to 0xd1fe5c (244 bytes)
//
// 2 xrefs:
// > ??> @ 0x121e340
// > ??> @ 0x121ed50
//
// 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_D1FD68(
int a1,
mbstate_t *a2,
char *s,
unsigned __int64 a4,
const char **a5,
wchar_t *pwc,
unsigned __int64 a7,
wchar_t **a8)
{
__int64 result; // x0
const char *v10; // x19
wchar_t *v13; // x20
mbstate_t v16; // x1
size_t v17; // x0
mbstate_t p; // [xsp+58h] [xbp+58h] BYREF
result = (unsigned __int64)s < a4;
v10 = s;
p = *a2;
v13 = pwc;
if ( (unsigned __int64)s >= a4 || (unsigned __int64)pwc >= a7 )
{
LABEL_11:
*a5 = v10;
*a8 = v13;
}
else
{
while ( 1 )
{
v17 = mbrtowc(v13, v10, a4 - (_QWORD)v10, &p);
if ( v17 == -1 )
{
result = 2;
goto LABEL_11;
}
if ( v17 == -2 )
break;
v16 = p;
if ( !v17 )
{
*v13 = 0;
v17 = 1;
}
v10 += v17;
*a2 = v16;
++v13;
result = a4 > (unsigned __int64)v10;
if ( a4 <= (unsigned __int64)v10 || a7 <= (unsigned __int64)v13 )
goto LABEL_11;
}
*a5 = v10;
*a8 = v13;
return 1;
}
return result;
}