//
// sub_9DAE6C from 0x9dae6c to 0x9db7c4 (2392 bytes)
//
// 2 xrefs:
// > sub_9D9D48 @ 0x9d9f14
// > sub_9D9D48 @ 0x9da484
//
// 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:17 +0000
//
int __fastcall sub_9DAE6C(int *a1, void **a2, int a3, _DWORD *a4, int a5, int a6, unsigned __int8 a7, int a8)
{
int v9; // r9
int v11; // r3
int (__fastcall *v12)(int, int *, _DWORD *, _DWORD); // r11
void **v13; // r8
int v14; // r7
int *v16; // r3
bool v17; // zf
int v18; // r7
int v19; // r0
int v20; // r2
_DWORD *v21; // r7
int v22; // r10
int i; // r6
int v24; // r9
int field_ptr; // r0
int choice_selector; // r0
int v27; // r3
int v28; // r10
int *v29; // r9
int v30; // r0
int v31; // r7
int v32; // r0
int v33; // r3
int v34; // r0
int v35; // r0
int v36; // r2
int v37; // r8
unsigned __int8 *v38; // r6
int v39; // r0
int *v40; // r0
void **v41; // [sp+20h] [bp-24h]
int v42; // [sp+24h] [bp-20h]
int v43; // [sp+24h] [bp-20h]
int v44; // [sp+2Ch] [bp-18h] BYREF
unsigned __int8 v45; // [sp+35h] [bp-Fh] BYREF
unsigned __int8 v46; // [sp+36h] [bp-Eh] BYREF
char v47; // [sp+37h] [bp-Dh] BYREF
unsigned __int8 *v48; // [sp+38h] [bp-Ch] BYREF
unsigned int v49; // [sp+3Ch] [bp-8h] BYREF
v44 = a3;
v9 = a4[4];
v48 = nullptr;
if ( !a1 )
return 0;
v11 = *(unsigned __int8 *)a4;
if ( v9 )
v12 = *(int (__fastcall **)(int, int *, _DWORD *, _DWORD))(v9 + 16);
else
v12 = nullptr;
v13 = a2;
switch ( v11 )
{
case 0:
v16 = (int *)a4[2];
if ( !v16 )
return sub_9D92C4(a1, a2, v44, (int)a4, a5, a6, a7, a8);
v17 = a5 == -1;
if ( a5 == -1 )
v17 = a7 == 0;
if ( !v17 )
{
ERR_put_error(13, 120, 170, "crypto/asn1/tasn_dec.c", 159);
goto LABEL_10;
}
return sub_9DAAB8((int)a1, (unsigned __int8 **)a2, v44, v16, 0, a8);
case 1:
case 6:
v18 = v44;
v48 = (unsigned __int8 *)*a2;
if ( a5 == -1 )
{
a6 = 0;
a5 = 16;
}
v19 = sub_9D8B3C(&v44, nullptr, nullptr, &v46, &v47, &v48, v44, a5, a6, a7, a8);
if ( !v19 )
{
ERR_put_error(13, 120, 58, "crypto/asn1/tasn_dec.c", 274);
goto LABEL_10;
}
if ( v19 == -1 )
return -1;
if ( v9 && (*(_DWORD *)(v9 + 4) & 4) != 0 )
{
v42 = 1;
v44 = (_BYTE *)*v13 - v48 + v18;
}
else
{
v42 = v46;
}
if ( !v47 )
{
ERR_put_error(13, 120, 149, "crypto/asn1/tasn_dec.c", 286);
goto LABEL_10;
}
if ( !*a1 && !ASN1_item_ex_new(a1, a4) )
{
ERR_put_error(13, 120, 58, "crypto/asn1/tasn_dec.c", 291);
goto LABEL_10;
}
if ( v12 && !v12(4, a1, a4, 0) )
goto LABEL_39;
v20 = a4[3];
v21 = (_DWORD *)a4[2];
if ( v20 <= 0 )
{
v22 = 0;
goto LABEL_97;
}
for ( i = 0; i < v20; ++i )
{
if ( (*v21 & 0x300) != 0 )
{
v24 = asn1_do_adb(a1, v21, 0);
if ( v24 )
{
field_ptr = asn1_get_field_ptr(a1, v24);
asn1_template_free(field_ptr, v24);
}
v20 = a4[3];
}
v21 += 5;
}
v22 = 0;
v21 = (_DWORD *)a4[2];
if ( v20 <= 0 )
{
LABEL_97:
if ( !v46 )
goto LABEL_87;
if ( v44 > 1 && !*v48 && !v48[1] )
{
v48 += 2;
goto LABEL_87;
}
goto LABEL_103;
}
v41 = v13;
while ( 1 )
{
v29 = (int *)asn1_do_adb(a1, v21, 1);
if ( !v29 )
goto LABEL_10;
v35 = asn1_get_field_ptr(a1, v29);
v36 = v44;
v37 = v35;
if ( !v44 )
{
v13 = v41;
if ( !v46 )
goto LABEL_89;
LABEL_103:
ERR_put_error(13, 120, 137, "crypto/asn1/tasn_dec.c", 364);
goto LABEL_10;
}
v38 = v48;
if ( v44 > 1 && !*v48 && !v48[1] )
break;
if ( a4[3] - 1 == v22 )
LOBYTE(v33) = 0;
else
v33 = *v29 & 1;
v34 = sub_9DAAB8(v35, &v48, v44, v29, v33, a8);
if ( !v34 )
goto LABEL_74;
if ( v34 == -1 )
asn1_template_free(v37, v29);
else
v44 += v38 - v48;
++v22;
v21 += 5;
if ( a4[3] <= v22 )
{
v13 = v41;
goto LABEL_97;
}
}
if ( v46 )
v36 = v44 - 2;
v13 = v41;
v48 += 2;
if ( !v46 )
{
ERR_put_error(13, 120, 159, "crypto/asn1/tasn_dec.c", 325);
goto LABEL_10;
}
v44 = v36;
v46 = 0;
LABEL_87:
if ( !v42 && v44 )
{
ERR_put_error(13, 120, 148, "crypto/asn1/tasn_dec.c", 369);
}
else
{
LABEL_89:
while ( a4[3] > v22 )
{
v40 = (int *)asn1_do_adb(a1, v21, 1);
++v22;
v21 += 5;
v29 = v40;
if ( !v40 )
goto LABEL_10;
if ( (*v40 & 1) == 0 )
{
ERR_put_error(13, 120, 121, "crypto/asn1/tasn_dec.c", 389);
goto LABEL_74;
}
v39 = asn1_get_field_ptr(a1, v40);
asn1_template_free(v39, v29);
}
if ( asn1_enc_save(a1, *v13, v48 - (_BYTE *)*v13, a4) )
{
if ( !v12 )
{
LABEL_54:
*v13 = v48;
return 1;
}
LABEL_53:
if ( v12(5, a1, a4, 0) )
goto LABEL_54;
}
LABEL_39:
ERR_put_error(13, 120, 100, "crypto/asn1/tasn_dec.c", 405);
}
LABEL_10:
ERR_add_error_data(2, "Type=", a4[6]);
return 0;
case 2:
if ( v12 && !v12(4, a1, a4, 0) )
goto LABEL_39;
if ( *a1 )
{
choice_selector = asn1_get_choice_selector(a1, a4);
v27 = a4[3];
if ( choice_selector >= 0 && choice_selector < v27 )
{
v31 = a4[2] + 20 * choice_selector;
v32 = asn1_get_field_ptr(a1, v31);
asn1_template_free(v32, v31);
asn1_set_choice_selector(a1, -1, a4);
v27 = a4[3];
}
}
else
{
if ( !ASN1_item_ex_new(a1, a4) )
{
ERR_put_error(13, 120, 58, "crypto/asn1/tasn_dec.c", 214);
goto LABEL_10;
}
v27 = a4[3];
}
v28 = 0;
v48 = (unsigned __int8 *)*v13;
v29 = (int *)a4[2];
if ( v27 <= 0 )
goto LABEL_51;
while ( 1 )
{
v43 = asn1_get_field_ptr(a1, v29);
v30 = sub_9DAAB8(v43, &v48, v44, v29, 1u, a8);
if ( v30 != -1 )
break;
v27 = a4[3];
++v28;
v29 += 5;
if ( v27 <= v28 )
goto LABEL_51;
}
if ( v30 <= 0 )
{
asn1_template_free(v43, v29);
ERR_put_error(13, 120, 58, "crypto/asn1/tasn_dec.c", 237);
if ( !v29 )
goto LABEL_10;
LABEL_74:
ERR_add_error_data(4, "Field=", v29[3]);
return 0;
}
v27 = a4[3];
LABEL_51:
if ( v28 != v27 )
{
asn1_set_choice_selector(a1, v28, a4);
if ( !v12 )
goto LABEL_54;
goto LABEL_53;
}
if ( !a7 )
{
ERR_put_error(13, 120, 143, "crypto/asn1/tasn_dec.c", 249);
goto LABEL_10;
}
ASN1_item_ex_free(a1, a4);
return -1;
case 4:
return (*(int (__fastcall **)(int *, void **, int, _DWORD *, int, int, _DWORD, int))(v9 + 16))(
a1,
a2,
v44,
a4,
a5,
a6,
a7,
a8);
case 5:
v48 = (unsigned __int8 *)*a2;
if ( !sub_9D8DC0(nullptr, &v49, &v45, nullptr, nullptr, &v48, v44, 1, a8) )
{
ERR_put_error(13, 120, 58, "crypto/asn1/tasn_dec.c", 174);
goto LABEL_10;
}
v14 = v45;
if ( v45 )
{
if ( a7 )
return -1;
ERR_put_error(13, 120, 139, "crypto/asn1/tasn_dec.c", 183);
}
else
{
if ( (ASN1_tag2bit(v49) & a4[1]) != 0 )
return sub_9D92C4(a1, v13, v44, (int)a4, v49, v14, v14, a8);
if ( a7 )
return -1;
ERR_put_error(13, 120, 140, "crypto/asn1/tasn_dec.c", 191);
}
goto LABEL_10;
default:
return 0;
}
}