//
// sub_1005EF964 from 0x1005ef964 to 0x1005efb14 (432 bytes)
//
// 1 xrefs:
// > sub_1005F6BDC @ 0x1005f6ce8
//
// 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_1005EF964(__int64 a1, char **a2)
{
int v3; // w9
int v4; // w10
_BYTE *v5; // x8
int v6; // w12
unsigned int v7; // w11
__int64 v9; // x12
_BOOL4 v10; // w12
char v11; // w11
__int64 v12; // x20
char *v13; // x8
unsigned __int8 *v14; // x1
__int64 v15; // x10
__int64 v16; // x11
char *v17; // x13
int v18; // w10
__int64 v19; // x14
char *v20; // x8
int v21; // w15
char *v22; // x8
char *v23; // x10
char v24; // t1
if ( !a1 )
return 0;
v3 = *(_DWORD *)a1;
v4 = *(_DWORD *)(a1 + 4) & 0x100;
if ( !*(_DWORD *)a1 )
{
v10 = 0;
v11 = 0;
v12 = 1;
goto LABEL_23;
}
v5 = *(_BYTE **)(a1 + 8);
if ( *v5 )
v6 = *(_DWORD *)(a1 + 4) & 0x100;
else
v6 = 0;
if ( v3 == 1 )
v4 = v6;
if ( !v4 )
{
v11 = 0;
v10 = (char)*v5 < 0;
goto LABEL_22;
}
v7 = (unsigned __int8)*v5;
if ( v7 > 0x80 )
goto LABEL_20;
if ( v7 == 128 && v3 >= 2 )
{
v9 = 1;
while ( !v5[v9] )
{
if ( ++v9 >= v3 )
goto LABEL_17;
}
LABEL_20:
v11 = -1;
v10 = 1;
goto LABEL_22;
}
LABEL_17:
v10 = 0;
v11 = 0;
LABEL_22:
v12 = (unsigned int)(v10 + v3);
LABEL_23:
if ( a2 )
{
v13 = *a2;
if ( v10 )
{
*v13++ = v11;
v3 = *(_DWORD *)a1;
}
if ( v3 )
{
v14 = *(unsigned __int8 **)(a1 + 8);
if ( v4 )
{
v15 = v3 - 1LL;
v16 = (__int64)&v14[v15];
v17 = &v13[v15];
v18 = v14[v15];
if ( v3 >= 2 && !v18 )
{
v19 = 0;
v20 = &v13[v3 - 1];
do
{
v20[v19] = 0;
v18 = v14[v3 - 2 + v19];
v21 = v3 - 1 + v19--;
}
while ( v21 >= 2 && !v18 );
v16 = (__int64)&v14[v3 - 1 + v19];
v17 = &v20[v19];
v3 += v19;
}
*v17 = -(char)v18;
if ( v3 >= 2 )
{
v22 = (char *)(v16 - 1);
v23 = v17 - 1;
do
{
--v3;
v24 = *v22--;
*v23-- = ~v24;
}
while ( v3 > 1 );
}
}
else
{
memcpy(v13, v14, (unsigned int)v3);
}
}
else
{
*v13 = 0;
}
*a2 += (int)v12;
}
return v12;
}