//
// sub_1005294D0 from 0x1005294d0 to 0x100529668 (408 bytes)
//
// 1 xrefs:
// > ??> @ 0x10085b650
//
// 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_1005294D0(_QWORD *a1, int a2)
{
_QWORD *v4; // x22
__int64 v5; // x19
__int64 v6; // x0
unsigned __int64 v7; // x24
__int64 v8; // x0
__int64 v9; // x23
int v10; // w25
__int64 result; // x0
__int64 v12; // x0
__int64 v13; // x3
if ( a2 )
{
v4 = (_QWORD *)a1[29];
v5 = a1[16] + 344LL;
if ( !v4 )
goto LABEL_6;
}
else
{
v4 = (_QWORD *)a1[26];
v5 = a1[16] + 288LL;
if ( !v4 )
{
LABEL_6:
v4 = nullptr;
v6 = 0;
goto LABEL_7;
}
}
v6 = sub_1005EB270(v4);
LABEL_7:
if ( !v6 || !v4 || !a1[38] )
{
memmove(*(void **)(v5 + 16), *(const void **)(v5 + 24), *(unsigned int *)(v5 + 4));
*(_QWORD *)(v5 + 24) = *(_QWORD *)(v5 + 16);
return 1;
}
v7 = *(unsigned int *)(v5 + 4);
v8 = sub_1005EB24C(*v4);
v9 = v8;
if ( a2 && (_DWORD)v8 != 1 )
{
v10 = v8 - (int)v7 % (int)v8;
v7 += v10;
bzero((void *)(*(_QWORD *)(v5 + 24) + *(unsigned int *)(v5 + 4)), v10);
*(_DWORD *)(v5 + 4) += v10;
*(_BYTE *)(v7 + *(_QWORD *)(v5 + 24) - 1) = v10 - 1;
}
if ( !a2 )
{
if ( !v7 )
return 0;
if ( v7 % (int)v9 )
return 0;
}
if ( (int)sub_1005EB260(v4, *(_QWORD *)(v5 + 16), *(_QWORD *)(v5 + 24), v7) < 1 )
return 0xFFFFFFFFLL;
if ( sub_1005EB2E8(a1[27]) )
{
v12 = sub_1005EB2E8(a1[27]);
v13 = sub_1005EB2A8(v12);
}
else
{
v13 = 0;
}
result = 1;
if ( !a2 && (_DWORD)v9 != 1 )
return sub_10052D1A0(a1, v5, v9, v13);
return result;
}