//
// sub_14051BA40 from 0x14051ba40 to 0x14051bb04 (196 bytes)
//
// 5 xrefs:
// > PlayLayer::saveDynamicSaveObjects @ 0x140517896
// > sub_14052F710 @ 0x14052f7d6
// > ??> @ 0x1408d7834
// > ??> @ 0x1408d7844
// > ??> @ 0x14092af2c
//
// 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 11:33:35 +0000
//
unsigned __int64 __fastcall sub_14051BA40(__int64 a1, unsigned __int64 a2)
{
__int64 v3; // r8
unsigned __int64 result; // rax
__int64 v6; // rdi
_QWORD *v7; // rbx
v3 = *(_QWORD *)(a1 + 16) - *(_QWORD *)a1;
result = (unsigned __int64)((unsigned __int128)(v3 * (__int128)0x2AAAAAAAAAAAAAABLL) >> 64) >> 63;
if ( a2 > v3 / 48 )
{
if ( a2 > 0x555555555555555LL )
sub_14005A170();
v6 = (*(_QWORD *)(a1 + 8) - *(_QWORD *)a1) / 48LL;
v7 = sub_14003D460(48 * a2);
memmove(v7, *(const void **)a1, *(_QWORD *)(a1 + 8) - *(_QWORD *)a1);
return sub_140418E30(a1, (__int64)v7, v6, a2);
}
return result;
}