//
// sub_77A8C8 from 0x77a8c8 to 0x77a932 (106 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
//
int __fastcall sub_77A8C8(int a1, int *a2, char *s, unsigned int a4, int a5)
{
int v6; // r1
int v7; // r5
const char *v8; // r4
bool v10; // cf
int v11; // r9
size_t v12; // r0
_BOOL4 v13; // r3
mbstate_t p; // [sp+4h] [bp-8h] BYREF
v6 = *a2;
v7 = a5;
v8 = s;
v10 = 1;
if ( a5 )
v10 = (unsigned int)s >= a4;
p.__count = v6;
if ( v10 )
return 0;
v11 = 0;
do
{
v12 = mbrtowc(nullptr, v8, a4 - (_DWORD)v8, &p);
if ( v12 + 2 <= 1 )
break;
if ( !v12 )
v12 = 1;
--v7;
v8 += v12;
v11 += v12;
v13 = a4 > (unsigned int)v8 && v7 != 0;
*a2 = p.__count;
}
while ( v13 );
return v11;
}