//
// ASN1_item_ex_free from 0x9ddd3c to 0x9de058 (796 bytes)
//
// 7 xrefs:
// > sub_9D9D48 @ 0x9d9e20
// > sub_9DAE6C @ 0x9db68c
// > ASN1_item_ex_d2i @ 0x9db928
// > ASN1_item_ex_d2i @ 0x9dc090
// > sub_9DE2C0 @ 0x9de474
// > ASN1_item_ex_new @ 0x9de8b8
// > ??> @ 0x7849c
//
// 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:07:18 +0000
//
_DWORD *__fastcall ASN1_item_ex_free(_DWORD *result, int a2)
{
int v2; // r2
_DWORD *v3; // r5
int (__fastcall *v5)(int, _DWORD *, int); // r7
int (__fastcall *v6)(_DWORD *, int); // r3
int v7; // r0
int v8; // r6
bool v9; // cc
int v10; // r6
int v11; // r8
int *v12; // r9
int field_ptr; // r0
int choice_selector; // r0
int *v15; // r4
int v16; // r0
int v17; // r6
int *v18; // r6
int v19; // r0
v2 = *(_DWORD *)(a2 + 16);
if ( !result )
return result;
v3 = result;
if ( *(_BYTE *)a2 )
{
if ( !*result )
return result;
if ( v2 )
goto LABEL_4;
switch ( *(_BYTE *)a2 )
{
case 1:
case 6:
v5 = nullptr;
LABEL_36:
result = (_DWORD *)asn1_do_lock(result, -1, a2);
if ( !result )
{
asn1_enc_free(v3, a2);
v17 = *(_DWORD *)(a2 + 12);
v9 = v17 <= 0;
v10 = *(_DWORD *)(a2 + 8) + 20 * v17;
if ( !v9 )
{
LABEL_24:
v11 = 0;
do
{
v10 -= 20;
++v11;
v12 = (int *)asn1_do_adb(v3, v10, 0);
if ( v12 )
{
field_ptr = asn1_get_field_ptr(v3, v12);
asn1_template_free(field_ptr, v12);
}
}
while ( v11 < *(_DWORD *)(a2 + 12) );
if ( v5 )
LABEL_29:
((void (__fastcall *)(int, _DWORD *, int, _DWORD))v5)(3, v3, a2, 0);
}
result = (_DWORD *)CRYPTO_free(*v3, "crypto/asn1/tasn_fre.c", 119);
*v3 = 0;
}
break;
case 2:
LABEL_31:
choice_selector = asn1_get_choice_selector(result, a2);
if ( choice_selector >= 0 && choice_selector < *(_DWORD *)(a2 + 12) )
{
v15 = (int *)(*(_DWORD *)(a2 + 8) + 20 * choice_selector);
v16 = asn1_get_field_ptr(v3, v15);
asn1_template_free(v16, v15);
}
LABEL_20:
result = (_DWORD *)CRYPTO_free(*v3, "crypto/asn1/tasn_fre.c", 79);
*v3 = 0;
break;
case 5:
return asn1_primitive_free(result, a2, 0);
default:
return result;
}
}
else
{
if ( v2 )
{
LABEL_4:
v5 = *(int (__fastcall **)(int, _DWORD *, int))(v2 + 16);
if ( v5 )
{
switch ( *(_BYTE *)a2 )
{
case 0:
goto LABEL_11;
case 1:
case 6:
result = (_DWORD *)asn1_do_lock(result, -1, a2);
if ( result )
return result;
result = (_DWORD *)v5(2, v3, a2);
if ( result == (int *)((char *)&dword_0 + 2) )
return result;
asn1_enc_free(v3, a2);
v8 = *(_DWORD *)(a2 + 12);
v9 = v8 <= 0;
v10 = *(_DWORD *)(a2 + 8) + 20 * v8;
if ( !v9 )
goto LABEL_24;
goto LABEL_29;
case 2:
result = (_DWORD *)((int (__fastcall *)(int, _DWORD *, int, _DWORD))v5)(2, result, a2, 0);
if ( result == (int *)((char *)&dword_0 + 2) )
return result;
v7 = asn1_get_choice_selector(v3, a2);
if ( v7 >= 0 && v7 < *(_DWORD *)(a2 + 12) )
{
v18 = (int *)(*(_DWORD *)(a2 + 8) + 20 * v7);
v19 = asn1_get_field_ptr(v3, v18);
asn1_template_free(v19, v18);
}
((void (__fastcall *)(int, _DWORD *, int, _DWORD))v5)(3, v3, a2, 0);
goto LABEL_20;
case 4:
goto LABEL_13;
case 5:
return asn1_primitive_free(result, a2, 0);
default:
return result;
}
}
switch ( *(_BYTE *)a2 )
{
case 0:
goto LABEL_11;
case 1:
case 6:
goto LABEL_36;
case 2:
goto LABEL_31;
case 4:
LABEL_13:
v6 = *(int (__fastcall **)(_DWORD *, int))(v2 + 8);
if ( v6 )
result = (_DWORD *)v6(result, a2);
break;
case 5:
return asn1_primitive_free(result, a2, 0);
default:
return result;
}
return result;
}
LABEL_11:
if ( *(_DWORD *)(a2 + 8) )
return (_DWORD *)asn1_template_free((int)result, *(int **)(a2 + 8));
else
return asn1_primitive_free(result, a2, 0);
}
return result;
}