//
// sub_180018340 from 0x180018340 to 0x18001839c (92 bytes)
//
// 6 xrefs:
// > sub_180001E90 @ 0x18000206c
// > sub_180001E90 @ 0x1800020e4
// > sub_180001E90 @ 0x180002180
// > sub_180001E90 @ 0x1800021c1
// > sub_180001E90 @ 0x18000224a
// > sub_180007790 @ 0x1800077df
//
// 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_180018340(int a1, int a2)
{
__int64 v2; // r9
__int64 v3; // rdx
__int64 result; // rax
int v5; // r11d
if ( !qword_1801B2810 || dword_1801B2818 <= 0 )
return 0;
v2 = ~(a1 - 1);
v3 = v2 & (a2 - 1 + a1);
result = v2 & (qword_1801B2810 + a1 - 1LL);
v5 = dword_1801B2818 - ((v2 & (qword_1801B2810 + a1 - 1)) - qword_1801B2810 + v3);
qword_1801B2810 = v3 + result;
dword_1801B2818 = v5;
return result;
}