//
// sub_100501CEC from 0x100501cec to 0x100501d4c (96 bytes)
//
// 5 xrefs:
// > sub_1004FC26C @ 0x1004fc604
// > sub_1004FC26C @ 0x1004fc678
// > sub_1004FC26C @ 0x1004fc760
// > sub_1004FC26C @ 0x1004fc80c
// > sub_1004FF814 @ 0x1004ff858
//
// 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_100501CEC(int a1, int a2)
{
bool v2; // cc
int v3; // w13
int v4; // w14
__int64 result; // x0
int v6; // w11
int v7; // w12
if ( qword_1008818E0 )
v2 = dword_1008818E8 < 1;
else
v2 = 1;
if ( v2 )
return 0;
v3 = a1 + a2;
v4 = -a1;
result = (qword_1008818E0 + a1 - 1) & -a1;
v6 = result - qword_1008818E0;
v7 = (v3 - 1) & v4;
qword_1008818E0 = result + v7;
dword_1008818E8 = dword_1008818E8 - v7 - v6;
return result;
}