//
// sub_7783F8 from 0x7783f8 to 0x778466 (110 bytes)
//
// 6 xrefs:
// > sub_765C04 @ 0x765e12
// > sub_7660F4 @ 0x766302
// > sub_77846C @ 0x77846c
// > sub_778B20 @ 0x778b56
// > sub_778B7C @ 0x778ba6
// > sub_778BCC @ 0x778bf0
//
// 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
//
const wchar_t **__fastcall sub_7783F8(const wchar_t **a1, const wchar_t **a2)
{
const wchar_t *v3; // r1
size_t v5; // r5
const wchar_t *v6; // r3
int v7; // r2
size_t v8; // r7
v3 = *a2;
v5 = *(v3 - 3);
if ( v5 )
{
v6 = *a1;
v7 = *(*a1 - 3);
v8 = v7 + v5;
if ( v7 + v5 > *(*a1 - 2) || *(v6 - 1) > 0 )
{
sub_778308(a1, v7 + v5);
v6 = *a1;
v3 = *a2;
v7 = *(*a1 - 3);
}
if ( v5 == 1 )
{
v6[v7] = *v3;
}
else
{
wmemcpy((wchar_t *)&v6[v7], v3, v5);
v6 = *a1;
}
if ( v6 - 3 != (const wchar_t *)&unk_ACDDAC )
{
*((_DWORD *)v6 - 3) = v8;
*((_DWORD *)v6 - 1) = 0;
v6[v8] = 0;
}
}
return a1;
}