//
// UTF8_putc from 0x7c1dac to 0x7c201c (624 bytes)
//
// 13 xrefs:
// > sub_7BE300 @ 0x7be550
// > sub_7BE300 @ 0x7beca8
// > sub_7BF37C @ 0x7bf5d8
// > sub_7BF37C @ 0x7bfd38
// > OPENSSL_uni2utf8 @ 0x82632c
// > OPENSSL_uni2utf8 @ 0x826414
// > sub_862EAC @ 0x862ec0
// > sub_862ED8 @ 0x862eec
// > ASN1_mbstring_ncopy @ 0x863548
// > ASN1_mbstring_ncopy @ 0x863768
// > ASN1_mbstring_ncopy @ 0x8637cc
// > ASN1_mbstring_ncopy @ 0x86381c
// > ??> @ 0x5e29c
//
// 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
//
int __fastcall UTF8_putc(_BYTE *a1, int a2, unsigned int a3)
{
if ( a1 )
{
if ( a2 <= 0 )
return -1;
if ( a3 <= 0x7F )
{
*a1 = a3;
return 1;
}
if ( a3 < 0x800 )
{
if ( a2 != 1 )
{
*a1 = ~(~(a3 >> 6 << 26) >> 26);
a1[1] = ~(~((a3 & 0x3F) << 25) >> 25);
return 2;
}
return -1;
}
if ( a3 < 0x10000 )
{
if ( a2 > 2 )
{
a1[1] = ~(~(((a3 >> 6) & 0x3F) << 25) >> 25);
*a1 = ~(~(a3 >> 12 << 27) >> 27);
a1[2] = ~(~((a3 & 0x3F) << 25) >> 25);
return 3;
}
return -1;
}
}
else
{
if ( a3 <= 0x7F )
return 1;
if ( a3 < 0x800 )
return 2;
a2 = 6;
if ( a3 < 0x10000 )
return 3;
}
if ( a3 < 0x200000 )
{
if ( a2 > 3 )
{
if ( a1 )
{
a1[1] = ~(~(((a3 >> 12) & 0x3F) << 25) >> 25);
a1[2] = ~(~(((a3 >> 6) & 0x3F) << 25) >> 25);
*a1 = ~(~(a3 >> 18 << 28) >> 28);
a1[3] = ~(~((a3 & 0x3F) << 25) >> 25);
}
return 4;
}
return -1;
}
if ( a3 > 0x3FFFFFF )
{
if ( a2 <= 5 )
return -1;
if ( a1 )
{
*a1 = ~((unsigned int)~(((a3 & 0x40000000) != 0) << 30) >> 30);
a1[1] = ~(~((HIBYTE(a3) & 0x3Fu) << 25) >> 25);
a1[2] = ~(~(((a3 >> 18) & 0x3F) << 25) >> 25);
a1[3] = ~(~(((a3 >> 12) & 0x3F) << 25) >> 25);
a1[4] = ~(~(((a3 >> 6) & 0x3F) << 25) >> 25);
a1[5] = ~(~((a3 & 0x3F) << 25) >> 25);
}
return 6;
}
else
{
if ( a2 <= 4 )
return -1;
if ( a1 )
{
a1[1] = ~(~(((a3 >> 18) & 0x3F) << 25) >> 25);
a1[2] = ~(~(((a3 >> 12) & 0x3F) << 25) >> 25);
a1[3] = ~(~(((a3 >> 6) & 0x3F) << 25) >> 25);
*a1 = ~((unsigned int)~(HIBYTE(a3) << 29) >> 29);
a1[4] = ~(~((a3 & 0x3F) << 25) >> 25);
}
return 5;
}
}