//
// sub_D164D8 from 0xd164d8 to 0xd1659c (196 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_D164D8(__int64 *a1, unsigned __int8 **a2, unsigned __int64 a3)
{
unsigned __int8 *v3; // x3
__int64 v4; // x21
unsigned __int64 v5; // x1
unsigned __int64 v6; // x20
__int64 v7; // x19
unsigned __int64 v9; // x22
unsigned __int64 v10; // x20
size_t v11; // x23
const void *v12; // x24
int v13; // w25
unsigned __int64 v14; // x1
int v15; // w0
v3 = *a2;
v4 = *a1;
v5 = *((_QWORD *)*a2 - 3);
v6 = *(_QWORD *)(*a1 - 24);
if ( v5 )
{
v7 = -1;
if ( v5 <= v6 )
{
v9 = v6 - v5;
if ( a3 <= v6 - v5 )
{
v10 = a3 + 1;
v7 = a3;
v11 = v5 - 1;
v12 = v3 + 1;
v13 = *v3;
while ( 1 )
{
v14 = v10;
if ( *(unsigned __int8 *)(v4 + v7) == v13 )
{
v15 = memcmp((const void *)(v4 + v10), v12, v11);
v14 = v10;
if ( !v15 )
break;
}
++v10;
++v7;
if ( v14 > v9 )
return -1;
}
}
}
}
else if ( a3 > v6 )
{
return -1;
}
else
{
return a3;
}
return v7;
}