//
// sub_851F04 from 0x851f04 to 0x852030 (300 bytes)
//
// 6 xrefs:
// > X509v3_asid_subset @ 0x853040
// > X509v3_asid_subset @ 0x85305c
// > X509v3_asid_validate_path @ 0x85334c
// > X509v3_asid_validate_path @ 0x853390
// > X509v3_asid_validate_resource_set @ 0x853700
// > X509v3_asid_validate_resource_set @ 0x853720
//
// 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 sub_851F04(_DWORD *a1, _DWORD *a2)
{
bool v2; // zf
int v3; // r7
int v6; // r11
int v7; // r9
int v8; // r10
signed int v9; // r6
signed int v10; // r4
_DWORD *v11; // r0
int *v12; // r3
_DWORD *v13; // r0
int *v14; // r3
v2 = a2 == nullptr;
if ( a2 )
v2 = a1 == a2;
v3 = v2;
if ( !v2 )
{
if ( !a1 )
return 0;
v6 = v3;
v7 = v3;
v8 = v3;
v9 = v3;
v10 = v3;
while ( v9 < OPENSSL_sk_num((int)a2) )
{
v11 = (_DWORD *)OPENSSL_sk_value(a2, v9);
if ( !v11 )
LABEL_27:
sub_2B44F0();
if ( *v11 )
{
if ( *v11 == 1 )
{
v12 = (int *)v11[1];
v6 = *v12;
v3 = v12[1];
}
}
else
{
v6 = v11[1];
v3 = v6;
}
if ( v10 >= OPENSSL_sk_num((int)a1) )
return 0;
while ( 1 )
{
v13 = (_DWORD *)OPENSSL_sk_value(a1, v10);
if ( !v13 )
goto LABEL_27;
if ( *v13 )
{
if ( *v13 == 1 )
{
v14 = (int *)v13[1];
v8 = *v14;
v7 = v14[1];
}
}
else
{
v8 = v13[1];
v7 = v8;
}
if ( ASN1_INTEGER_cmp(v7, v3) >= 0 )
break;
if ( ++v10 >= OPENSSL_sk_num((int)a1) )
return 0;
}
if ( ASN1_INTEGER_cmp(v8, v6) > 0 )
return 0;
++v9;
}
}
return 1;
}