//
// OPENSSL_uni2utf8 from 0xa3aea4 to 0xa3b0c4 (544 bytes)
//
// 2 xrefs:
// > PKCS12_get_friendlyname @ 0xad070c
// > ??> @ 0x7f40c
//
// 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:08:10 +0000
//
_BYTE *__fastcall OPENSSL_uni2utf8(int a1, int a2)
{
int v2; // r4
char *v5; // r9
unsigned int v6; // r2
int v7; // r2
unsigned int v8; // r3
int v9; // r1
int v10; // r0
_BYTE *v11; // r10
int v12; // r4
int v13; // r9
unsigned int v14; // r2
unsigned int v15; // r3
int v16; // r1
int v17; // r0
int v18; // r5
v2 = a2 & 1;
if ( (a2 & 1) != 0 )
return nullptr;
if ( a2 > 0 )
{
v5 = (char *)(a2 & 1);
while ( 1 )
{
v9 = a2 - v2;
if ( a2 == v2 )
goto LABEL_17;
if ( v9 <= 1 )
return OPENSSL_uni2asc(a1, a2);
v6 = *(unsigned __int8 *)(a1 + v2 + 1) | (*(unsigned __int8 *)(a1 + v2) << 8);
if ( v6 - 55296 <= 0x7FF )
{
if ( v9 <= 3 )
return OPENSSL_uni2asc(a1, a2);
v7 = (v6 - 55296) << 10;
v8 = (*(unsigned __int8 *)(a1 + v2 + 3) | (*(unsigned __int8 *)(a1 + v2 + 2) << 8)) - 56320;
if ( v8 > 0x3FF )
return OPENSSL_uni2asc(a1, a2);
v6 = (v7 | v8) + 0x10000;
}
if ( v9 >= 4 )
v9 = 4;
v10 = UTF8_putc(nullptr, v9, v6);
v9 = v10;
if ( v10 < 0 )
return OPENSSL_uni2asc(a1, a2);
if ( v10 != 4 )
{
LABEL_17:
v2 += 2;
v5 += v9;
if ( v2 >= a2 )
goto LABEL_18;
}
else
{
v2 += 4;
v5 += 4;
if ( v2 >= a2 )
goto LABEL_18;
}
}
}
v5 = (char *)(a2 & 1);
if ( !a2 )
goto LABEL_19;
LABEL_18:
if ( *(_BYTE *)(a1 + a2 - 2) || *(_BYTE *)(a1 + a2 - 1) )
LABEL_19:
++v5;
v11 = CRYPTO_malloc(v5, (int)"crypto/pkcs12/p12_utl.c", 197);
if ( !v11 )
return nullptr;
if ( a2 > 0 )
{
v12 = 0;
v13 = 0;
while ( 1 )
{
v17 = a2 - v12;
if ( a2 == v12 )
goto LABEL_34;
if ( v17 <= 1 )
goto LABEL_40;
v14 = *(unsigned __int8 *)(a1 + v12 + 1) | (*(unsigned __int8 *)(a1 + v12) << 8);
if ( v14 - 55296 <= 0x7FF )
{
if ( v17 <= 3
|| (v15 = (*(unsigned __int8 *)(a1 + v12 + 3) | (*(unsigned __int8 *)(a1 + v12 + 2) << 8)) - 56320, v15 > 0x3FF) )
{
LABEL_40:
v17 = -1;
v12 += 2;
goto LABEL_35;
}
v14 = (((v14 - 55296) << 10) | v15) + 0x10000;
}
v16 = v17 >= 4 ? 4 : a2 - v12;
v17 = UTF8_putc(&v11[v13], v16, v14);
if ( v17 != 4 )
{
LABEL_34:
v12 += 2;
LABEL_35:
v13 += v17;
if ( v12 >= a2 )
goto LABEL_36;
}
else
{
v12 += 4;
v13 += 4;
if ( v12 >= a2 )
goto LABEL_36;
}
}
}
v13 = 0;
if ( a2 )
{
LABEL_36:
v18 = a1 + a2;
if ( !*(_BYTE *)(v18 - 2) && !*(_BYTE *)(v18 - 1) )
return v11;
}
v11[v13] = 0;
return v11;
}