//
// sub_B76BBC from 0xb76bbc to 0xb76cb8 (252 bytes)
//
// 4 xrefs:
// > sub_B77D60 @ 0xb77e54
// > sub_B77D60 @ 0xb77e5c
// > sub_B787B0 @ 0xb79acc
// > sub_B787B0 @ 0xb79adc
//
// 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
//
signed __int64 __fastcall sub_B76BBC(void *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // x19
__int64 v5; // x21
signed __int64 v6; // x4
signed __int64 v8; // x20
const void *v9; // x1
__int64 v10; // x0
__int64 v11; // x2
__int64 v12; // x1
__int64 v13; // x4
int v14; // w0
__int64 v16; // x2
v4 = *(_QWORD *)(*(_QWORD *)a4 + 536LL);
v5 = 0;
v6 = *(_QWORD *)(v4 + 8);
if ( !v6 )
return v5;
v8 = a2 * a3;
*(_BYTE *)(*(_QWORD *)a4 + 531LL) = *(_DWORD *)(v4 + 120) == 1;
v9 = *(const void **)(v4 + 16);
if ( v6 > v8 )
{
memcpy(a1, v9, v8);
v16 = *(_QWORD *)(v4 + 8);
*(_QWORD *)(v4 + 16) += v8;
*(_QWORD *)(v4 + 8) = v16 - v8;
return v8;
}
else
{
memcpy(a1, v9, v6);
v10 = *(_QWORD *)(v4 + 112);
v11 = *(_QWORD *)(v4 + 8);
if ( v10 )
{
v12 = *(_QWORD *)a4 + 0x8000LL;
*(_QWORD *)(v4 + 16) = *(_QWORD *)(v4 + 104);
*(_QWORD *)(v4 + 8) = v10;
v13 = *(_QWORD *)(v4 + 88);
v14 = *(_DWORD *)(v4 + 120);
*(_QWORD *)(v12 + 3352) = *(_QWORD *)(v4 + 96);
*(_QWORD *)(v12 + 3344) = v13;
*(_QWORD *)(v4 + 112) = 0;
v5 = v11;
*(_DWORD *)(v4 + 120) = v14 + 1;
return v5;
}
*(_QWORD *)(v4 + 8) = 0;
return v11;
}
}