//
// sub_1000DA680 from 0x1000da680 to 0x1000da7cb (331 bytes)
//
// 1 xrefs:
// > sub_1000F5470 @ 0x1000f6024
//
// 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_1000DA680(_QWORD *a1, int *a2)
{
unsigned __int64 v2; // r8
unsigned __int64 v3; // rcx
unsigned __int64 v4; // r10
__int64 v5; // rsi
__int64 **v7; // rax
__int64 *v8; // r9
unsigned __int64 v9; // r8
__int64 v10; // rdi
__int64 v11; // rax
unsigned __int64 v12; // rax
v2 = a1[1];
if ( !v2 )
return 0;
v3 = *a2;
v4 = (0x101010101010101LL
* ((((v2 - ((v2 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v2 - ((v2 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v2 - ((v2 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v2 - ((v2 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v4 > 1 )
{
v5 = *a2;
if ( v2 <= v3 )
{
if ( (v2 | v3) >> 32 )
v5 = v3 % v2;
else
v5 = (unsigned int)v3 % (unsigned int)v2;
}
}
else
{
v5 = v3 & (v2 - 1);
}
v7 = *(__int64 ***)(*a1 + 8 * v5);
if ( !v7 )
return 0;
v8 = *v7;
if ( !*v7 )
return 0;
if ( (unsigned int)v4 < 2 )
{
v9 = v2 - 1;
v10 = 0;
while ( 1 )
{
v11 = v8[1];
if ( v11 == v3 )
{
if ( *((_DWORD *)v8 + 4) == (_DWORD)v3 )
return 1;
}
else if ( (v9 & v11) != v5 )
{
return v10;
}
v8 = (__int64 *)*v8;
if ( !v8 )
return v10;
}
}
v10 = 0;
while ( 1 )
{
v12 = v8[1];
if ( v12 == v3 )
break;
if ( v12 >= v2 )
{
if ( (v2 | v12) >> 32 )
v12 %= v2;
else
v12 = (unsigned int)v12 % (unsigned int)v2;
}
if ( v12 != v5 )
return v10;
LABEL_23:
v8 = (__int64 *)*v8;
if ( !v8 )
return v10;
}
if ( *((_DWORD *)v8 + 4) != (_DWORD)v3 )
goto LABEL_23;
return 1;
}