//
// sub_1005DE618 from 0x1005de618 to 0x1005de6b0 (152 bytes)
//
// 4 xrefs:
// > sub_1005D7928 @ 0x1005d7a1c
// > sub_1005D7928 @ 0x1005d7ae0
// > sub_1005FFA90 @ 0x1005ffce8
// > sub_100611770 @ 0x1006117c0
//
// 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
//
__int64 __fastcall sub_1005DE618(int *a1, __int64 a2)
{
__int64 v2; // x9
__int64 v3; // x8
_QWORD *i; // x11
int v5; // w10
int v6; // w9
v2 = *a1;
if ( (int)v2 < 1 )
return 0;
v3 = 0;
for ( i = *((_QWORD **)a1 + 1); *i != a2; ++i )
{
if ( ++v3 >= v2 )
return 0;
}
if ( (v3 & 0x80000000) != 0 )
return 0;
v5 = v2 - 1;
if ( (int)v2 - 1 > (int)v3 )
{
*i = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3 + 8);
if ( (_DWORD)v3 != (_DWORD)v2 - 2 )
{
v6 = v2 - 2;
do
{
*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3 + 8) = *(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3 + 16);
++v3;
}
while ( v6 != (_DWORD)v3 );
}
}
*a1 = v5;
return a2;
}