//
// sub_77A77C from 0x77a77c to 0x77a846 (202 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_77A77C(
int a1,
int *a2,
unsigned int a3,
unsigned int a4,
unsigned int *a5,
char *a6,
unsigned int a7,
char **a8)
{
unsigned int v8; // r4
char *v10; // r5
int result; // r0
wchar_t *v14; // r7
bool v15; // cc
unsigned int v16; // r0
unsigned int v17; // r11
wchar_t *v18; // r3
size_t v19; // r0
char s[4]; // [sp+8h] [bp-Ch] BYREF
mbstate_t v21; // [sp+Ch] [bp-8h] BYREF
v8 = a3;
v10 = a6;
v21.__count = *a2;
if ( (int)&a6[((int)(a4 - a3) >> 2) - a7] <= 0 )
{
if ( a4 <= a3 )
{
LABEL_21:
result = 0;
goto LABEL_14;
}
v18 = (wchar_t *)a3;
while ( 1 )
{
v8 = (unsigned int)v18;
v19 = wcrtomb(v10, *v18, &v21);
v18 = (wchar_t *)(v8 + 4);
if ( v19 == -1 )
goto LABEL_13;
v10 += v19;
v8 += 4;
*a2 = v21.__count;
if ( a4 <= (unsigned int)v18 )
goto LABEL_21;
}
}
result = a4 > a3;
if ( (unsigned int)a6 < a7 && a4 > a3 )
{
v14 = (wchar_t *)a3;
while ( 1 )
{
v8 = (unsigned int)v14;
v16 = wcrtomb(s, *v14++, &v21);
v17 = v16;
if ( v16 == -1 )
break;
if ( v16 > a7 - (unsigned int)v10 )
{
result = 1;
goto LABEL_14;
}
memcpy(v10, s, v16);
v10 += v17;
v15 = a4 > (unsigned int)v14;
if ( a4 > (unsigned int)v14 )
v15 = a7 > (unsigned int)v10;
v8 = (unsigned int)v14;
*a2 = v21.__count;
if ( !v15 )
{
result = a4 > (unsigned int)v14;
goto LABEL_14;
}
}
LABEL_13:
result = 2;
}
LABEL_14:
*a5 = v8;
*a8 = v10;
return result;
}