//
// sub_D6F800 from 0xd6f800 to 0xd6fbc8 (968 bytes)
//
// 4 xrefs:
// > sub_D6F800 @ 0xd6fb88
// > sub_D6F800 @ 0xd6fbb0
// > ASN1_item_ex_new @ 0xd6fef4
// > ASN1_item_ex_new @ 0xd6ff78
//
// 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
//
__int64 __fastcall sub_D6F800(__int64 *a1, __int64 a2, int a3)
{
__int64 v4; // x0
__int64 (__fastcall *v7)(__int64, __int64 *, __int64, _QWORD); // x22
__int64 *v9; // x1
__int64 v10; // x0
__int64 v11; // x1
unsigned int (__fastcall *v12)(__int64 *, __int64); // x2
int v13; // w0
__int64 v14; // x0
__int64 v15; // x24
__int64 *v16; // x20
__int64 field_ptr; // x0
_DWORD *v19; // x23
__int64 v20; // x3
__int64 v21; // x1
__int64 v22; // x2
__int64 v23; // x0
int v24; // w0
__int64 v25; // x0
__int64 v26; // x0
__int64 *v27; // [xsp+58h] [xbp+58h] BYREF
v4 = *(_QWORD *)(a2 + 32);
if ( v4 )
{
v7 = *(__int64 (__fastcall **)(__int64, __int64 *, __int64, _QWORD))(v4 + 24);
if ( v7 )
{
switch ( *(_BYTE *)a2 )
{
case 0:
goto LABEL_8;
case 1:
case 6:
v13 = v7(0, a1, a2, 0);
if ( !v13 )
goto LABEL_41;
if ( v13 != 2 )
goto LABEL_19;
return 1;
case 2:
v24 = v7(0, a1, a2, 0);
if ( !v24 )
goto LABEL_41;
if ( v24 != 2 )
goto LABEL_37;
return 1;
case 4:
goto LABEL_14;
case 5:
goto LABEL_6;
default:
return 1;
}
}
switch ( *(_BYTE *)a2 )
{
case 0:
goto LABEL_8;
case 1:
case 6:
LABEL_19:
if ( !a3 )
goto LABEL_20;
goto LABEL_48;
case 2:
LABEL_37:
if ( !a3 )
goto LABEL_38;
goto LABEL_49;
case 4:
LABEL_14:
v12 = *(unsigned int (__fastcall **)(__int64 *, __int64))(v4 + 8);
if ( v12 && !v12(a1, a2) )
goto LABEL_7;
return 1;
case 5:
goto LABEL_6;
default:
return 1;
}
}
switch ( *(_BYTE *)a2 )
{
case 0:
LABEL_8:
v9 = *(__int64 **)(a2 + 16);
if ( !v9 )
goto LABEL_6;
v10 = *v9;
v11 = v9[4];
if ( (v10 & 0x1000) != 0 )
{
v27 = a1;
a1 = (__int64 *)&v27;
}
if ( (v10 & 1) != 0 )
{
if ( (v10 & 0x306) != 0 )
*a1 = 0;
else
sub_D6F75C(a1, v11);
}
else
{
if ( (v10 & 0x300) != 0 )
{
*a1 = v10 & 1;
return 1;
}
if ( (v10 & 6) != 0 )
{
v26 = OPENSSL_sk_new_null(v10);
if ( !v26 )
goto LABEL_55;
*a1 = v26;
}
else if ( !(unsigned int)sub_D6F800(a1, v11, v10 & 0x1000) )
{
goto LABEL_7;
}
}
return 1;
case 1:
case 6:
v7 = nullptr;
if ( a3 )
{
LABEL_48:
memset((void *)*a1, 0, *(_QWORD *)(a2 + 40));
}
else
{
LABEL_20:
v14 = CRYPTO_zalloc(*(_QWORD *)(a2 + 40), "crypto/asn1/tasn_new.c", 122);
*a1 = v14;
if ( !v14 )
goto LABEL_7;
}
if ( (asn1_do_lock(a1, 0, a2) & 0x80000000) != 0 )
goto LABEL_7;
v15 = 1;
asn1_enc_init(a1, a2);
v16 = *(__int64 **)(a2 + 16);
if ( *(__int64 *)(a2 + 24) <= 0 )
goto LABEL_59;
break;
case 2:
v7 = nullptr;
if ( a3 )
{
LABEL_49:
memset((void *)*a1, 0, *(_QWORD *)(a2 + 40));
}
else
{
LABEL_38:
v25 = CRYPTO_zalloc(*(_QWORD *)(a2 + 40), "crypto/asn1/tasn_new.c", 97);
*a1 = v25;
if ( !v25 )
goto LABEL_7;
}
asn1_set_choice_selector(a1, 0xFFFFFFFFLL, a2);
if ( v7 )
goto LABEL_40;
return 1;
case 5:
LABEL_6:
if ( !sub_D6F5E8(a1, a2, a3) )
goto LABEL_7;
return 1;
default:
return 1;
}
while ( 1 )
{
field_ptr = asn1_get_field_ptr(a1, v16);
v19 = (_DWORD *)field_ptr;
v20 = *v16;
v21 = v16[4];
v22 = *v16 & 0x1000;
if ( (*v16 & 0x1000) != 0 )
{
v27 = (__int64 *)field_ptr;
v19 = &v27;
}
v23 = v20 & 1;
if ( (v20 & 1) != 0 )
{
if ( (v20 & 0x306) != 0 )
*(_QWORD *)v19 = 0;
else
sub_D6F75C(v19, v21);
goto LABEL_26;
}
if ( (v20 & 0x300) == 0 )
{
if ( (v20 & 6) == 0 )
{
if ( !(unsigned int)sub_D6F800(v19, v21, v22) )
goto LABEL_7;
goto LABEL_26;
}
v23 = OPENSSL_sk_new_null(v23);
if ( !v23 )
break;
}
*(_QWORD *)v19 = v23;
LABEL_26:
v16 += 5;
if ( v15++ >= *(_QWORD *)(a2 + 24) )
{
LABEL_59:
if ( v7 )
{
LABEL_40:
if ( !(unsigned int)v7(1, a1, a2, 0) )
{
LABEL_41:
ERR_put_error(13, 121, 100, "crypto/asn1/tasn_new.c", 152);
ASN1_item_ex_free((__int64)a1, (unsigned __int8 *)a2);
return 0;
}
}
return 1;
}
}
LABEL_55:
ERR_put_error(13, 133, 65, "crypto/asn1/tasn_new.c", 223);
LABEL_7:
ERR_put_error(13, 121, 65, "crypto/asn1/tasn_new.c", 145);
return 0;
}