//
// sub_CF9420 from 0xcf9420 to 0xcf94ec (204 bytes)
//
// 3 xrefs:
// > sub_D0CE04 @ 0xd0cf88
// > ??> @ 0x111e9f0
// > ??> @ 0x121daa0
//
// 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_CF9420(_QWORD *a1, wchar_t *s1, __int64 a3)
{
__int64 i; // x20
const wchar_t *v7; // x4
__int64 v8; // x3
__int64 v9; // x19
wchar_t v10; // w0
size_t v11; // x2
__int64 v12; // x19
for ( i = 0; a3 > i; ++s1 )
{
v7 = (const wchar_t *)a1[2];
v8 = (__int64)(a1[3] - (_QWORD)v7) >> 2;
if ( a3 - i > v8 )
v9 = (__int64)(a1[3] - (_QWORD)v7) >> 2;
else
v9 = a3 - i;
if ( v8 )
{
v11 = v9;
i += v9;
v12 = 4 * v9;
wmemcpy(s1, v7, v11);
a1[2] += v12;
if ( a3 <= i )
return i;
s1 = (wchar_t *)((char *)s1 + v12);
}
v10 = (*(__int64 (__fastcall **)(_QWORD *))(*a1 + 80LL))(a1);
if ( v10 == -1 )
break;
++i;
*s1 = v10;
}
return i;
}