//
// std::__ndk1::codecvt::do_length from 0xf72004 to 0xf721fc (504 bytes)
//
// 5 xrefs:
// > ??> @ 0x49df8
// > ??> @ 0x1534108
// > ??> @ 0x1534758
// > ??> @ 0x1534878
// > ??> @ 0x1534978
//
// 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:13:39 +0000
//
unsigned __int8 *__fastcall std::codecvt::do_length(
__int64 a1,
__int64 a2,
char *a3,
unsigned __int64 a4,
unsigned __int64 a5)
{
char *v5; // x8
unsigned __int64 v6; // x9
unsigned int v7; // w14
unsigned int v8; // w10
unsigned __int8 v9; // w11
unsigned __int8 v10; // w12
unsigned __int8 v11; // w11
unsigned __int8 v12; // w13
unsigned __int8 v13; // w12
unsigned __int8 v14; // w11
int v15; // w13
int v16; // w14
v5 = a3;
if ( a5 && (unsigned __int64)a3 < a4 )
{
v6 = 1;
while ( 1 )
{
v7 = (unsigned __int8)*v5;
if ( (*v5 & 0x80000000) == 0 )
{
++v5;
goto LABEL_37;
}
v8 = (unsigned __int8)*v5;
if ( v8 < 0xC2 )
return (unsigned __int8 *)(v5 - a3);
if ( v7 <= 0xDF )
{
if ( (__int64)(a4 - (_QWORD)v5) < 2 )
return (unsigned __int8 *)(v5 - a3);
v9 = v5[1];
if ( (v9 & 0xC0) != 0x80 || (v9 & 0x3F | ((unsigned __int8)(v8 & 0x1F) << 6)) > 0x10FFFFuLL )
return (unsigned __int8 *)(v5 - a3);
v5 += 2;
goto LABEL_37;
}
if ( v8 <= 0xEF )
{
if ( (__int64)(a4 - (_QWORD)v5) < 3 )
return (unsigned __int8 *)(v5 - a3);
v10 = v5[1];
v11 = v5[2];
if ( v8 == 237 )
{
v15 = v10 & 0xE0;
}
else
{
if ( v8 == 224 )
{
if ( (v10 & 0xE0) != 0xA0 )
return (unsigned __int8 *)(v5 - a3);
LABEL_27:
if ( (v11 & 0xC0) != 0x80 || (((v8 & 0xF) << 12) | ((v10 & 0x3F) << 6) | v11 & 0x3F) > 0x10FFFFuLL )
return (unsigned __int8 *)(v5 - a3);
v5 += 3;
goto LABEL_37;
}
v15 = v10 & 0xC0;
}
if ( v15 != 128 )
return (unsigned __int8 *)(v5 - a3);
goto LABEL_27;
}
if ( v7 > 0xF4 || (__int64)(a4 - (_QWORD)v5) < 4 )
return (unsigned __int8 *)(v5 - a3);
v12 = v5[1];
v13 = v5[2];
v14 = v5[3];
if ( v7 == 244 )
break;
if ( v7 != 240 )
{
v16 = v12 & 0xC0;
LABEL_32:
if ( v16 != 128 )
return (unsigned __int8 *)(v5 - a3);
goto LABEL_33;
}
if ( (unsigned __int8)(v12 + 112) >= 0x30u )
return (unsigned __int8 *)(v5 - a3);
LABEL_33:
if ( (v13 & 0xC0) != 0x80
|| (v14 & 0xC0) != 0x80
|| (((v8 & 7) << 18) | ((v12 & 0x3F) << 12) | ((v13 & 0x3F) << 6) | v14 & 0x3F) > 0x10FFFFuLL )
{
return (unsigned __int8 *)(v5 - a3);
}
v5 += 4;
LABEL_37:
if ( v6 < a5 )
{
++v6;
if ( (unsigned __int64)v5 < a4 )
continue;
}
return (unsigned __int8 *)(v5 - a3);
}
v16 = v12 & 0xF0;
goto LABEL_32;
}
return (unsigned __int8 *)(v5 - a3);
}