//
// sub_778648 from 0x778648 to 0x7786c4 (124 bytes)
//
// 3 xrefs:
// > sub_7786CC @ 0x7786d2
// > sub_7786DC @ 0x778700
// > sub_778B7C @ 0x778b9e
//
// 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
//
int __fastcall sub_778648(const wchar_t **a1, size_t a2, wchar_t a3)
{
const wchar_t *v4; // r3
int v6; // r1
size_t v8; // r6
int result; // r0
v4 = *a1;
v6 = *(*a1 - 3);
if ( 268435454 - v6 < a2 )
sub_7731C4("basic_string::append");
v8 = a2 + v6;
if ( a2 + v6 > *(v4 - 2) || *(v4 - 1) > 0 )
{
sub_778308(a1, a2 + v6);
v4 = *a1;
v6 = *(*a1 - 3);
}
if ( a2 == 1 )
{
v4[v6] = a3;
}
else
{
wmemset((wchar_t *)&v4[v6], a3, a2);
v4 = *a1;
}
result = 0;
if ( v4 - 3 != (const wchar_t *)&unk_ACDDAC )
{
*((_DWORD *)v4 - 3) = v8;
*((_DWORD *)v4 - 1) = 0;
v4[v8] = 0;
}
return result;
}