//
// sub_CB5DC0 from 0xcb5dc0 to 0xcb5e50 (144 bytes)
//
// 3 xrefs:
// > sub_C6B594 @ 0xc6b8cc
// > sub_C6B594 @ 0xc6bba0
// > sub_C6B594 @ 0xc6bbc4
//
// 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_CB5DC0(__int64 result, unsigned __int64 *a2, unsigned __int64 a3)
{
unsigned __int64 *v3; // x3
unsigned __int64 *v4; // x2
unsigned __int64 v5; // t1
v3 = (unsigned __int64 *)((char *)a2 + a3);
*(_DWORD *)(result + 8) = 254;
*(_QWORD *)result = 0;
*(_DWORD *)(result + 12) = -8;
*(_DWORD *)(result + 40) = 0;
*(_QWORD *)(result + 16) = a2;
*(_QWORD *)(result + 24) = (char *)a2 + a3;
if ( a3 <= 7 )
{
*(_QWORD *)(result + 32) = a2;
}
else
{
v4 = (unsigned __int64 *)((char *)a2 + a3 - 7);
*(_QWORD *)(result + 32) = v4;
if ( a2 < v4 )
{
v5 = *a2;
*(_QWORD *)(result + 16) = (char *)a2 + 7;
*(_DWORD *)(result + 12) = 48;
*(_QWORD *)result = bswap64(v5) >> 8;
return result;
}
}
*(_DWORD *)(result + 12) = 0;
if ( a2 < v3 )
{
*(_QWORD *)(result + 16) = (char *)a2 + 1;
*(_QWORD *)result = *(unsigned __int8 *)a2;
}
else
{
*(_DWORD *)(result + 40) = 1;
}
return result;
}