//
// sub_D1659C from 0xd1659c to 0xd16674 (216 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
//
unsigned __int64 __fastcall sub_D1659C(__int64 *a1, char *a2, unsigned __int64 a3)
{
size_t v4; // x0
__int64 v5; // x21
size_t v6; // x20
__int64 v7; // x19
size_t v9; // x22
unsigned __int64 v10; // x20
size_t v11; // x23
int v12; // w25
size_t v13; // x2
int v14; // w0
v4 = strlen(a2);
v5 = *a1;
v6 = *(_QWORD *)(*a1 - 24);
if ( v4 )
{
v7 = -1;
if ( v4 <= v6 )
{
v9 = v6 - v4;
if ( a3 <= v6 - v4 )
{
v10 = a3 + 1;
v7 = a3;
v11 = v4 - 1;
v12 = (unsigned __int8)*a2;
while ( 1 )
{
v13 = v10;
if ( *(unsigned __int8 *)(v5 + v7) == v12 )
{
v14 = memcmp((const void *)(v5 + v10), a2 + 1, v11);
v13 = v10;
if ( !v14 )
break;
}
++v10;
++v7;
if ( v13 > v9 )
return -1;
}
}
}
}
else if ( a3 > v6 )
{
return -1;
}
else
{
return a3;
}
return v7;
}