//
// sub_B5804 from 0xb5804 to 0xb5894 (144 bytes)
//
// 3 xrefs:
// > sub_B5764 @ 0xb5794
// > sub_B57D4 @ 0xb57f0
// > sub_B5954 @ 0xb5984
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:14:38 +0000
//
__int64 __fastcall sub_B5804(__int64 a1, unsigned int a2)
{
__int64 result; // x0
__int64 v5; // x8
void *v6; // x8
void *dest; // [xsp+8h] [xbp-18h] BYREF
if ( *(_DWORD *)(a1 + 8) > (signed int)a2 )
return 28;
dest = nullptr;
if ( a2 )
{
result = sub_B5894(a2, &dest);
if ( (_DWORD)result )
return result;
v5 = *(int *)(a1 + 8);
if ( (_DWORD)v5 )
memcpy(dest, *(const void **)a1, 4 * v5);
}
if ( *(int *)(a1 + 12) >= 1 )
sub_65158(*(_QWORD *)a1);
v6 = dest;
*(_DWORD *)(a1 + 12) = a2;
*(_QWORD *)a1 = v6;
return 0;
}