//
// ERR_error_string_n from 0x7f9f6c to 0x7fa164 (504 bytes)
//
// 8 xrefs:
// > sub_641BFC @ 0x641c8e
// > sub_641F78 @ 0x64208e
// > sub_6449AC @ 0x6449f8
// > sub_644B1C @ 0x644c14
// > sub_645094 @ 0x645138
// > ERR_error_string @ 0x7fa188
// > ERR_print_errors_cb @ 0x8b49c0
// > ??> @ 0x54b1c
//
// 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
//
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;
}