//
// sub_E0DC68 from 0xe0dc68 to 0xe0e1d0 (1384 bytes)
//
// 2 xrefs:
// > sub_E0D194 @ 0xe0d1c8
// > sub_E0D194 @ 0xe0d1dc
//
// 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_E0DC68(char *a1, int a2, __int64 a3)
{
int v4; // w21
char *v6; // x3
int v7; // w27
const char *v8; // x20
int v9; // w28
char **v10; // x19
int v11; // w0
int v12; // w3
unsigned int v13; // w2
__int64 result; // x0
int v15; // w1
int v16; // w3
__int64 v17; // x26
int v18; // w1
int v19; // w3
_DWORD *v20; // x26
int v21; // w1
int v22; // w3
_DWORD *v23; // x26
int v24; // w5
int v25; // w4
int v26; // w1
__int64 v27; // x26
int v28; // [xsp+68h] [xbp+68h] BYREF
int v29; // [xsp+6Ch] [xbp+6Ch] BYREF
v4 = a2;
if ( !a1 )
return (unsigned int)-1;
if ( a2 <= 0 )
{
v8 = nullptr;
v7 = a2;
v9 = 0;
}
else
{
v6 = a1;
v7 = 0;
if ( *a1 != 58 )
{
v6 = a1;
do
{
if ( ++v6 == &a1[a2 - 1 + 1] )
{
v8 = nullptr;
v7 = a2;
v9 = 0;
goto LABEL_8;
}
}
while ( *v6 != 58 );
v7 = (_DWORD)v6 - (_DWORD)a1;
}
v8 = v6 + 1;
v9 = a2 + (_DWORD)a1 - ((_DWORD)v6 + 1);
}
v4 = v7;
if ( v7 == -1 )
v4 = strlen(a1);
LABEL_8:
v10 = &off_1131B70;
qword_125F868 = (__int64)&off_1131B70;
while ( 1 )
{
if ( *((_DWORD *)v10 + 2) == v4 )
{
v11 = strncmp(*v10, a1, v4);
if ( !v11 )
break;
}
v10 += 2;
qword_125F868 = (__int64)v10;
if ( v10 == (char **)&unk_1131E80 )
goto LABEL_16;
}
v12 = *((_DWORD *)v10 + 3);
if ( v12 == -1 )
{
LABEL_16:
ERR_put_error(13, 177, 194, (__int64)"crypto/asn1/asn1_gen.c", 266);
ERR_add_error_data(2, "tag=", a1);
return 0xFFFFFFFFLL;
}
v13 = v12 & 0x10000;
if ( (v12 & 0x10000) == 0 )
{
*(_DWORD *)(a3 + 8) = v12;
*(_QWORD *)(a3 + 16) = v8;
if ( !v8 )
{
if ( a1[v7] )
{
ERR_put_error(13, 177, 189, (__int64)"crypto/asn1/asn1_gen.c", 277);
return (unsigned int)-1;
}
}
return v13;
}
switch ( v12 )
{
case 65537:
if ( *(_DWORD *)a3 == -1 )
{
if ( !(unsigned int)sub_E0D04C(v8, v9, (_DWORD *)a3, (_DWORD *)(a3 + 4)) )
return (unsigned int)-1;
return 1;
}
else
{
ERR_put_error(13, 177, 181, (__int64)"crypto/asn1/asn1_gen.c", 288);
return (unsigned int)-1;
}
case 65538:
if ( !(unsigned int)sub_E0D04C(v8, v9, &v28, &v29) )
return (unsigned int)-1;
v24 = v28;
v25 = v29;
if ( *(_DWORD *)a3 != -1 )
{
ERR_put_error(13, 176, 179, (__int64)"crypto/asn1/asn1_gen.c", 472);
return (unsigned int)-1;
}
v26 = *(_DWORD *)(a3 + 504);
if ( v26 == 20 )
{
ERR_put_error(13, 176, 174, (__int64)"crypto/asn1/asn1_gen.c", 477);
return (unsigned int)-1;
}
else
{
*(_DWORD *)(a3 + 504) = v26 + 1;
v13 = 1;
v27 = a3 + 24LL * v26;
*(_DWORD *)(v27 + 24) = v24;
*(_DWORD *)(v27 + 28) = v25;
*(_QWORD *)(v27 + 32) = 1;
}
return v13;
case 65540:
v21 = *(_DWORD *)(a3 + 504);
v22 = *(_DWORD *)a3;
if ( v21 == 20 )
goto LABEL_61;
*(_DWORD *)(a3 + 504) = v21 + 1;
if ( v22 == -1 )
{
v22 = 3;
}
else
{
v11 = *(_DWORD *)(a3 + 4);
*(_DWORD *)a3 = -1;
*(_DWORD *)(a3 + 4) = -1;
}
v13 = 1;
v23 = (_DWORD *)(a3 + 24LL * v21);
v23[7] = v11;
v23[6] = v22;
v23[8] = 0;
v23[9] = 1;
return v13;
case 65541:
v18 = *(_DWORD *)(a3 + 504);
v19 = *(_DWORD *)a3;
if ( v18 == 20 )
goto LABEL_61;
*(_DWORD *)(a3 + 504) = v18 + 1;
if ( v19 == -1 )
{
v19 = 4;
}
else
{
v11 = *(_DWORD *)(a3 + 4);
*(_DWORD *)a3 = -1;
*(_DWORD *)(a3 + 4) = -1;
}
v13 = 1;
v20 = (_DWORD *)(a3 + 24LL * v18);
v20[7] = v11;
v20[6] = v19;
v20[8] = 0;
v20[9] = 0;
return v13;
case 65542:
v15 = *(_DWORD *)(a3 + 504);
v16 = *(_DWORD *)a3;
if ( v15 == 20 )
goto LABEL_61;
*(_DWORD *)(a3 + 504) = v15 + 1;
if ( v16 != -1 )
goto LABEL_32;
v16 = 16;
goto LABEL_33;
case 65543:
v15 = *(_DWORD *)(a3 + 504);
v16 = *(_DWORD *)a3;
if ( v15 == 20 )
{
LABEL_61:
ERR_put_error(13, 176, 174, (__int64)"crypto/asn1/asn1_gen.c", 477);
return (unsigned int)-1;
}
*(_DWORD *)(a3 + 504) = v15 + 1;
if ( v16 == -1 )
{
v16 = 17;
}
else
{
LABEL_32:
v11 = *(_DWORD *)(a3 + 4);
*(_DWORD *)a3 = -1;
*(_DWORD *)(a3 + 4) = -1;
}
LABEL_33:
v17 = a3 + 24LL * v15;
*(_DWORD *)(v17 + 28) = v11;
*(_DWORD *)(v17 + 24) = v16;
*(_QWORD *)(v17 + 32) = 1;
result = 1;
break;
case 65544:
if ( v8 )
{
if ( !strncmp(v8, "ASCII", 5u) )
{
v13 = 1;
*(_DWORD *)(a3 + 12) = 1;
}
else if ( !strncmp(v8, "UTF8", 4u) )
{
v13 = 1;
*(_DWORD *)(a3 + 12) = 2;
}
else if ( !strncmp(v8, "HEX", 3u) )
{
v13 = 1;
*(_DWORD *)(a3 + 12) = 3;
}
else if ( !strncmp(v8, "BITLIST", 7u) )
{
v13 = 1;
*(_DWORD *)(a3 + 12) = 4;
}
else
{
ERR_put_error(13, 177, 160, (__int64)"crypto/asn1/asn1_gen.c", 337);
return (unsigned int)-1;
}
}
else
{
ERR_put_error(13, 177, 160, (__int64)"crypto/asn1/asn1_gen.c", 325);
return (unsigned int)-1;
}
return v13;
default:
return 1;
}
return result;
}