//
// sub_1006401F0 from 0x1006401f0 to 0x100640425 (565 bytes)
//
// 1 xrefs:
// > TabbedPopupLayer::addTab @ 0x10063f215
//
// 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 12:34:42 +0000
//
__int64 __fastcall sub_1006401F0(void ***a1, __int64 a2)
{
void **v2; // rcx
unsigned __int64 v3; // r12
unsigned __int64 v4; // r15
_QWORD *v5; // rax
__int64 v6; // rcx
void **v7; // r14
void **v8; // r13
__int64 v9; // rdx
void **v10; // r12
__int64 v11; // r15
char *v12; // rax
__int64 v13; // rcx
__int64 v14; // rdx
void **v16; // [rsp+0h] [rbp-30h]
v2 = *a1;
v3 = 0x8E38E38E38E38E39LL * (a1[1] - *a1);
v4 = v3 + 1;
if ( v3 + 1 > 0x38E38E38E38E38ELL )
sub_100640430(a1);
if ( 0x1C71C71C71C71C72LL * (a1[2] - v2) > v4 )
v4 = 0x1C71C71C71C71C72LL * (a1[2] - v2);
if ( 0x8E38E38E38E38E39LL * (a1[2] - v2) >= 0x1C71C71C71C71C7LL )
v4 = 0x38E38E38E38E38ELL;
if ( v4 )
{
if ( v4 > 0x38E38E38E38E38ELL )
sub_10001ADB0();
v5 = operator new(72 * v4);
}
else
{
v5 = nullptr;
}
v6 = 9 * v3;
v5[v6 + 2] = *(_QWORD *)(a2 + 16);
*(_OWORD *)&v5[v6] = *(_OWORD *)a2;
*(_OWORD *)a2 = 0;
*(_QWORD *)(a2 + 16) = 0;
v5[v6 + 5] = *(_QWORD *)(a2 + 40);
*(_OWORD *)&v5[v6 + 3] = *(_OWORD *)(a2 + 24);
*(_OWORD *)(a2 + 24) = 0;
*(_QWORD *)(a2 + 40) = 0;
v5[v6 + 8] = *(_QWORD *)(a2 + 64);
*(_OWORD *)&v5[v6 + 6] = *(_OWORD *)(a2 + 48);
v7 = *a1;
v8 = a1[1];
v9 = (char *)v8 - (char *)*a1;
v10 = (void **)((char *)&v5[9 * v3] - v9);
v16 = (void **)&v5[9 * v4];
v11 = (__int64)&v5[v6 + 9];
if ( v8 != *a1 )
{
v12 = (char *)&v5[v6 - (v9 >> 3)];
v13 = 0;
do
{
*(_QWORD *)&v12[v13 * 8 + 16] = v7[v13 + 2];
*(_OWORD *)&v12[v13 * 8] = *(_OWORD *)&v7[v13];
*(_OWORD *)&v7[v13] = 0;
v7[v13 + 2] = nullptr;
*(_QWORD *)&v12[v13 * 8 + 40] = v7[v13 + 5];
*(_OWORD *)&v12[v13 * 8 + 24] = *(_OWORD *)&v7[v13 + 3];
*(_OWORD *)&v7[v13 + 3] = 0;
v7[v13 + 5] = nullptr;
*(_QWORD *)&v12[v13 * 8 + 64] = v7[v13 + 8];
*(_OWORD *)&v12[v13 * 8 + 48] = *(_OWORD *)&v7[v13 + 6];
v14 = (__int64)&v7[v13 + 9];
v13 += 9;
}
while ( (void **)v14 != v8 );
while ( 1 )
{
if ( ((_BYTE)v7[3] & 1) != 0 )
{
operator delete(v7[5]);
if ( (*(_BYTE *)v7 & 1) != 0 )
LABEL_19:
operator delete(v7[2]);
}
else if ( (*(_BYTE *)v7 & 1) != 0 )
{
goto LABEL_19;
}
v7 += 9;
if ( v7 == v8 )
{
v7 = *a1;
break;
}
}
}
*a1 = v10;
a1[1] = (void **)v11;
a1[2] = v16;
if ( v7 )
operator delete(v7);
return v11;
}