//
// sub_D1D3A4 from 0xd1d3a4 to 0xd1d4a0 (252 bytes)
//
// 0 xrefs:
//
// 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_D1D3A4(const wchar_t **a1, __int64 *a2, unsigned __int64 a3, size_t a4)
{
__int64 v4; // x5
unsigned __int64 v5; // x4
size_t v9; // x4
size_t v10; // x19
const wchar_t *v11; // x2
__int64 v12; // x3
size_t v13; // x23
v4 = *a2;
v5 = *(_QWORD *)(*a2 - 24);
if ( a3 > v5 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::append", a3, v5);
v9 = v5 - a3;
if ( v9 > a4 )
v10 = a4;
else
v10 = v9;
if ( v10 )
{
v11 = *a1;
v12 = *((_QWORD *)*a1 - 3);
v13 = v10 + v12;
if ( v10 + v12 > *((_QWORD *)*a1 - 2) || *(v11 - 2) > 0 )
{
sub_D1D184(a1, v10 + v12);
v11 = *a1;
v4 = *a2;
v12 = *((_QWORD *)*a1 - 3);
}
if ( v10 == 1 )
{
v11[v12] = *(_DWORD *)(v4 + 4 * a3);
}
else
{
wmemcpy((wchar_t *)&v11[v12], (const wchar_t *)(v4 + 4 * a3), v10);
v11 = *a1;
}
if ( v11 - 6 != (const wchar_t *)&qword_124B6D0 )
{
*((_DWORD *)v11 - 2) = 0;
*((_QWORD *)v11 - 3) = v13;
v11[v13] = 0;
}
}
return a1;
}