//
// ssl_choose_server_version from 0xfcd6c8 to 0xfcd9a0 (728 bytes)
//
// 3 xrefs:
// > tls_process_client_hello @ 0xfceae4
// > tls_process_client_hello @ 0xfcf174
// > ??> @ 0x1005b8
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:15:27 +0000
//
__int64 __fastcall ssl_choose_server_version(__int64 a1)
{
__int64 v1; // x2
int v2; // w21
int *v3; // x19
int v4; // w1
int v6; // w3
__int64 (*v7)(void); // x0
__int64 v8; // x23
int v9; // w1
signed int v10; // w22
int v11; // t1
int v13; // w1
int v14; // w0
int v15; // w0
int v16; // w1
int v17; // w2
int v18; // w0
v1 = *(_QWORD *)(a1 + 8);
v2 = *(_DWORD *)(a1 + 516);
if ( *(_DWORD *)v1 == 0x10000 )
{
v3 = &dword_1538358;
goto LABEL_4;
}
if ( *(_DWORD *)v1 == 0x1FFFF )
{
v3 = &dword_15382F8;
LABEL_4:
v4 = *v3;
if ( !*v3 )
return 396;
v6 = 0;
while ( 1 )
{
v7 = *((__int64 (**)(void))v3 + 2);
if ( v7 )
{
if ( v2 == v4 )
goto LABEL_10;
if ( (*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 104LL) & 8) != 0 )
{
if ( v2 != 256 )
{
v17 = v2;
if ( v4 == 256 )
v4 = 65280;
goto LABEL_40;
}
v17 = 65280;
if ( v4 != 256 )
{
LABEL_40:
if ( v4 < v17 )
goto LABEL_16;
}
LABEL_10:
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 >= v9 )
goto LABEL_14;
LABEL_15:
v6 = 1;
goto LABEL_16;
}
if ( v10 != 256 )
{
v18 = *(_DWORD *)v8;
if ( v9 == 256 )
v9 = 65280;
goto LABEL_45;
}
v18 = 65280;
if ( v9 != 256 )
{
LABEL_45:
if ( v18 > v9 )
goto LABEL_15;
}
}
LABEL_14:
if ( !(unsigned int)ssl_security(a1, 9u, 0, v10, 0) )
goto LABEL_15;
v14 = *(_DWORD *)(a1 + 496);
if ( !v14 || v10 == v14 )
{
LABEL_32:
if ( (*(unsigned int *)(a1 + 484) & *(_QWORD *)(v8 + 8)) != 0 )
goto LABEL_15;
}
else
{
if ( (*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 192LL) + 104LL) & 8) == 0 )
{
if ( v10 >= v14 )
goto LABEL_15;
goto LABEL_32;
}
if ( v10 == 256 )
{
v10 = 65280;
if ( v14 == 256 )
goto LABEL_15;
}
else if ( v14 == 256 )
{
v14 = 65280;
}
if ( v10 <= v14 || (*(unsigned int *)(a1 + 484) & *(_QWORD *)(v8 + 8)) != 0 )
goto LABEL_15;
}
v15 = *(_DWORD *)(v8 + 4);
if ( ((v15 & 2) == 0 || (*(_DWORD *)(*(_QWORD *)(a1 + 328) + 28LL) & 0x30000) == 0)
&& ((v15 & 1) == 0 || !(unsigned int)FIPS_mode()) )
{
v16 = *v3;
*(_QWORD *)(a1 + 8) = v8;
*(_DWORD *)a1 = v16;
return 0;
}
goto LABEL_15;
}
if ( v2 >= v4 )
goto LABEL_10;
}
LABEL_16:
v11 = v3[6];
v3 += 6;
v4 = v11;
if ( !v11 )
{
if ( v6 )
return 258;
else
return 396;
}
}
}
v13 = *(_DWORD *)a1;
if ( v2 == *(_DWORD *)a1 )
return 0;
if ( (*(_DWORD *)(*(_QWORD *)(v1 + 192) + 104LL) & 8) != 0 )
{
if ( v2 != 256 )
{
if ( v13 == 256 )
v13 = 65280;
goto LABEL_25;
}
v2 = 65280;
if ( v13 != 256 )
{
LABEL_25:
if ( v13 < v2 )
return 266;
else
return 0;
}
return 0;
}
if ( v2 < v13 )
return 266;
else
return 0;
}