//
// sub_1004DA470 from 0x1004da470 to 0x1004da548 (216 bytes)
//
// 2 xrefs:
// > sub_1004ECE90 @ 0x1004ed240
// > sub_1004ED490 @ 0x1004ed52c
//
// 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_1004DA470(__int64 result, __int64 a2)
{
__int64 v2; // x8
__int64 v3; // x12
__int64 v4; // x13
int v5; // w10
int v6; // w11
int v7; // w9
__int64 v8; // x10
__int64 v9; // x12
int *v10; // x13
int v11; // t1
int v12; // w17
if ( result )
{
v2 = *(_QWORD *)result;
if ( *(_QWORD *)result && (v3 = *(int *)(result + 52), *(_DWORD *)(result + 48) > (int)v3) )
{
v4 = *(_QWORD *)(result + 24);
if ( (*(_DWORD *)(v4 + 4 * v3) & 0x400) != 0 )
{
*(_DWORD *)(result + 52) = v3 + 1;
++*(_QWORD *)(result + 360);
return 0xFFFFFFFFLL;
}
else if ( a2 )
{
v5 = (unsigned __int8)*(_DWORD *)(v4 + 4 * v3);
v6 = *(_DWORD *)(v4 + 4 * v3) & 0x200;
v7 = *(_DWORD *)(v4 + 4 * v3) & 0x100;
if ( v5 == 255 )
{
v8 = v4 + 4 * v3;
v9 = v3 << 32;
v10 = (int *)(v8 + 4);
v5 = 255;
do
{
v11 = *v10++;
v12 = (unsigned __int8)v11;
if ( (v11 & 0x200) != 0 )
v6 = 512;
v5 += v12;
v9 += (__int64)&_mh_execute_header;
}
while ( v12 == 255 );
v3 = v9 >> 32;
}
*(_DWORD *)(a2 + 16) = v6;
*(_QWORD *)a2 = v2 + *(int *)(result + 16);
*(_QWORD *)(a2 + 32) = *(_QWORD *)(result + 360);
*(_QWORD *)(a2 + 24) = *(_QWORD *)(*(_QWORD *)(result + 32) + 8 * v3);
*(_DWORD *)(a2 + 8) = v5;
*(_DWORD *)(a2 + 12) = v7;
return 1;
}
else
{
return 1;
}
}
else
{
return 0;
}
}
return result;
}