//
// sub_1002F40C0 from 0x1002f40c0 to 0x1002f4276 (438 bytes)
//
// 1 xrefs:
// > GJEffectManager::runPulseEffect @ 0x1002e844d
//
// 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_1002F40C0(__int64 *a1, int *a2)
{
unsigned __int64 v2; // r11
unsigned __int64 v4; // rcx
unsigned __int64 v5; // rsi
__int64 v6; // rdi
__int64 *v8; // rax
__int64 v9; // r9
unsigned __int64 v10; // r11
__int64 v11; // r8
__int64 v12; // rax
unsigned __int64 v13; // rax
_QWORD *v14; // rdi
void *v15; // rax
_QWORD *v16; // [rsp-28h] [rbp-28h] BYREF
char v17; // [rsp-18h] [rbp-18h]
v2 = a1[1];
if ( !v2 )
return 0;
v4 = *a2;
v5 = (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 ( v5 > 1 )
{
v6 = v4;
if ( v2 <= v4 )
{
if ( (v2 | v4) >> 32 )
v6 = v4 % v2;
else
v6 = (unsigned int)v4 % (unsigned int)v2;
}
}
else
{
v6 = v4 & (v2 - 1);
}
v8 = *(__int64 **)(*a1 + 8 * v6);
if ( !v8 )
return 0;
v9 = *v8;
if ( !*v8 )
return 0;
if ( (unsigned int)v5 < 2 )
{
v10 = v2 - 1;
v11 = 0;
while ( 1 )
{
v12 = *(_QWORD *)(v9 + 8);
if ( v12 == v4 )
{
if ( *(_DWORD *)(v9 + 16) == (_DWORD)v4 )
goto LABEL_31;
}
else if ( (v10 & v12) != v6 )
{
return v11;
}
v9 = *(_QWORD *)v9;
if ( !v9 )
return v11;
}
}
v11 = 0;
while ( 1 )
{
v13 = *(_QWORD *)(v9 + 8);
if ( v13 == v4 )
break;
if ( v13 < v2 )
goto LABEL_27;
if ( (v2 | v13) >> 32 )
{
v13 %= v2;
LABEL_27:
if ( v13 != v6 )
return v11;
goto LABEL_22;
}
if ( (unsigned int)v13 % (unsigned int)v2 != v6 )
return v11;
LABEL_22:
v9 = *(_QWORD *)v9;
if ( !v9 )
return v11;
}
if ( *(_DWORD *)(v9 + 16) != (_DWORD)v4 )
goto LABEL_22;
LABEL_31:
sub_100056B40((__int64)&v16, a1, (__int64 *)v9);
v14 = v16;
v16 = nullptr;
if ( v14 )
{
if ( v17 == 1 )
{
v15 = (void *)v14[3];
if ( v15 )
{
v14[4] = v15;
operator delete(v15);
}
}
operator delete(v14);
}
return 1;
}