//
// sub_D1A548 from 0xd1a548 to 0xd1a61c (212 bytes)
//
// 2 xrefs:
// > sub_D1A61C @ 0xd1a624
// > sub_D1A628 @ 0xd1a660
//
// 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_D1A548(_QWORD *a1, _DWORD *a2, unsigned __int64 a3, unsigned __int64 a4)
{
unsigned __int64 v4; // x21
unsigned __int64 v6; // x22
unsigned __int64 v7; // x20
const wchar_t *v9; // x24
size_t v10; // x23
const wchar_t *i; // x19
unsigned __int64 v12; // x2
int v13; // w0
v4 = *(_QWORD *)(*a1 - 24LL);
if ( a4 )
{
if ( a4 > v4 )
return -1;
v6 = v4 - a4;
if ( a3 > v4 - a4 )
{
return -1;
}
else
{
v7 = a3 + 1;
v9 = a2 + 1;
v10 = a4 - 1;
for ( i = (const wchar_t *)(*a1 + 4 * (a3 + 1)); ; ++i )
{
v12 = v7;
if ( *(i - 1) == *a2 )
{
v13 = wmemcmp(i, v9, v10);
v12 = v7;
if ( !v13 )
break;
}
++v7;
if ( v12 > v6 )
return -1;
}
return v7 - 1;
}
}
else if ( a3 > v4 )
{
return -1;
}
else
{
return a3;
}
}