//
// sub_A26E8 from 0xa26e8 to 0xa285c (372 bytes)
//
// 1 xrefs:
// > sub_A1EF4 @ 0xa1ef4
//
// 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_A26E8(__int64 a1, __int64 a2, unsigned int a3, int a4)
{
__int64 result; // x0
__int64 v7; // x2
unsigned int v8; // w21
int v9; // w8
unsigned int v10; // w9
unsigned __int64 v11; // x10
bool v12; // zf
unsigned __int64 v13; // x8
unsigned int v14; // w11
unsigned int v15; // w20
__int64 v16; // x2
unsigned int v17; // [xsp+Ch] [xbp-1024h] BYREF
_DWORD v18[1024]; // [xsp+10h] [xbp-1020h] BYREF
*(_DWORD *)(a1 + 508) = a3;
if ( a4 == 8 )
return sub_E08C0(*(_QWORD *)(a1 + 368), *(_DWORD *)(a1 + 272) + a3);
if ( a3 )
{
v7 = *(_QWORD *)(a1 + 8);
v8 = *(_DWORD *)(v7 + 20);
sub_8A454(1u, v18, v7);
v9 = **(unsigned __int16 **)(a1 + 552);
if ( (v9 | 2) == 3 && (v10 = v18[0]) != 0 || (v10 = *(_DWORD *)(a1 + 504)) != 0 )
v8 = v8 / v10 * v10;
v11 = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 24LL);
v12 = (v9 | 2) == 3;
v13 = v8 * (unsigned __int64)a3 / v11;
if ( v12 && (v14 = v18[0]) != 0 || (v14 = *(_DWORD *)(a1 + 504)) != 0 )
LODWORD(v13) = (unsigned int)v13 / v14 * v14;
*(_DWORD *)(a1 + 508) = (unsigned int)v13 * v11 / v8;
}
else
{
LODWORD(v13) = 0;
}
result = sub_E08C0(*(_QWORD *)(a1 + 368), (unsigned int)(*(_DWORD *)(a1 + 272) + v13));
if ( !(_DWORD)result )
{
if ( *(_QWORD *)(a1 + 320) )
{
v15 = a3 - *(_DWORD *)(a1 + 508);
while ( v15 )
{
if ( v15 >= 0x3E8 )
v16 = 1000;
else
v16 = v15;
v17 = 0;
result = sub_D2700(a1, v18, v16, &v17);
if ( v15 >= v17 )
v15 -= v17;
else
v15 = 0;
*(_DWORD *)(a1 + 508) += v17;
if ( (_DWORD)result )
return result;
}
}
return 0;
}
return result;
}