//
// sub_1004B65E4 from 0x1004b65e4 to 0x1004b66c0 (220 bytes)
//
// 1 xrefs:
// > sub_1004D4110 @ 0x1004d416c
//
// 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_1004B65E4(__int64 a1, __int64 a2)
{
unsigned int (__fastcall *v2)(__int64, __int64, int *); // x8
signed int v6; // w8
signed int v7; // w2
__int64 v8; // x8
int v9; // w8
int v10; // [xsp+Ch] [xbp-14h] BYREF
v2 = *(unsigned int (__fastcall **)(__int64, __int64, int *))(a1 + 1016);
if ( v2 )
{
if ( !*(_DWORD *)(a2 + 36) || *(_BYTE *)(a2 + 49) )
return 0;
v10 = 0;
if ( !v2(a1 + 8, a2, &v10) )
{
v6 = *(_DWORD *)(a2 + 36);
v7 = v10 - *(_DWORD *)(a2 + 20);
if ( v7 < 0 && (v7 += v6, v7 < 0) || v7 > v6 )
v7 = 0;
v8 = *(_QWORD *)(a2 + 72);
if ( v8 )
{
v9 = *(_DWORD *)(v8 + 640);
if ( v7 < 3 * v9 )
return 0;
v7 = v7 - v9 - v7 % v9;
}
else if ( v7 < 1 )
{
return 0;
}
if ( !(unsigned int)sub_1004B62D4(a1, a2, v7) )
return 0;
}
*(_BYTE *)(a2 + 49) = 1;
return 0;
}
return 66;
}