//
// sub_D166C8 from 0xd166c8 to 0xd1675c (148 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
//
__int64 __fastcall sub_D166C8(__int64 *a1, const void **a2, size_t a3)
{
const void *v3; // x21
__int64 v4; // x22
__int64 result; // x0
size_t v6; // x20
size_t v7; // x1
size_t v8; // x19
v3 = *a2;
v4 = *a1;
result = -1;
v6 = *((_QWORD *)*a2 - 3);
v7 = *(_QWORD *)(v4 - 24);
if ( v6 <= v7 )
{
if ( a3 > v7 - v6 )
v8 = v7 - v6;
else
v8 = a3;
while ( 1 )
{
if ( !memcmp((const void *)(v4 + v8), v3, v6) )
return v8;
if ( !v8 )
break;
--v8;
}
return -1;
}
return result;
}