//
// X509v3_addr_add_prefix from 0xa63068 to 0xa631f0 (392 bytes)
//
// 3 xrefs:
// > sub_A64180 @ 0xa644bc
// > sub_A64180 @ 0xa64520
// > ??> @ 0x821fc
//
// 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:35 +0000
//
int __fastcall X509v3_addr_add_prefix(int *a1, unsigned int a2, unsigned int *a3, int a4, int a5)
{
int *v7; // r0
int *v8; // r5
_DWORD *v9; // r2
int *v10; // r0
int *v11; // r7
_DWORD *v12; // r3
int v13; // r0
int v16; // r5
_DWORD *v17; // r0
int v18; // r5
_DWORD *v19; // r6
int v20; // r1
int v21; // r4
v7 = sub_A62A64(a1, a2, a3);
v8 = v7;
if ( !v7 )
return 0;
v9 = (_DWORD *)v7[1];
if ( !v9 )
return 0;
if ( *v9 )
{
if ( *v9 == 1 )
{
v11 = (int *)v9[1];
if ( v11 )
goto LABEL_17;
}
}
else if ( v9[1] )
{
return 0;
}
v10 = OPENSSL_sk_new_null();
v11 = v10;
if ( !v10 )
return 0;
if ( a2 == 1 )
{
OPENSSL_sk_set_cmp_func((int)v10, (int)sub_A61898);
}
else if ( a2 == 2 )
{
OPENSSL_sk_set_cmp_func((int)v10, (int)sub_A61608);
}
v12 = (_DWORD *)v8[1];
*v12 = 1;
v12[1] = v11;
LABEL_17:
v16 = a5 + 7;
if ( a5 + 7 < 0 )
v16 = a5 + 14;
v17 = IPAddressOrRange_new();
v18 = v16 >> 3;
v19 = v17;
if ( !v17 )
return 0;
v13 = v17[1];
*v19 = 0;
if ( !v13 && (v13 = ASN1_BIT_STRING_new(), (v19[1] = v13) == 0) || !ASN1_BIT_STRING_set(v13, a4, v18) )
{
IPAddressOrRange_free(v19);
return 0;
}
v20 = v19[1];
v21 = a5 % 8;
*(_DWORD *)(v20 + 12) = *(_DWORD *)(v20 + 12) & 0xFFFFFFF0 | 8;
if ( a5 % 8 > 0 )
{
*(_BYTE *)(*(_DWORD *)(v20 + 8) + v18 - 1) &= ~(255 >> v21);
*(_DWORD *)(v19[1] + 12) |= 8 - v21;
}
if ( OPENSSL_sk_push(v11, (int)v19) )
return 1;
IPAddressOrRange_free(v19);
return 0;
}