//
// sub_140376050 from 0x140376050 to 0x140376262 (530 bytes)
//
// 3 xrefs:
// > GJEffectManager::saveToState @ 0x14036eb86
// > GJEffectManager::loadFromState @ 0x14036f156
// > ??> @ 0x140922124
//
// 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:31:01 +0000
//
// Hidden C++ exception states: #wind=2
void __fastcall sub_140376050(void ****a1, void **a2, void **a3)
{
void **v6; // r14
void **v7; // rsi
__int64 v8; // r15
void ***v9; // r14
__int64 v10; // rcx
void ***v11; // r12
void **i; // rbx
void **v13; // rsi
__int64 v14; // rcx
void ***v15; // rax
__int64 v16; // rbp
void **v17; // rbx
void **v18; // rcx
void **v19; // rax
v6 = (void **)*a1;
v7 = **a1;
if ( v7 == (void **)*a1 )
{
LABEL_6:
v8 = 0;
if ( a2 == a3 )
{
v9 = nullptr;
v11 = nullptr;
}
else
{
v9 = (void ***)operator new(0x30u);
sub_1403791A0(v10, v9 + 2, a2 + 2);
v11 = v9;
v8 = 1;
for ( i = (void **)*a2; i != a3; i = (void **)*i )
{
v13 = (void **)operator new(0x30u);
sub_1403791A0(v14, v13 + 2, i + 2);
*v11 = v13;
v13[1] = v11;
v11 = (void ***)v13;
++v8;
}
}
v18 = (void **)*a1;
if ( v8 )
{
v19 = (void **)v18[1];
v9[1] = v19;
*v19 = v9;
*v11 = v18;
v18[1] = v11;
a1[1] = (void ***)((char *)a1[1] + v8);
}
}
else
{
while ( a2 != a3 )
{
*((_DWORD *)v7 + 4) = *((_DWORD *)a2 + 4);
if ( v7 != a2 )
sub_140379B20(v7 + 3, a2[3], ((_BYTE *)a2[4] - (_BYTE *)a2[3]) / 56);
v7 = (void **)*v7;
a2 = (void **)*a2;
if ( v7 == v6 )
goto LABEL_6;
}
if ( v7 != v6 )
{
v15 = (void ***)v7[1];
*v15 = v6;
v6[1] = v15;
v16 = 0;
do
{
v17 = (void **)*v7;
sub_140373070(v7 + 3);
j_j_free(v7);
v7 = v17;
++v16;
}
while ( v17 != v6 );
a1[1] = (void ***)((char *)a1[1] - v16);
}
}
}