//
// sub_CF94EC from 0xcf94ec to 0xcf95b4 (200 bytes)
//
// 3 xrefs:
// > sub_D0C3A0 @ 0xd0c494
// > ??> @ 0x111ea10
// > ??> @ 0x121dac0
//
// 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_CF94EC(_QWORD *a1, wchar_t *s2, __int64 a3)
{
__int64 i; // x20
wchar_t *v7; // x4
__int64 v8; // x3
__int64 v9; // x19
size_t v10; // x2
__int64 v11; // x19
for ( i = 0; a3 > i; ++i )
{
v7 = (wchar_t *)a1[5];
v8 = (__int64)(a1[6] - (_QWORD)v7) >> 2;
if ( a3 - i > v8 )
v9 = (__int64)(a1[6] - (_QWORD)v7) >> 2;
else
v9 = a3 - i;
if ( v8 )
{
v10 = v9;
i += v9;
v11 = 4 * v9;
wmemcpy(v7, s2, v10);
a1[5] += v11;
if ( a3 <= i )
return i;
s2 = (wchar_t *)((char *)s2 + v11);
}
if ( (*(unsigned int (__fastcall **)(_QWORD *, _QWORD))(*a1 + 104LL))(a1, (unsigned int)*s2++) == -1 )
break;
}
return i;
}