//
// sub_1800C0360 from 0x1800c0360 to 0x1800c04f3 (403 bytes)
//
// 2 xrefs:
// > sub_1800BF8E0 @ 0x1800bf914
// > ??> @ 0x1801fd9ec
//
// 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_1800C0360(__int64 a1, void *a2, __int64 a3, unsigned int *a4)
{
int v7; // ecx
__int64 v8; // rcx
unsigned int v9; // ebx
int v10; // ecx
__int64 v11; // rcx
unsigned int v12; // ebx
unsigned int v13; // r8d
unsigned __int64 v14; // rcx
__int64 result; // rax
int v16; // [rsp+40h] [rbp-48h] BYREF
int v17; // [rsp+44h] [rbp-44h] BYREF
__int64 v18; // [rsp+48h] [rbp-40h] BYREF
__int64 v19; // [rsp+50h] [rbp-38h] BYREF
__int64 v20[6]; // [rsp+58h] [rbp-30h] BYREF
__int16 v21; // [rsp+90h] [rbp+8h] BYREF
unsigned int v22; // [rsp+A8h] [rbp+20h] BYREF
v18 = 0;
v20[0] = 0;
v17 = 0;
v16 = 0;
v21 = 0;
v19 = 0;
v22 = 0;
*a4 = 0;
while ( 1 )
{
v7 = (*(__int64 (__fastcall **)(_QWORD, _QWORD, __int64 *, __int64, __int64 *, int *, int *, __int16 *))(**(_QWORD **)(a1 + 376) + 56LL))(
*(_QWORD *)(a1 + 376),
*(unsigned __int16 *)(a1 + 392),
&v18,
a1 + 400,
v20,
&v17,
&v16,
&v21);
if ( v7 < 0 )
break;
(*(void (__fastcall **)(__int64, __int64 *, unsigned int *))(*(_QWORD *)v18 + 56LL))(v18, &v19, &v22);
v8 = *(unsigned int *)(a1 + 424);
v9 = v22;
if ( (unsigned int)v8 < v22 )
{
memmove(a2, (const void *)(v19 + v8), v22 - (unsigned int)v8);
v11 = *(_QWORD *)(a1 + 8);
v12 = v9 - *(_DWORD *)(a1 + 424);
v13 = *(_DWORD *)(v11 + 12);
if ( v13 )
{
switch ( *(_DWORD *)(v11 + 8) )
{
case 1:
v14 = 8;
break;
case 2:
v14 = 16;
break;
case 3:
v14 = 24;
break;
default:
if ( (unsigned int)(*(_DWORD *)(v11 + 8) - 4) >= 2 )
{
*a4 = v12;
goto LABEL_16;
}
v14 = 32;
break;
}
*a4 = (unsigned int)(8 * (unsigned __int64)v12 / v14) / v13;
}
LABEL_16:
v10 = 0;
goto LABEL_17;
}
v10 = v8 - v22;
LABEL_17:
*(_DWORD *)(a1 + 424) = v10;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v18 + 16LL))(v18);
if ( *a4 )
return 0;
}
result = 13;
if ( v7 == -1072886833 )
return 16;
return result;
}