//
// sub_85A08 from 0x85a08 to 0x85b26 (286 bytes)
//
// 1 xrefs:
// > sub_85384 @ 0x85384
//
// 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
//
int __fastcall sub_85A08(int a1, int a2, unsigned int a3, int a4)
{
int v7; // r2
unsigned int v8; // r8
int v9; // r10
unsigned int v10; // r1
unsigned int v11; // r6
unsigned int v12; // r1
int v13; // r6
unsigned int v14; // r5
int v15; // r2
int v16; // r0
bool v17; // cf
unsigned int v18; // [sp+0h] [bp-1020h] BYREF
_DWORD v19[1025]; // [sp+4h] [bp-101Ch] BYREF
*(_DWORD *)(a1 + 336) = a3;
if ( a4 == 8 )
return sub_BBB84(*(_DWORD *)(a1 + 220), *(_DWORD *)(a1 + 152) + a3);
if ( a3 )
{
v7 = *(_DWORD *)(a1 + 4);
v8 = *(_DWORD *)(v7 + 16);
sub_71348(1u, v19, v7);
v9 = **(unsigned __int16 **)(a1 + 380) | 2;
if ( v9 == 3 && (v10 = v19[0]) != 0 || (v10 = *(_DWORD *)(a1 + 332)) != 0 )
v8 -= v8 % v10;
v11 = v8 * (unsigned __int64)a3 / *(unsigned int *)(*(_DWORD *)(a1 + 4) + 20);
if ( v9 == 3 && (v12 = v19[0]) != 0 || (v12 = *(_DWORD *)(a1 + 332)) != 0 )
v11 -= (unsigned int)(v8 * (unsigned __int64)a3 / *(unsigned int *)(*(_DWORD *)(a1 + 4) + 20)) % v12;
*(_DWORD *)(a1 + 336) = v11 * (unsigned __int64)*(unsigned int *)(*(_DWORD *)(a1 + 4) + 20) / v8;
}
else
{
v11 = 0;
}
v13 = sub_BBB84(*(_DWORD *)(a1 + 220), *(_DWORD *)(a1 + 152) + v11);
if ( !v13 )
{
v13 = 0;
if ( *(_DWORD *)(a1 + 184) )
{
v14 = a3 - *(_DWORD *)(a1 + 336);
while ( v14 )
{
v15 = v14;
if ( v14 >= 0x3E8 )
v15 = 1000;
v18 = 0;
v16 = sub_B0630(a1, v19, v15, &v18);
v17 = v14 >= v18;
v14 -= v18;
*(_DWORD *)(a1 + 336) += v18;
if ( !v17 )
v14 = 0;
if ( v16 )
return v16;
}
return 0;
}
}
return v13;
}