//
// ssl_check_version_downgrade from 0xd4f104 to 0xd4f304 (512 bytes)
//
// 3 xrefs:
// > tls_process_client_hello @ 0xd50d40
// > tls_process_client_hello @ 0xd51008
// > ??> @ 0x90810
//
// 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 ssl_check_version_downgrade(__int64 a1)
{
_BOOL8 result; // x0
int v3; // w19
int v4; // w19
int *v5; // x19
int v6; // t1
__int64 (*v7)(void); // x0
__int64 v8; // x22
int v9; // w1
signed int v10; // w21
int v11; // w0
int v12; // w0
int v13; // w0
result = 1;
v3 = ***(_DWORD ***)(a1 + 440);
if ( *(_DWORD *)a1 != v3 )
{
if ( v3 == *(_DWORD *)TLS_method() )
{
v5 = &dword_12205D0;
}
else
{
v4 = ***(_DWORD ***)(a1 + 440);
if ( v4 != *(_DWORD *)DTLS_method() )
return 0;
v5 = &dword_1220570;
}
if ( !*v5 )
return 0;
while ( 1 )
{
v7 = *((__int64 (**)(void))v5 + 2);
if ( !v7 )
goto LABEL_11;
v8 = v7();
v9 = *(_DWORD *)(a1 + 492);
v10 = *(_DWORD *)v8;
if ( v9 && v10 != v9 )
{
if ( (*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 104LL) & 8) != 0 )
{
if ( v10 != 256 )
{
v11 = *(_DWORD *)v8;
if ( v9 == 256 )
v9 = 65280;
LABEL_19:
if ( v9 < v11 || !(unsigned int)ssl_security(a1, 9u, 0, v10, 0) )
goto LABEL_11;
goto LABEL_21;
}
v11 = 65280;
if ( v9 != 256 )
goto LABEL_19;
}
else if ( v10 < v9 )
{
goto LABEL_11;
}
}
if ( !(unsigned int)ssl_security(a1, 9u, 0, v10, 0) )
goto LABEL_11;
LABEL_21:
v12 = *(_DWORD *)(a1 + 496);
if ( !v12 || v10 == v12 )
goto LABEL_28;
if ( (*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 104LL) & 8) == 0 )
{
if ( v10 >= v12 )
goto LABEL_11;
LABEL_28:
if ( (*(unsigned int *)(a1 + 484) & *(_QWORD *)(v8 + 8)) == 0 )
{
v13 = *(_DWORD *)(v8 + 4);
if ( ((v13 & 2) == 0 || (*(_DWORD *)(*(_QWORD *)(a1 + 328) + 28LL) & 0x30000) == 0)
&& ((v13 & 1) == 0 || !(unsigned int)FIPS_mode()) )
{
return *(_DWORD *)a1 == *v5;
}
}
goto LABEL_11;
}
if ( v10 == 256 )
{
v10 = 65280;
if ( v12 == 256 )
goto LABEL_11;
}
else if ( v12 == 256 )
{
v12 = 65280;
}
if ( v10 > v12 )
goto LABEL_28;
LABEL_11:
v6 = v5[6];
v5 += 6;
if ( !v6 )
return 0;
}
}
return result;
}