//
// OBJ_obj2txt from 0xa314e8 to 0xa3186c (900 bytes)
//
// 9 xrefs:
// > i2t_ASN1_OBJECT @ 0x9d2450
// > X509_NAME_print_ex @ 0x9d519c
// > X509_NAME_print_ex_fp @ 0x9d5718
// > X509_aux_print @ 0xa520e0
// > X509_aux_print @ 0xa52190
// > sub_A7C880 @ 0xa7d2b4
// > sub_A7C880 @ 0xa7d5b0
// > ASN1_item_print @ 0xa7df9c
// > ??> @ 0x77c4c
//
// 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:04 +0000
//
size_t __fastcall OBJ_obj2txt(char *a1, signed int a2, int a3, int a4)
{
int v4; // r4
bool v5; // cc
char *v7; // r8
unsigned __int8 *v8; // r5
int v9; // r4
int **v10; // r6
int v11; // r7
unsigned int v12; // r11
int v13; // r10
unsigned __int8 v14; // r1
unsigned __int8 v15; // t1
unsigned __int8 v16; // r9
unsigned int v18; // r2
bool v19; // cc
const char *v20; // r0
char *v21; // r11
signed int v22; // r10
int v23; // r3
char *v24; // r0
unsigned int v25; // r5
size_t v26; // r0
bool v27; // cc
signed int v28; // r11
char *v29; // r6
signed int v30; // r3
signed int v31; // [sp+0h] [bp-34h]
int v32; // [sp+4h] [bp-30h]
char v33[32]; // [sp+14h] [bp-20h] BYREF
v4 = (int)a1;
if ( a1 )
v4 = 1;
v5 = (int)a1 <= 0;
if ( a1 )
v5 = a2 <= 0;
if ( !v5 )
*a1 = 0;
v7 = a1;
v31 = a2;
if ( !a3 )
return 0;
v8 = *(unsigned __int8 **)(a3 + 16);
if ( !v8 )
return 0;
if ( a4 )
{
LABEL_10:
v9 = *(_DWORD *)(a3 + 12);
if ( v9 <= 0 )
{
v10 = nullptr;
v11 = 0;
goto LABEL_54;
}
v11 = 0;
v10 = nullptr;
v32 = 1;
while ( 1 )
{
v12 = 0;
v13 = 0;
while ( 1 )
{
v15 = *v8++;
v14 = v15;
--v9;
v16 = v15;
if ( ((v9 == 0) & (v15 >> 7)) != 0 )
goto LABEL_22;
if ( v13 )
break;
v12 |= v14 & 0x7F;
if ( (v16 & 0x80) == 0 )
{
if ( !v32 )
{
LABEL_57:
BIO_snprintf(v33, 0x1Au, ".%lu", v12, v31);
v26 = strlen(v33);
v27 = (int)v7 <= 0;
if ( v7 )
v27 = v31 <= 0;
v28 = v26;
if ( !v27 )
{
OPENSSL_strlcpy(v7, v33, v31);
v30 = v31;
if ( v31 >= v28 )
v30 = v31 - v28;
else
v7 += v31;
if ( v31 >= v28 )
v7 += v28;
else
v30 = 0;
v31 = v30;
}
v11 += v28;
goto LABEL_53;
}
if ( v12 > 0x4F )
{
v12 -= 80;
goto LABEL_35;
}
LABEL_68:
v18 = v12 / 0x28;
v12 %= 0x28u;
goto LABEL_36;
}
if ( v12 < 0x2000000 )
{
v12 <<= 7;
}
else
{
if ( !v10 )
{
v10 = (int **)BN_new();
if ( !v10 )
goto LABEL_22;
}
if ( !BN_set_word(v10, v12) )
goto LABEL_22;
v13 = 1;
LABEL_21:
if ( !BN_lshift(v10, (int *)v10, 7) )
goto LABEL_22;
}
}
if ( !BN_add_word((int)v10, v14 & 0x7F) )
goto LABEL_22;
if ( (v16 & 0x80) != 0 )
goto LABEL_21;
if ( !v32 )
goto LABEL_41;
if ( v12 <= 0x4F )
goto LABEL_68;
if ( !BN_sub_word(v10, 0x50u) )
goto LABEL_22;
LABEL_35:
LOBYTE(v18) = 2;
LABEL_36:
v19 = (int)v7 <= 0;
if ( v7 )
v19 = v31 <= 1;
if ( !v19 )
{
v7[1] = 0;
*v7++ = v18 + 48;
--v31;
}
++v11;
if ( !v13 )
goto LABEL_57;
LABEL_41:
v20 = BN_bn2dec(v10);
v21 = (char *)v20;
if ( !v20 )
{
LABEL_22:
BN_free((int)v10);
return -1;
}
v22 = strlen(v20);
if ( v7 )
{
if ( v31 > 1 )
{
v7[1] = 0;
*v7++ = 46;
--v31;
}
OPENSSL_strlcpy(v7, v21, v31);
v23 = v31;
if ( v31 >= v22 )
v23 = v31 - v22;
else
v7 += v31;
if ( v31 >= v22 )
v7 += v22;
else
v23 = 0;
v31 = v23;
}
v11 += 1 + v22;
CRYPTO_free(v21, (int)"crypto/objects/obj_dat.c", 501);
LABEL_53:
v32 = 0;
if ( v9 <= 0 )
{
LABEL_54:
BN_free((int)v10);
return v11;
}
}
}
v24 = OBJ_obj2nid(a3);
v25 = (unsigned int)v24;
if ( !v24 || (v29 = OBJ_nid2ln((unsigned int)v24)) == nullptr && (v29 = OBJ_nid2sn(v25)) == nullptr )
{
v8 = *(unsigned __int8 **)(a3 + 16);
goto LABEL_10;
}
if ( v4 )
OPENSSL_strlcpy(v7, v29, v31);
return strlen(v29);
}