//
// sub_86C850 from 0x86c850 to 0x86c964 (276 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::generateVisibilityGroups @ 0x883194
// > GJBaseGameLayer::generateTargetGroups @ 0x888294
//
// 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_86C850(__int64 *a1, int *a2)
{
unsigned __int64 v3; // x21
unsigned __int64 v4; // x19
__int64 **v5; // x0
__int64 v6; // x3
__int64 *v7; // x22
__int64 **v8; // x4
__int64 v9; // x1
unsigned __int64 v10; // x21
__int64 v12; // x5
unsigned __int64 v13; // x21
__int64 *v14; // x1
v3 = a1[1];
v4 = *a2 % v3;
v5 = (__int64 **)sub_855FD0(a1, v4, a2);
if ( v5 )
{
v6 = *a1;
v7 = *v5;
v8 = (__int64 **)(*a1 + 8 * v4);
if ( v5 != (__int64 **)*v8 )
{
v9 = *v7;
if ( *v7 )
{
v10 = *(int *)(v9 + 8) % v3;
if ( v4 != v10 )
{
*(_QWORD *)(v6 + 8 * v10) = v5;
v9 = *v7;
}
}
goto LABEL_6;
}
v12 = *v7;
if ( *v7 )
{
v9 = *v7;
v13 = *(int *)(v12 + 8) % v3;
if ( v4 == v13 )
{
LABEL_6:
*v5 = (__int64 *)v9;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)(v7 + 2));
operator delete(v7);
--a1[3];
return 1;
}
*(_QWORD *)(v6 + 8 * v13) = v5;
v8 = (__int64 **)(*a1 + 8 * v4);
v14 = *v8;
}
else
{
v14 = (__int64 *)v5;
}
if ( v14 == a1 + 2 )
a1[2] = v12;
*v8 = nullptr;
v9 = *v7;
goto LABEL_6;
}
return 0;
}