//
// asn1_do_lock from 0xfee664 to 0xfee740 (220 bytes)
//
// 11 xrefs:
// > asn1_template_free @ 0xfecdbc
// > asn1_template_free @ 0xfecf70
// > asn1_template_free @ 0xfed1a0
// > asn1_template_free @ 0xfed2bc
// > ASN1_item_free @ 0xfed490
// > ASN1_item_free @ 0xfed5ec
// > ASN1_item_ex_free @ 0xfed7b8
// > ASN1_item_ex_free @ 0xfed8ec
// > sub_FEDB60 @ 0xfedcc4
// > ASN1_item_ex_new @ 0xfee110
// > ??> @ 0xf3d00
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:15:44 +0000
//
__int64 __fastcall asn1_do_lock(__int64 *a1, __int64 a2, unsigned __int8 *a3)
{
int v3; // w3
bool v4; // zf
unsigned int v5; // w3
_DWORD *v7; // x2
__int64 v8; // x20
__int64 v9; // x3
__int64 v10; // x21
__int64 v11; // x0
__int64 v12; // x0
unsigned int v13; // [xsp+3Ch] [xbp+3Ch] BYREF
v3 = *a3;
if ( v3 == 6 || (v4 = v3 == 1, v5 = 0, v4) )
{
v7 = *((_DWORD **)a3 + 4);
if ( v7 )
{
v5 = v7[2] & 1;
if ( v5 )
{
v8 = *a1;
v9 = (int)v7[3];
v10 = (int)v7[4];
v11 = *a1 + v9;
if ( (_DWORD)a2 )
{
if ( (CRYPTO_atomic_add(v11, a2, &v13, *(_QWORD *)(v8 + v10)) & 0x80000000) != 0 )
{
return (unsigned int)-1;
}
else
{
v5 = v13;
if ( !v13 )
{
CRYPTO_THREAD_lock_free(*(_QWORD *)(v8 + v10));
*(_QWORD *)(v8 + v10) = 0;
return v13;
}
}
}
else
{
*(_DWORD *)(v8 + v9) = 1;
v12 = CRYPTO_THREAD_lock_new(v11);
*(_QWORD *)(v8 + v10) = v12;
v5 = 1;
if ( !v12 )
{
ERR_put_error(13, 233, 65, "crypto/asn1/tasn_utl.c", 74);
return (unsigned int)-1;
}
}
}
}
else
{
return 0;
}
}
return v5;
}