//
// BN_to_ASN1_ENUMERATED from 0x862c1c to 0x862d54 (312 bytes)
//
// 1 xrefs:
// > ??> @ 0x698fc
//
// 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
//
int __fastcall BN_to_ASN1_ENUMERATED(_DWORD *a1, int a2, int a3, int a4)
{
int v6; // r5
int v7; // r0
int v8; // r4
int v9; // r4
int v11; // r0
if ( a2 )
a4 = 10;
if ( a2 )
{
*(_DWORD *)(a2 + 4) = a4;
v6 = a2;
}
else
{
v11 = ASN1_STRING_type_new(10);
v6 = v11;
if ( !v11 )
{
ERR_put_error(13, 229, 58, (int)"crypto/asn1/a_int.c", 484);
return 0;
}
}
if ( BN_is_negative((int)a1) && !BN_is_zero((int)a1) )
*(_DWORD *)(v6 + 4) |= 0x102u;
v7 = BN_num_bits(a1);
v8 = v7 + 7;
if ( v7 + 7 < 0 )
v8 = v7 + 14;
v9 = v8 >> 3;
if ( !v9 )
v9 = 1;
if ( ASN1_STRING_set((signed int *)v6, nullptr, v9) )
{
if ( BN_is_zero((int)a1) )
**(_BYTE **)(v6 + 8) = 0;
else
v9 = BN_bn2bin(a1, *(_BYTE **)(v6 + 8));
*(_DWORD *)v6 = v9;
return v6;
}
else
{
ERR_put_error(13, 229, 65, (int)"crypto/asn1/a_int.c", 497);
if ( a2 != v6 )
ASN1_INTEGER_free(v6);
return 0;
}
}