//
// asn1_generalizedtime_to_tm from 0x860c08 to 0x860edc (724 bytes)
//
// 4 xrefs:
// > ASN1_TIME_diff @ 0x7c12e0
// > ASN1_TIME_diff @ 0x7c1314
// > ASN1_GENERALIZEDTIME_check @ 0x860ee8
// > ??> @ 0x5e4ec
//
// 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
//
bool __fastcall asn1_generalizedtime_to_tm(int *a1, int *a2)
{
int v3; // r4
int v4; // r6
int v5; // r1
int *v6; // r7
int v7; // r2
int *v8; // r8
int v9; // lr
int v10; // r5
int v11; // r12
int v12; // r3
int v13; // r12
int v14; // t1
int v15; // t1
int v16; // r12
_BOOL4 v17; // r3
int v18; // r3
int v19; // r12
int v20; // r2
int v21; // r7
int v22; // r1
int v23; // r3
int v24; // lr
int v25; // r1
int v26; // r1
int v27; // r12
int v28; // r1
int v29; // t1
_BOOL4 v30; // r2
if ( a2[1] != 24 )
return 0;
v3 = *a2;
v4 = a2[2];
if ( *a2 <= 12 )
return 0;
v5 = 1;
v6 = (int *)&unk_A18720;
v7 = 0;
v8 = (int *)&unk_A18744;
v9 = 1;
v10 = 0;
while ( 1 )
{
if ( v7 == 6 )
{
v16 = *(unsigned __int8 *)(v4 + 12);
v17 = ((v16 - 43) & 0xFD) == 0;
if ( v16 == 90 )
v17 = 1;
if ( v17 )
break;
}
if ( (unsigned __int8)(*(_BYTE *)(v4 + 2 * v7) - 48) > 9u )
return 0;
if ( v3 < v5 )
return 0;
v11 = *(unsigned __int8 *)(v4 + v5);
if ( (unsigned int)(v11 - 48) > 9 )
return 0;
v10 += 2;
v12 = v11 + 10 * (*(unsigned __int8 *)(v4 + 2 * v7) - 48);
v13 = v12 - 48;
if ( v3 < v10 )
return 0;
v14 = *v8++;
if ( v13 < v14 )
return 0;
v15 = *v6++;
if ( v13 > v15 )
return 0;
if ( a1 )
{
switch ( v7 )
{
case 1:
a1[5] += v13;
goto LABEL_16;
case 2:
a1[4] = v12 - 49;
goto LABEL_16;
case 3:
a1[3] = v13;
goto LABEL_16;
case 4:
a1[2] = v13;
goto LABEL_16;
case 5:
a1[1] = v13;
goto LABEL_16;
case 6:
*a1 = v13;
goto LABEL_22;
default:
a1[5] = 100 * v13 - 1900;
break;
}
}
if ( v9 == 7 )
goto LABEL_22;
LABEL_16:
++v7;
++v9;
v5 += 2;
}
if ( a1 )
*a1 = 0;
LABEL_22:
v18 = *(unsigned __int8 *)(v4 + v10);
if ( v18 == 46 )
{
v27 = v10 + 1;
if ( v3 < v10 + 1 || (unsigned int)*(unsigned __int8 *)(v4 + v27) - 48 > 9 )
return 0;
v28 = v4 + v27;
++v10;
do
{
v29 = *(unsigned __int8 *)++v28;
v18 = v29;
++v10;
v30 = (unsigned int)(v29 - 48) <= 9;
if ( v3 < v10 )
v30 = 0;
}
while ( v30 );
if ( v27 == v10 )
return 0;
}
if ( v18 != 90 )
{
if ( ((v18 - 43) & 0xFD) != 0 )
{
if ( !v18 )
return v3 == v10;
}
else
{
v19 = v10 + 4;
if ( v18 == 45 )
v20 = -1;
else
v20 = 1;
if ( v3 > v19 )
{
v21 = v4 + v10;
if ( (unsigned __int8)(*(_BYTE *)(v4 + v10 + 1) - 48) <= 9u )
{
v22 = *(unsigned __int8 *)(v21 + 2);
if ( (unsigned int)(v22 - 48) <= 9 )
{
v23 = v22 + 10 * (*(unsigned __int8 *)(v4 + v10 + 1) - 48) - 48;
if ( v23 <= 12 )
{
v24 = a1 ? 3600 * v23 : 0;
if ( (unsigned __int8)(*(_BYTE *)(v21 + 3) - 48) <= 9u )
{
v25 = *(unsigned __int8 *)(v4 + v19);
if ( (unsigned int)(v25 - 48) <= 9 )
{
v26 = v25 + 10 * (*(unsigned __int8 *)(v21 + 3) - 48) - 48;
if ( v26 <= 59 )
{
if ( a1 )
v24 += 60 * v26;
v10 += 5;
if ( !v24 || OPENSSL_gmtime_adj(a1, 0, v24 * v20) )
return v3 == v10;
}
}
}
}
}
}
}
}
return 0;
}
return v3 == ++v10;
}