//
// ERR_error_string_n from 0xa0eb6c to 0xa0ed64 (504 bytes)
//
// 8 xrefs:
// > sub_851C7C @ 0x851d0e
// > sub_851FF8 @ 0x85210e
// > sub_854A2C @ 0x854a78
// > sub_854B9C @ 0x854c94
// > sub_855114 @ 0x8551b8
// > ERR_error_string @ 0xa0ed88
// > ERR_print_errors_cb @ 0xac99c0
// > ??> @ 0x67a4c
//
// 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:45 +0000
//
unsigned int __fastcall ERR_error_string_n(unsigned int result, char *a2, unsigned int a3)
{
unsigned int v3; // r6
const char *v6; // r9
const char *v7; // r8
const char *v8; // r7
char *v9; // r0
unsigned int v10; // r3
char *v11; // r3
char *v12; // r0
char *v13; // r0
char *v14; // r1
_BYTE v15[64]; // [sp+10h] [bp-E0h] BYREF
_BYTE v16[64]; // [sp+50h] [bp-A0h] BYREF
_BYTE v17[96]; // [sp+90h] [bp-60h] BYREF
if ( a3 )
{
v3 = result;
v6 = (const char *)ERR_lib_error_string(result);
v7 = (const char *)ERR_func_error_string(v3);
v8 = (const char *)ERR_reason_error_string(v3);
if ( !v6 )
BIO_snprintf(v15, 0x40u, "lib(%lu)", HIBYTE(v3));
if ( !v7 )
BIO_snprintf(v16, 0x40u, "func(%lu)", v3 << 8 >> 20);
if ( !v8 )
BIO_snprintf(v17, 0x40u, "reason(%lu)", v3 & 0xFFF);
if ( !v6 )
v6 = v15;
if ( !v7 )
v7 = v16;
if ( !v8 )
v8 = v17;
BIO_snprintf(a2, a3, "error:%08lX:%s:%s:%s", v3, v6, v7, v8);
result = strlen(a2) == a3 - 1;
if ( a3 <= 4 )
result = 0;
if ( result )
{
v9 = strchr(a2, 58);
v10 = a3 - 5;
if ( v9 )
{
v11 = &a2[v10];
if ( v11 >= v9 )
goto LABEL_21;
v9 = v11;
}
else
{
v9 = &a2[v10];
}
*v9 = 58;
LABEL_21:
v12 = strchr(v9 + 1, 58);
if ( v12 )
{
if ( v12 <= &a2[a3 - 4] )
goto LABEL_25;
v12 = &a2[a3 - 4];
}
else
{
v12 = &a2[a3 - 4];
}
*v12 = 58;
LABEL_25:
v13 = strchr(v12 + 1, 58);
if ( v13 )
{
if ( v13 <= &a2[a3 - 3] )
{
LABEL_29:
result = (unsigned int)strchr(v13 + 1, 58);
v14 = &a2[a3 - 2];
if ( !result || result > (unsigned int)v14 )
*v14 = 58;
return result;
}
v13 = &a2[a3 - 3];
}
else
{
v13 = &a2[a3 - 3];
}
*v13 = 58;
goto LABEL_29;
}
}
return result;
}