//
// sub_180113300 from 0x180113300 to 0x1801133f5 (245 bytes)
//
// 4 xrefs:
// > ??> @ 0x18016e828
// > ??> @ 0x180190de8
// > ??> @ 0x180190e1c
// > ??> @ 0x180201cc4
//
// 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_180113300(__int64 a1, int a2, unsigned int a3, _DWORD *a4)
{
_DWORD *v5; // r15
__int64 v6; // rcx
unsigned int v9; // ebp
__int64 v11; // rcx
unsigned __int8 (__fastcall ***v12)(_QWORD); // r14
int v13; // esi
__int64 v14; // rdx
int v15; // r9d
int v16; // eax
unsigned int v17; // eax
int v18; // ecx
int v19; // [rsp+70h] [rbp+8h] BYREF
_DWORD *v20; // [rsp+88h] [rbp+20h]
v20 = a4;
*a4 = 0;
v5 = a4;
v6 = *(_QWORD *)(a1 + 408);
v9 = 13;
if ( !v6 )
return 28;
v11 = *(_QWORD *)(v6 + 74088);
if ( v11 )
{
v12 = sub_1800DA200(v11, 10);
if ( v12 )
{
v13 = 0;
if ( a3 )
{
do
{
v14 = *(_QWORD *)(a1 + 504);
v15 = a3;
v16 = *(_DWORD *)(a1 + 496);
if ( a3 > 0x10000 )
v15 = 0x10000;
v19 = 0;
v17 = sub_180114590((_DWORD)v12, v14, a2 + v13, v15, v16, (__int64)&v19);
v18 = v19;
v9 = v17;
*(_DWORD *)(a1 + 496) += v19;
a3 -= v18;
v13 += v18;
}
while ( !v17 && a3 );
v5 = v20;
}
*v5 = v13;
}
}
return v9;
}