//
// sub_140083390 from 0x140083390 to 0x1400834ba (298 bytes)
//
// 17 xrefs:
// > ScrollableContentLayer::reloadVirtualRows @ 0x140082ac1
// > sub_1400EB320 @ 0x1400eb5b6
// > GameManager::init @ 0x140276393
// > sub_14030A310 @ 0x14030a37f
// > GJBaseGameLayer::init @ 0x14030d61a
// > GJBaseGameLayer::init @ 0x14030d62b
// > GJBaseGameLayer::addToSection @ 0x14032f3f4
// > GJBaseGameLayer::addToSection @ 0x14032f629
// > GJBaseGameLayer::addToSection @ 0x14032f8aa
// > LevelEditorLayer::init @ 0x1403ee0d7
// > LevelSettingsObject::touchIDUsage @ 0x14040e8f1
// > MusicBrowser::cellPerformedAction @ 0x14047d433
// > PlayLayer::createObjectsFromSetupFinished @ 0x14050c643
// > ??> @ 0x14088b584
// > ??> @ 0x14088b594
// > ??> @ 0x14088b5a8
// > ??> @ 0x140912350
//
// 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:25:56 +0000
//
char *__fastcall sub_140083390(__int64 a1, unsigned __int64 a2)
{
char *v2; // rbp
char *result; // rax
unsigned __int64 v6; // rsi
unsigned __int64 v7; // rcx
unsigned __int64 v8; // rdx
unsigned __int64 v9; // rbp
_QWORD *v10; // rbx
size_t v11; // rbx
v2 = *(char **)(a1 + 8);
result = *(char **)a1;
v6 = (__int64)&v2[-*(_QWORD *)a1] >> 2;
if ( a2 >= v6 )
{
if ( a2 > v6 )
{
v7 = (__int64)(*(_QWORD *)(a1 + 16) - (_QWORD)result) >> 2;
if ( a2 <= v7 )
{
v11 = 4 * (a2 - v6);
memset(v2, 0, v11);
result = &v2[v11];
*(_QWORD *)(a1 + 8) = &v2[v11];
}
else
{
if ( a2 > 0x3FFFFFFFFFFFFFFFLL )
sub_14005A170();
v8 = v7 >> 1;
if ( v7 <= 0x3FFFFFFFFFFFFFFFLL - (v7 >> 1) )
{
v9 = v7 + v8;
if ( v7 + v8 >= a2 )
{
if ( v9 > 0x3FFFFFFFFFFFFFFFLL )
sub_140009CF0(v7, v8, 0x3FFFFFFFFFFFFFFFLL);
}
else
{
v9 = a2;
}
}
else
{
v9 = 0x3FFFFFFFFFFFFFFFLL;
}
v10 = sub_14003D460(4 * v9);
memset((char *)v10 + 4 * v6, 0, 4 * (a2 - v6));
memmove(v10, *(const void **)a1, *(_QWORD *)(a1 + 8) - *(_QWORD *)a1);
return (char *)sub_14006B840(a1, (__int64)v10, a2, v9);
}
}
}
else
{
result += 4 * a2;
*(_QWORD *)(a1 + 8) = result;
}
return result;
}