//
// OBJ_obj2txt from 0xdc2528 to 0xdc2890 (872 bytes)
//
// 9 xrefs:
// > i2t_ASN1_OBJECT @ 0xd64044
// > X509_NAME_print_ex @ 0xd66ec4
// > X509_NAME_print_ex_fp @ 0xd673b4
// > X509_aux_print @ 0xde53d0
// > X509_aux_print @ 0xde5474
// > sub_E0FE14 @ 0xe10724
// > sub_E0FE14 @ 0xe10b38
// > ASN1_item_print @ 0xe11420
// > ??> @ 0x5b938
//
// 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
//
size_t __fastcall OBJ_obj2txt(char *a1, int a2, __int64 a3, int a4)
{
_BOOL4 v4; // w19
char *v5; // x26
int v6; // w27
char *v7; // x22
int v8; // w21
__int64 *v9; // x23
unsigned int v10; // w28
int v11; // s8
unsigned __int64 v12; // x19
int v13; // w24
char v14; // w1
char v15; // t1
int v16; // w20
unsigned __int64 v18; // x0
const char *v19; // x0
char *v20; // x19
int v21; // w20
char *v22; // x24
unsigned int v23; // w0
unsigned int v24; // w20
int v25; // w19
char *v26; // x21
__int64 v27; // [xsp+88h] [xbp+88h]
char v28[40]; // [xsp+98h] [xbp+98h] BYREF
v4 = a1 != nullptr;
v5 = a1;
v6 = a2;
if ( a1 && a2 > 0 )
*a1 = 0;
if ( !a3 )
return 0;
v7 = *(char **)(a3 + 24);
if ( !v7 )
return 0;
if ( a4 )
{
LABEL_7:
v8 = *(_DWORD *)(a3 + 20);
v9 = nullptr;
v10 = 0;
if ( v8 <= 0 )
goto LABEL_49;
v10 = 0;
v9 = nullptr;
v11 = 1;
while ( 1 )
{
v12 = 0;
v13 = 0;
while ( 1 )
{
v15 = *v7++;
v14 = v15;
--v8;
v16 = v15;
if ( v15 < 0 && !v8 )
goto LABEL_19;
if ( v13 )
break;
v12 |= v14 & 0x7F;
if ( (v16 & 0x80000000) == 0 )
{
if ( v11 )
{
if ( v12 <= 0x4F )
goto LABEL_56;
v12 -= 80LL;
LABEL_26:
LOBYTE(v18) = 2;
goto LABEL_27;
}
LABEL_45:
BIO_snprintf(v28, 0x25u, ".%lu", v12);
v25 = strlen(v28);
if ( v6 > 0 && v5 )
{
OPENSSL_strlcpy(v5, v28, v6);
if ( v6 >= v25 )
{
v6 -= v25;
v5 += v25;
}
else
{
v5 += v6;
v6 = 0;
}
}
v10 += v25;
goto LABEL_48;
}
if ( v12 <= 0x1FFFFFFFFFFFFFFLL )
{
v12 <<= 7;
}
else
{
if ( !v9 )
{
v9 = (__int64 *)BN_new();
if ( !v9 )
goto LABEL_19;
}
if ( !(unsigned int)BN_set_word((__int64)v9, v12) )
goto LABEL_19;
v13 = 1;
LABEL_18:
if ( !(unsigned int)BN_lshift((__int64)v9, v9, 7) )
goto LABEL_19;
}
}
if ( !(unsigned int)BN_add_word((__int64)v9, v14 & 0x7F) )
goto LABEL_19;
if ( v16 < 0 )
goto LABEL_18;
if ( v11 )
{
if ( v12 > 0x4F )
{
if ( (unsigned int)BN_sub_word((__int64)v9, 0x50u) )
goto LABEL_26;
LABEL_19:
BN_free((__int64)v9);
return 0xFFFFFFFFLL;
}
LABEL_56:
v18 = v12 / 0x28;
v12 -= (int)(40 * (v12 / 0x28));
LABEL_27:
if ( v6 > 1 && v5 )
{
*(_WORD *)v5 = (unsigned __int8)(v18 + 48);
--v6;
++v5;
}
++v10;
if ( !v13 )
goto LABEL_45;
}
v19 = BN_bn2dec((__int64)v9);
v20 = (char *)v19;
if ( !v19 )
goto LABEL_19;
v21 = strlen(v19);
if ( v5 )
{
if ( v6 <= 1 )
{
v22 = v5;
}
else
{
v22 = v5 + 1;
*v5 = 46;
--v6;
v5[1] = 0;
}
OPENSSL_strlcpy(v22, v20, v6);
if ( v6 >= v21 )
{
v6 -= v21;
v5 = &v22[v21];
}
else
{
v5 = &v22[v6];
v6 = 0;
}
}
v10 += 1 + v21;
CRYPTO_free(v20, (__int64)"crypto/objects/obj_dat.c", 501);
LABEL_48:
v11 = 0;
if ( v8 <= 0 )
{
LABEL_49:
BN_free((__int64)v9);
return v10;
}
}
}
v27 = a3;
v23 = OBJ_obj2nid(a3);
v24 = v23;
a3 = v27;
if ( !v23 )
{
v7 = *(char **)(v27 + 24);
goto LABEL_7;
}
v26 = OBJ_nid2ln(v23);
if ( !v26 )
{
v26 = OBJ_nid2sn(v24);
if ( !v26 )
{
a3 = v27;
v7 = *(char **)(v27 + 24);
goto LABEL_7;
}
}
if ( v4 )
OPENSSL_strlcpy(v5, v26, v6);
return strlen(v26);
}