//
// sub_1005DE350 from 0x1005de350 to 0x1005de4a4 (340 bytes)
//
// 1 xrefs:
// > sub_100605958 @ 0x100605acc
//
// 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
//
int *__fastcall sub_1005DE350(__int64 a1, __int64 (*a2)(void), void (*a3)(void))
{
int *v6; // x0
int *v7; // x19
int v8; // w8
_BYTE *v9; // x0
__int64 v10; // x8
__int64 v11; // x9
int v12; // w8
__int64 i; // x23
__int64 v14; // x0
__int64 v15; // x21
__int64 v16; // x8
void *v17; // x0
v6 = (int *)sub_100588710(32, (__int64)"stack.c", 124);
v7 = v6;
if ( v6 )
{
*((_QWORD *)v6 + 3) = *(_QWORD *)(a1 + 24);
v6[4] = *(_DWORD *)(a1 + 16);
*v6 = *(_DWORD *)a1;
v8 = *(_DWORD *)a1;
if ( *(int *)a1 <= 4 )
v8 = 4;
v6[5] = v8;
v9 = sub_100588710((unsigned int)(8 * v8), (__int64)"stack.c", 130);
*((_QWORD *)v7 + 1) = v9;
if ( v9 )
{
v10 = v7[5];
if ( (int)v10 >= 1 )
{
*(_QWORD *)v9 = 0;
v11 = 1;
if ( (int)v10 > 1 )
{
do
*(_QWORD *)(*((_QWORD *)v7 + 1) + 8 * v11++) = 0;
while ( v11 < v10 );
}
}
v12 = *v7;
if ( *v7 >= 1 )
{
for ( i = 0; i < v12; ++i )
{
if ( *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * i) )
{
v14 = a2();
*(_QWORD *)(*((_QWORD *)v7 + 1) + 8 * i) = v14;
if ( !v14 )
{
if ( (int)i >= 1 )
{
v15 = (int)i - 1LL;
do
{
if ( *(_QWORD *)(*((_QWORD *)v7 + 1) + 8 * v15) )
a3();
v16 = v15-- + 1;
}
while ( v16 > 1 );
}
v17 = *((void **)v7 + 1);
if ( v17 )
sub_100588C44(v17);
goto LABEL_22;
}
v12 = *v7;
}
}
}
}
else
{
LABEL_22:
sub_100588C44(v7);
return nullptr;
}
}
return v7;
}