//
// sub_10039078C from 0x10039078c to 0x100390840 (180 bytes)
//
// 7 xrefs:
// > sub_100390450 @ 0x100390468
// > sub_100390480 @ 0x100390498
// > sub_1003904B0 @ 0x1003904c8
// > sub_1004AFBBC @ 0x1004b017c
// > sub_1004AFBBC @ 0x1004b0554
// > sub_1004B26F4 @ 0x1004b2720
// > sub_1004B2F00 @ 0x1004b2f28
//
// This function is hookable on this platform (idp: arm, 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 11:03:37 +0000
//
__int64 *__fastcall sub_10039078C(_QWORD *a1, unsigned int *a2)
{
int8x8_t v2; // x8
unsigned __int64 v3; // x9
uint8x8_t v4; // d0
__int64 v5; // x11
__int64 **v6; // x12
__int64 *result; // x0
unsigned __int64 v8; // x13
v2 = (int8x8_t)a1[1];
if ( !*(_QWORD *)&v2 )
return nullptr;
v3 = *a2;
v4 = (uint8x8_t)vcnt_s8(v2);
v4.i16[0] = vaddlv_u8(v4);
if ( v4.u32[0] > 1uLL )
{
v5 = *a2;
if ( *(_QWORD *)&v2 <= v3 )
v5 = (unsigned int)v3 % v2.i32[0];
}
else
{
v5 = (v2.i32[0] - 1) & (unsigned int)v3;
}
v6 = *(__int64 ***)(*a1 + 8 * v5);
if ( !v6 )
return nullptr;
for ( result = *v6; result; result = (__int64 *)*result )
{
v8 = result[1];
if ( v8 == v3 )
{
if ( *((_DWORD *)result + 4) == (_DWORD)v3 )
return result;
}
else
{
if ( v4.u32[0] > 1uLL )
{
if ( v8 >= *(_QWORD *)&v2 )
v8 %= *(_QWORD *)&v2;
}
else
{
v8 &= *(_QWORD *)&v2 - 1LL;
}
if ( v8 != v5 )
return nullptr;
}
}
return result;
}