//
// sub_9933B0 from 0x9933b0 to 0x99349a (234 bytes)
//
// 4 xrefs:
// > std::__ndk1::codecvt::do_in @ 0x9708d8
// > std::__ndk1::codecvt::do_in @ 0x97095c
// > sub_993394 @ 0x9933a8
// > sub_9934AC @ 0x993546
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:06:37 +0000
//
int __fastcall sub_9933B0(int *a1, unsigned __int8 *a2, int a3, int *a4)
{
int *v4; // r12
int v5; // lr
int v6; // r5
unsigned int v7; // r4
char *v8; // r3
int v9; // r1
char v10; // t1
int result; // r0
int v12; // r3
unsigned int v13; // r3
int *v14; // [sp+4h] [bp-14h] BYREF
v4 = (int *)&unk_D33F0C;
v14 = a1;
if ( a4 )
v4 = a4;
v5 = *v4;
if ( !a2 )
{
if ( !v5 )
return 0;
goto LABEL_22;
}
if ( !a1 )
{
a1 = (int *)&v14;
v14 = (int *)&v14;
}
if ( !a3 )
return -2;
if ( v5 )
{
v6 = a3;
goto LABEL_9;
}
v12 = *a2;
if ( (v12 & 0x80u) == 0 )
{
*a1 = v12;
result = (unsigned __int8)v12;
if ( (_BYTE)v12 )
return 1;
return result;
}
v13 = v12 - 194;
if ( v13 > 0x32 )
{
LABEL_22:
*v4 = 0;
*(_DWORD *)_errno() = 84;
return -1;
}
v6 = a3 - 1;
v5 = dword_C5130C[v13];
if ( a3 == 1 )
{
LABEL_26:
*v4 = v5;
return -2;
}
++a2;
LABEL_9:
v7 = *a2;
if ( (((v7 >> 3) + (v5 >> 26)) | ((v7 >> 3) - 16)) > 7 )
goto LABEL_22;
v8 = (char *)(a2 + 1);
v9 = v6 - 1;
while ( 1 )
{
v5 = ((unsigned __int8)v7 - 128) | (v5 << 6);
if ( v5 >= 0 )
break;
if ( !v9 )
goto LABEL_26;
v10 = *v8++;
LOBYTE(v7) = v10;
--v9;
if ( (v10 & 0xC0) != 0x80 )
goto LABEL_22;
}
*a1 = v5;
*v4 = 0;
return a3 - v9;
}