//
// asn1_do_lock from 0x7ca358 to 0x7ca434 (220 bytes)
//
// 11 xrefs:
// > asn1_template_free @ 0x7c8900
// > asn1_template_free @ 0x7c8a84
// > asn1_template_free @ 0x7c8c60
// > asn1_template_free @ 0x7c8d90
// > ASN1_item_free @ 0x7c8f60
// > ASN1_item_free @ 0x7c90cc
// > ASN1_item_ex_free @ 0x7c92a4
// > ASN1_item_ex_free @ 0x7c93e8
// > sub_7C96C0 @ 0x7c98dc
// > ASN1_item_ex_new @ 0x7c9d20
// > ??> @ 0x5eb0c
//
// 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 asn1_do_lock(int *a1, int a2, unsigned __int8 *a3)
{
int v3; // r3
bool v4; // zf
int v5; // r4
_DWORD *v6; // r3
int v7; // r5
int v8; // r2
int v9; // r6
int v10; // r0
int v12; // r0
int v13; // [sp+Ch] [bp-4h] BYREF
v3 = *a3;
v4 = v3 == 6;
if ( v3 != 6 )
v4 = v3 == 1;
if ( !v4 )
return 0;
v6 = *((_DWORD **)a3 + 4);
if ( !v6 )
return 0;
v5 = v6[1] & 1;
if ( v5 )
{
v7 = *a1;
v8 = v6[2];
v9 = v6[3];
v10 = *a1 + v8;
if ( a2 )
{
if ( CRYPTO_atomic_add(v10, a2, &v13, *(_DWORD *)(v7 + v9)) < 0 )
{
return -1;
}
else
{
v5 = v13;
if ( !v13 )
{
CRYPTO_THREAD_lock_free(*(_DWORD *)(v7 + v9));
*(_DWORD *)(v7 + v9) = 0;
return v13;
}
}
}
else
{
v5 = 1;
*(_DWORD *)(v7 + v8) = 1;
v12 = CRYPTO_THREAD_lock_new(v10);
*(_DWORD *)(v7 + v9) = v12;
if ( !v12 )
{
ERR_put_error(13, 233, 65, "crypto/asn1/tasn_utl.c", 74);
return -1;
}
}
}
return v5;
}