//
// sub_140249580 from 0x140249580 to 0x14024960f (143 bytes)
//
// 10 xrefs:
// > GJBaseGameLayer::addToSection @ 0x1402265be
// > GJBaseGameLayer::addToSection @ 0x1402265d0
// > GJBaseGameLayer::addToSection @ 0x140226662
// > GJBaseGameLayer::addToSection @ 0x140226857
// > GJBaseGameLayer::addToSection @ 0x140226ae8
// > GJBaseGameLayer::addToSection @ 0x140226af7
// > GJBaseGameLayer::addToSection @ 0x140226c0e
// > ??> @ 0x140682934
// > ??> @ 0x140682944
// > ??> @ 0x1406ce868
//
// 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_140249580(__int64 *a1, unsigned __int64 a2)
{
char *v2; // rsi
__int64 v4; // r8
unsigned __int64 v5; // rcx
__int64 result; // rax
size_t v7; // rbx
v2 = (char *)a1[1];
v4 = *a1;
v5 = (__int64)&v2[-*a1] >> 3;
if ( a2 >= v5 )
{
if ( a2 > v5 )
{
if ( a2 <= (a1[2] - v4) >> 3 )
{
v7 = 8 * (a2 - v5);
memset(v2, 0, v7);
a1[1] = (__int64)&v2[v7];
return (__int64)&v2[v7];
}
else
{
return sub_140252CD0(a1, a2);
}
}
}
else
{
result = v4 + 8 * a2;
a1[1] = result;
}
return result;
}