//
// 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 (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 10:52:48 +0000
//
__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;
}