//
// sub_776F98 from 0x776f98 to 0x777004 (108 bytes)
//
// 2 xrefs:
// > sub_777004 @ 0x77700a
// > sub_777010 @ 0x77702a
//
// 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_776F98(_DWORD *a1, _DWORD *a2, unsigned int a3, unsigned int a4)
{
unsigned int v4; // r4
unsigned int v6; // r7
const wchar_t *v8; // r6
unsigned int v9; // r4
size_t v10; // r8
const wchar_t *v11; // r9
wchar_t v12; // t1
unsigned int v13; // r3
int v14; // r0
v4 = *(_DWORD *)(*a1 - 12);
if ( a4 )
{
if ( a4 > v4 )
return -1;
v6 = v4 - a4;
if ( a3 > v4 - a4 )
{
return -1;
}
else
{
v8 = (const wchar_t *)(*a1 + 4 * a3);
v9 = a3 + 1;
v10 = a4 - 1;
v11 = a2 + 1;
while ( 1 )
{
v12 = *v8++;
v13 = v9;
if ( v12 == *a2 )
{
v14 = wmemcmp(v8, v11, v10);
v13 = v9;
if ( !v14 )
break;
}
++v9;
if ( v13 > v6 )
return -1;
}
return v9 - 1;
}
}
else if ( a3 > v4 )
{
return -1;
}
else
{
return a3;
}
}