//
// sub_1005FDB00 from 0x1005fdb00 to 0x1005fdc3c (316 bytes)
//
// 3 xrefs:
// > sub_1005DC790 @ 0x1005dd228
// > sub_1005DC790 @ 0x1005dd612
// > sub_1005E29A0 @ 0x1005e765a
//
// 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:34:29 +0000
//
__int64 __fastcall sub_1005FDB00(__int64 a1, __int64 *a2, __int64 a3, unsigned int a4)
{
unsigned __int64 v4; // r10
unsigned __int64 v5; // rax
__int64 v7; // r8
__int64 **v8; // r9
__int64 v9; // rdx
__int64 *v10; // rdi
__int64 v11; // r10
unsigned __int64 v12; // rsi
unsigned __int64 v13; // rdi
__int64 **v14; // rax
__int64 *i; // r11
unsigned __int64 v16; // rax
if ( *(_QWORD *)(a1 + 24) != a2[3] )
return 0;
v4 = a2[1];
v5 = v4 - 1;
if ( !v4 )
{
LOBYTE(a4) = *(_QWORD *)(a1 + 16) == 0;
return a4;
}
v7 = *a2;
a4 = v4 - 1;
v8 = *(__int64 ***)(a1 + 16);
if ( ((v4 - 1) & v4) != 0 )
{
LOBYTE(a4) = 1;
if ( !v8 )
return a4;
LABEL_16:
v12 = *((int *)v8 + 4);
v13 = v12;
if ( v4 <= v12 )
{
if ( (v4 | v12) >> 32 )
v13 = v12 % v4;
else
v13 = (unsigned int)v12 % (unsigned int)v4;
}
v14 = *(__int64 ***)(v7 + 8 * v13);
if ( !v14 )
return 0;
for ( i = *v14; ; i = (__int64 *)*i )
{
if ( !i )
return 0;
v16 = i[1];
if ( v16 == v12 )
{
if ( *((_DWORD *)i + 4) == (_DWORD)v12 )
{
v8 = (__int64 **)*v8;
if ( v8 )
goto LABEL_16;
return a4;
}
}
else
{
if ( v16 < v4 )
goto LABEL_29;
if ( (v4 | v16) >> 32 )
{
v16 %= v4;
LABEL_29:
if ( v16 != v13 )
return 0;
continue;
}
if ( (unsigned int)v16 % (unsigned int)v4 != v13 )
return 0;
}
}
}
LOBYTE(a4) = 1;
if ( !v8 )
return a4;
LABEL_7:
v9 = *((int *)v8 + 4);
v10 = *(__int64 **)(v7 + 8 * (v9 & v5));
if ( v10 )
{
while ( 1 )
{
v10 = (__int64 *)*v10;
if ( !v10 )
break;
v11 = v10[1];
if ( v11 == v9 )
{
if ( *((_DWORD *)v10 + 4) == (_DWORD)v9 )
{
v8 = (__int64 **)*v8;
if ( v8 )
goto LABEL_7;
return a4;
}
}
else if ( (v5 & v11) != (v9 & v5) )
{
return 0;
}
}
}
return 0;
}