//
// sub_1008C1820 from 0x1008c1820 to 0x1008c19f6 (470 bytes)
//
// 1 xrefs:
// > DeathMarkerLayer::updateVisibility @ 0x1008beda7
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:37:30 +0000
//
unsigned __int64 __fastcall sub_1008C1820(__int64 a1, unsigned int a2)
{
unsigned __int64 result; // rax
unsigned __int64 v4; // rdi
unsigned __int64 v5; // r9
unsigned __int64 v6; // rcx
__int64 *v7; // r14
unsigned __int64 v8; // rdi
unsigned __int64 v9; // r15
__int64 v10; // r12
__int64 v11; // r13
__int64 v12; // rsi
__int64 v13; // rsi
v4 = *(_QWORD *)(a1 + 352);
if ( v4 )
{
v5 = (0x101010101010101LL
* ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v5 > 1 )
{
v6 = a2;
if ( v4 <= a2 )
v6 = a2 % (unsigned int)v4;
}
else
{
v6 = ((_DWORD)v4 - 1) & a2;
}
result = *(_QWORD *)(*(_QWORD *)(a1 + 344) + 8 * v6);
if ( result )
{
v7 = *(__int64 **)result;
if ( *(_QWORD *)result )
{
if ( (unsigned int)v5 < 2 )
{
v8 = v4 - 1;
while ( 1 )
{
result = v7[1];
if ( result == a2 )
{
if ( *((_DWORD *)v7 + 4) == a2 )
goto LABEL_25;
}
else
{
result &= v8;
if ( result != v6 )
return result;
}
v7 = (__int64 *)*v7;
if ( !v7 )
return result;
}
}
do
{
result = v7[1];
if ( result == a2 )
{
if ( *((_DWORD *)v7 + 4) == a2 )
{
LABEL_25:
result = v7[3];
if ( v7[4] != result )
{
v9 = 0;
do
{
v10 = *(_QWORD *)(a1 + 320);
v11 = 80LL * *(int *)(result + 4 * v9);
v12 = *(_QWORD *)(v10 + v11 + 64);
if ( v12 )
(*(void (__fastcall **)(_QWORD, __int64, _QWORD))(**(_QWORD **)(a1 + 408) + 552LL))(
*(_QWORD *)(a1 + 408),
v12,
0);
v13 = *(_QWORD *)(v11 + v10 + 72);
if ( v13 )
(*(void (__fastcall **)(_QWORD, __int64, _QWORD))(**(_QWORD **)(a1 + 416) + 552LL))(
*(_QWORD *)(a1 + 416),
v13,
0);
++v9;
result = v7[3];
}
while ( v9 < (__int64)(v7[4] - result) >> 2 );
}
return result;
}
}
else
{
if ( result < v4 )
goto LABEL_21;
if ( (v4 | result) >> 32 )
{
result %= v4;
LABEL_21:
if ( result != v6 )
return result;
goto LABEL_16;
}
result = (unsigned int)result % (unsigned int)v4;
if ( result != v6 )
return result;
}
LABEL_16:
v7 = (__int64 *)*v7;
}
while ( v7 );
}
}
}
return result;
}