//
// sub_D55314 from 0xd55314 to 0xd554b4 (416 bytes)
//
// 2 xrefs:
// > cocos2d::CCLabelBMFont::setString @ 0xd56a94
// > cocos2d::CCLabelBMFont::setString @ 0xd56b3c
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:07:43 +0000
//
unsigned __int64 __fastcall sub_D55314(cocos2d *a1, const unsigned __int16 *a2)
{
int v3; // w19
unsigned __int64 v4; // x0
__int64 v5; // x21
unsigned __int64 v6; // x0
unsigned __int64 result; // x0
cocos2d *v8; // x5
_OWORD *v9; // x4
unsigned int v10; // w2
unsigned int v11; // w3
int v12; // w1
__int128 v13; // t1
__int64 v14; // x2
__int64 v15; // x1
if ( a1 )
{
v3 = cocos2d::cc_wcslen(a1, a2);
v4 = v3 + 1;
if ( v4 <= 0x3F80000000000000LL )
{
v6 = 2 * v4;
v5 = v6 - 2;
}
else
{
v5 = 2LL * v3;
v6 = -1;
}
}
else
{
v5 = 0;
v6 = 2;
v3 = 0;
}
result = operator new[](v6);
if ( v3 <= 0 )
{
LABEL_17:
*(_WORD *)(result + v5) = 0;
return result;
}
if ( ((unsigned __int64)a1 >= result + 16 || result >= (unsigned __int64)a1 + 16) && (unsigned int)v3 > 9 )
{
v8 = a1;
v9 = (_OWORD *)result;
v10 = ((unsigned int)(v3 - 8) >> 3) + 1;
v11 = 0;
v12 = 8 * v10;
do
{
v13 = *(_OWORD *)v8;
v8 = (cocos2d *)((char *)v8 + 16);
++v11;
*v9++ = v13;
}
while ( v11 < v10 );
if ( v3 != v12 )
{
*(_WORD *)(result + 2LL * v12) = *((_WORD *)a1 + v12);
v14 = 2LL * v12;
if ( v12 + 1 < v3 )
{
*(_WORD *)(result + v14 + 2) = *(_WORD *)((char *)a1 + v14 + 2);
if ( v3 > v12 + 2 )
{
*(_WORD *)(result + v14 + 4) = *(_WORD *)((char *)a1 + v14 + 4);
if ( v3 > v12 + 3 )
{
*(_WORD *)(result + v14 + 6) = *(_WORD *)((char *)a1 + v14 + 6);
if ( v3 > v12 + 4 )
{
*(_WORD *)(result + v14 + 8) = *(_WORD *)((char *)a1 + v14 + 8);
if ( v3 > v12 + 5 )
{
*(_WORD *)(result + v14 + 10) = *(_WORD *)((char *)a1 + v14 + 10);
if ( v3 > v12 + 6 )
*(_WORD *)(result + v14 + 12) = *(_WORD *)((char *)a1 + v14 + 12);
}
}
}
}
}
}
goto LABEL_17;
}
v15 = 0;
do
{
*(_WORD *)(result + 2 * v15) = *((_WORD *)a1 + v15);
++v15;
}
while ( v3 > (int)v15 );
*(_WORD *)(result + v5) = 0;
return result;
}