//
// sub_1403BDC20 from 0x1403bdc20 to 0x1403bdd8a (362 bytes)
//
// 6 xrefs:
// > PlayLayer::createObjectsFromSetupFinished @ 0x1403adcf5
// > ??> @ 0x14069ab48
// > ??> @ 0x14069ab60
// > ??> @ 0x14069ab80
// > ??> @ 0x14069ab90
// > ??> @ 0x1406d7610
//
// 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
//
char *__fastcall sub_1403BDC20(__int64 a1, unsigned __int64 a2, __int64 a3)
{
__int64 v5; // rbp
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rcx
unsigned __int64 v8; // rax
__int64 v9; // r14
_QWORD *v10; // rsi
_QWORD *v11; // r8
if ( a2 > 0x5555555555555555LL )
sub_140062A20(a1, a2);
v5 = (*(_QWORD *)(a1 + 8) - *(_QWORD *)a1) / 3LL;
v6 = (*(_QWORD *)(a1 + 16) - *(_QWORD *)a1) / 3LL;
v7 = v6 >> 1;
if ( v6 <= 0x5555555555555555LL - (v6 >> 1) )
{
v8 = v7 + v6;
if ( v7 + v6 >= a2 )
{
if ( v8 > 0x5555555555555555LL )
sub_140007AB0(v7, v6, a3);
}
else
{
v8 = a2;
}
}
else
{
v8 = 0x5555555555555555LL;
}
v9 = 3 * v8;
v10 = sub_14003AA10(3 * v8);
if ( a2 != v5 )
memset((char *)v10 + 2 * v5 + v5, 0, 3 * (a2 - v5));
memmove(v10, *(const void **)a1, *(_QWORD *)(a1 + 8) - *(_QWORD *)a1);
v11 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
if ( (unsigned __int64)(3 * ((*(_QWORD *)(a1 + 16) - (_QWORD)v11) / 3LL)) >= 0x1000 )
{
if ( (unsigned __int64)v11 - *(v11 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v11 = (_QWORD *)*(v11 - 1);
}
j_j_free(v11);
}
*(_QWORD *)a1 = v10;
*(_QWORD *)(a1 + 8) = (char *)v10 + 2 * a2 + a2;
*(_QWORD *)(a1 + 16) = (char *)v10 + v9;
return (char *)v10 + v9;
}