//
// sub_180094B80 from 0x180094b80 to 0x180094e24 (676 bytes)
//
// 4 xrefs:
// > cocos2d::cc_utf8_to_utf16 @ 0x180095311
// > ??> @ 0x18013e530
// > ??> @ 0x18013e540
// > ??> @ 0x1801b6774
//
// 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_180094B80(unsigned __int64 *a1, unsigned __int64 a2, _WORD **a3, unsigned __int64 a4, int a5)
{
unsigned __int8 *v5; // r10
unsigned int v6; // ebx
_WORD *v7; // r11
__int64 v9; // r15
__int64 v10; // rdi
int v11; // edx
unsigned __int16 v12; // ax
__int64 v13; // rbp
__int64 v14; // rsi
__int64 v15; // r14
unsigned __int8 *v16; // r8
char v17; // al
char v18; // al
unsigned __int8 v19; // r9
bool v20; // cf
int v21; // edx
int v22; // edx
int v23; // edx
int v24; // edx
int v25; // eax
unsigned int v26; // edx
_WORD *v27; // rcx
unsigned int v28; // edx
unsigned __int64 v32; // [rsp+58h] [rbp+20h]
v32 = a4;
v5 = (unsigned __int8 *)*a1;
v6 = 0;
v7 = *a3;
if ( *a1 < a2 )
{
v9 = a2 - (_QWORD)v5;
while ( 1 )
{
v10 = *v5;
v11 = 0;
v12 = byte_1801043C0[v10];
v13 = v12;
if ( v12 >= v9 )
{
v6 = 1;
goto LABEL_50;
}
v14 = v12;
v15 = (unsigned int)v12 + 1;
v16 = &v5[v15];
if ( byte_1801043C0[v10] )
break;
LABEL_23:
if ( (unsigned __int8)(v10 + 0x80) <= 0x41u || (unsigned __int8)v10 > 0xF4u )
goto LABEL_46;
switch ( v14 )
{
case 0LL:
goto LABEL_31;
case 1LL:
goto LABEL_30;
case 2LL:
goto LABEL_29;
case 3LL:
goto LABEL_28;
case 4LL:
goto LABEL_27;
case 5LL:
++v5;
--v9;
v11 = (_DWORD)v10 << 6;
LABEL_27:
--v9;
v21 = *v5++ + v11;
v11 = v21 << 6;
LABEL_28:
--v9;
v22 = *v5++ + v11;
v11 = v22 << 6;
LABEL_29:
--v9;
v23 = *v5++ + v11;
v11 = v23 << 6;
LABEL_30:
--v9;
v24 = *v5++ + v11;
v11 = v24 << 6;
LABEL_31:
v25 = *v5++;
v11 += v25;
--v9;
break;
default:
break;
}
v26 = v11 - dword_1801044C0[v13];
if ( (unsigned __int64)v7 >= a4 )
{
LABEL_48:
v5 -= v15;
v6 = 2;
goto LABEL_50;
}
if ( v26 > 0xFFFF )
{
if ( v26 <= 0x10FFFF )
{
v27 = v7 + 1;
if ( (unsigned __int64)(v7 + 1) >= a4 )
goto LABEL_48;
v28 = v26 - 0x10000;
*v7++ = (v28 >> 10) - 10240;
*v27 = (v28 & 0x3FF) - 9216;
}
else
{
if ( !a5 )
{
v6 = 3;
v5 -= v15;
goto LABEL_50;
}
*v7 = -3;
}
}
else
{
if ( v26 - 55296 <= 0x7FF )
{
if ( !a5 )
{
v5 -= v15;
LABEL_46:
v6 = 3;
goto LABEL_50;
}
LOWORD(v26) = -3;
}
*v7 = v26;
}
++v7;
if ( (unsigned __int64)v5 >= a2 )
goto LABEL_50;
}
if ( v12 != 1 )
{
if ( v12 != 2 )
{
if ( v12 != 3 )
goto LABEL_46;
v17 = *--v16;
if ( (unsigned __int8)(v17 + 0x80) > 0x3Fu )
goto LABEL_46;
}
v18 = *--v16;
if ( (unsigned __int8)(v18 + 0x80) > 0x3Fu )
goto LABEL_46;
}
v19 = *(v16 - 1);
if ( (unsigned __int8)(v19 + 0x80) > 0x3Fu )
goto LABEL_46;
switch ( (_DWORD)v10 )
{
case 0xE0:
v20 = v19 < 0xA0u;
break;
case 0xED:
if ( v19 > 0x9Fu )
goto LABEL_46;
LABEL_22:
a4 = v32;
goto LABEL_23;
case 0xF0:
v20 = v19 < 0x90u;
break;
default:
if ( (_DWORD)v10 == 244 && v19 > 0x8Fu )
goto LABEL_46;
goto LABEL_22;
}
if ( v20 )
goto LABEL_46;
goto LABEL_22;
}
LABEL_50:
*a1 = (unsigned __int64)v5;
*a3 = v7;
return v6;
}