//
// sub_9D2CF8 from 0x9d2cf8 to 0x9d2ee8 (496 bytes)
//
// 2 xrefs:
// > sub_9D2F00 @ 0x9d3448
// > sub_9D2F00 @ 0x9d39c0
//
// 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:07:12 +0000
//
int __fastcall sub_9D2CF8(unsigned int a1, __int16 a2, _BYTE *a3, int a4)
{
int v5; // r3
int v7; // r3
int v8; // r3
int v9; // r3
int v10; // r3
char v11; // [sp+3h] [bp-11h] BYREF
_BYTE v12[16]; // [sp+4h] [bp-10h] BYREF
if ( a1 >= 0x10000 )
{
BIO_snprintf(v12, 11, "\\W%08lX", a1);
if ( !a4 || BIO_write(a4, v12, 10, v7) == 10 )
return 10;
return -1;
}
if ( a1 > 0xFF )
{
BIO_snprintf(v12, 11, "\\U%04lX", a1);
if ( !a4 || BIO_write(a4, v12, 6, v8) == 6 )
return 6;
return -1;
}
v11 = a1;
if ( (a1 & 0x80) != 0 )
{
v5 = a2 & 4;
}
else
{
v5 = (unsigned __int16)(word_C51C4C[a1] & a2);
if ( (word_C51C4C[a1] & (unsigned __int8)a2 & 0x61) != 0 )
{
if ( (word_C51C4C[a1] & (unsigned __int8)a2 & 8) == 0 )
{
if ( !a4 || BIO_write(a4, &word_BFB9D4, 1, v5) == 1 && BIO_write(a4, &v11, 1, v10) == 1 )
return 2;
return -1;
}
if ( a3 )
{
v5 = 1;
*a3 = 1;
}
goto LABEL_9;
}
}
if ( (v5 & 6) == 0 )
{
if ( a1 == 92 && (a2 & 0xF) != 0 )
{
if ( !a4 || BIO_write(a4, &word_BFB9D0, 2, v5) == 2 )
return 2;
return -1;
}
LABEL_9:
if ( !a4 || BIO_write(a4, &v11, 1, v5) == 1 )
return 1;
return -1;
}
BIO_snprintf(v12, 11, "\\%02X", a1);
if ( a4 && BIO_write(a4, v12, 3, v9) != 3 )
return -1;
return 3;
}