//
// sub_180070A40 from 0x180070a40 to 0x180070afa (186 bytes)
//
// 3 xrefs:
// > sub_1800719C0 @ 0x180071bcc
// > sub_1800719C0 @ 0x180071edd
// > ??> @ 0x1801b4278
//
// 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_180070A40(__int64 a1, unsigned int *a2)
{
__int64 v4; // rcx
__int64 v5; // rdx
unsigned __int64 v6; // rdi
__int64 v7; // rsi
__int64 result; // rax
v4 = *(_QWORD *)(a1 + 32);
if ( ((*(_BYTE *)(a1 + 24) + (_BYTE)v4) & 3) == 0 && *(_QWORD *)(a1 + 16) <= (unsigned __int64)(v4 + 4) >> 2 )
sub_18006D4A0((_QWORD *)a1, 1u);
v5 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 24) &= 4 * v5 - 1;
v6 = *(_QWORD *)(a1 + 32) + *(_QWORD *)(a1 + 24);
v7 = 8 * ((v6 >> 2) & (v5 - 1));
if ( !*(_QWORD *)(v7 + *(_QWORD *)(a1 + 8)) )
*(_QWORD *)(v7 + *(_QWORD *)(a1 + 8)) = operator new(0x10u);
result = *a2;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + v7) + 4 * (v6 & 3)) = result;
++*(_QWORD *)(a1 + 32);
return result;
}