//
// sub_CFBDF8 from 0xcfbdf8 to 0xcfc0d8 (736 bytes)
//
// 2 xrefs:
// > ??> @ 0x111ea40
// > ??> @ 0x111ea80
//
// 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_CFBDF8(int a1, const wchar_t *a2, const wchar_t *a3, const wchar_t *a4, const wchar_t *a5)
{
signed __int64 v8; // x19
size_t v9; // x24
__int64 v10; // x0
__int64 v11; // x20
wchar_t *v12; // x23
signed __int64 v13; // x19
size_t v14; // x25
__int64 v15; // x0
__int64 v16; // x20
wchar_t *v17; // x24
__int64 v18; // x21
wchar_t *v19; // x20
wchar_t *v20; // x19
wchar_t *v21; // x21
wchar_t *v22; // x25
unsigned int v23; // w0
wchar_t *v24; // x19
wchar_t *v25; // x20
unsigned int v26; // w21
wchar_t *v27; // x0
wchar_t *v28; // x0
unsigned int *v30; // x24
int v31; // w1
unsigned int *v32; // x23
int v33; // w1
const wchar_t *v34; // [xsp+58h] [xbp+58h]
if ( a2 == a3 )
{
v12 = (wchar_t *)&unk_124B6E8;
}
else
{
if ( !a2 && a3 )
sub_D138D8("basic_string::_S_construct null not valid");
v8 = (char *)a3 - (char *)a2;
v9 = a3 - a2;
v34 = a5;
v10 = sub_D1B424(v9, 0);
v11 = v10;
v12 = (wchar_t *)(v10 + 24);
a5 = v34;
if ( v9 == 1 )
{
*(_DWORD *)(v10 + 24) = *a2;
}
else
{
wmemcpy((wchar_t *)(v10 + 24), a2, v9);
a5 = v34;
}
if ( (__int64 *)v11 != &qword_124B6D0 )
{
*(_DWORD *)(v11 + 16) = 0;
*(_QWORD *)v11 = v9;
*(_DWORD *)(v11 + v8 + 24) = 0;
}
}
if ( a4 == a5 )
{
v17 = (wchar_t *)&unk_124B6E8;
v18 = qword_124B6D0;
}
else
{
if ( !a4 && a5 )
sub_D138D8("basic_string::_S_construct null not valid");
v13 = (char *)a5 - (char *)a4;
v14 = a5 - a4;
v15 = sub_D1B424(v14, 0);
v16 = v15;
v17 = (wchar_t *)(v15 + 24);
if ( v14 == 1 )
*(_DWORD *)(v15 + 24) = *a4;
else
wmemcpy((wchar_t *)(v15 + 24), a4, v14);
if ( (__int64 *)v16 == &qword_124B6D0 )
{
v18 = *(_QWORD *)v16;
}
else
{
*(_DWORD *)(v16 + 16) = 0;
*(_QWORD *)v16 = v14;
v18 = v14;
*(_DWORD *)(v16 + v13 + 24) = 0;
}
}
v19 = v17;
v20 = v12;
v21 = &v17[v18];
v22 = &v12[*((_QWORD *)v12 - 3)];
v23 = sub_D1FFAC(a1, v12, v17);
if ( v23 )
{
LABEL_26:
v26 = v23;
v27 = v17 - 6;
if ( v17 - 6 == (wchar_t *)&qword_124B6D0 )
goto LABEL_22;
goto LABEL_27;
}
while ( 1 )
{
v24 = &v20[wcslen(v20)];
v25 = &v19[wcslen(v19)];
if ( v25 == v21 )
{
v26 = v24 != v22;
goto LABEL_21;
}
if ( v24 == v22 )
break;
v20 = v24 + 1;
v19 = v25 + 1;
v23 = sub_D1FFAC(a1, v20, v19);
if ( v23 )
goto LABEL_26;
}
v26 = -1;
LABEL_21:
v27 = v17 - 6;
if ( v17 - 6 != (wchar_t *)&qword_124B6D0 )
{
LABEL_27:
if ( &pthread_create )
{
v30 = (unsigned int *)(v17 - 2);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(v17 - 2);
*(v17 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v27);
}
LABEL_22:
v28 = v12 - 6;
if ( v12 - 6 != (wchar_t *)&qword_124B6D0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v12 - 2);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *(v12 - 2);
*(v12 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v28);
}
return v26;
}