//
// ssl_cert_set_current from 0xd3a784 to 0xd3a970 (492 bytes)
//
// 3 xrefs:
// > ssl3_ctrl @ 0xd38fc8
// > ssl3_ctx_ctrl @ 0xd39580
// > ??> @ 0xc4938
//
// 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 ssl_cert_set_current(_QWORD *a1, __int64 a2)
{
__int64 result; // x0
int v4; // w3
__int64 v5; // x2
__int64 v6; // x1
int v7; // w3
int v8; // w3
int v9; // w1
int v10; // w1
int v11; // w1
if ( !a1 )
return 0;
if ( a2 != 1 )
{
result = 0;
if ( a2 != 2 )
return result;
v4 = -858993459 * ((__int64)(*a1 - (_QWORD)(a1 + 4)) >> 3) + 1;
if ( v4 > 6 )
return result;
v5 = v4;
v6 = 4LL * v4;
if ( a1[5 * v4 + 4] && a1[5 * v4 + 5] )
goto LABEL_26;
v7 = -858993459 * ((__int64)(*a1 - (_QWORD)(a1 + 4)) >> 3) + 2;
if ( -858993459 * (unsigned int)((__int64)(*a1 - (_QWORD)(a1 + 4)) >> 3) == 5 )
return 0;
LABEL_9:
v5 = v7;
v6 = 4LL * v7;
if ( !a1[5 * v7 + 4] )
goto LABEL_11;
LABEL_10:
if ( !a1[v6 + 5 + v5] )
{
LABEL_11:
v8 = v7 + 1;
if ( v8 != 7 )
goto LABEL_12;
return 0;
}
LABEL_26:
*a1 = &a1[v6 + 4 + v5];
return 1;
}
if ( a1[4] )
{
v5 = 0;
v7 = 1;
v6 = 0;
if ( a1[5] )
goto LABEL_26;
goto LABEL_9;
}
v7 = 1;
v5 = 1;
v6 = 4;
if ( a1[9] )
goto LABEL_10;
v8 = 2;
LABEL_12:
v5 = v8;
v6 = 4LL * v8;
if ( a1[5 * v8 + 4] && a1[5 * v8 + 5] )
goto LABEL_26;
v9 = v8 + 1;
if ( v8 == 6 )
return 0;
v5 = v9;
v6 = 4LL * v9;
if ( a1[v6 + 4 + v5] && a1[v6 + 5 + v5] )
goto LABEL_26;
v10 = v8 + 2;
if ( v8 == 5 )
return 0;
v5 = v10;
v6 = 4LL * v10;
if ( a1[v6 + 4 + v5] && a1[v6 + 5 + v5] )
goto LABEL_26;
v11 = v8 + 3;
if ( v8 == 4 )
return 0;
v5 = v11;
v6 = 4LL * v11;
if ( a1[v6 + 4 + v5] && a1[v6 + 5 + v5] )
goto LABEL_26;
LODWORD(v5) = v8 + 4;
if ( v8 == 3 )
return 0;
v5 = (int)v5;
v6 = 4LL * (int)v5;
result = a1[5 * (int)v5 + 4];
if ( result )
{
result = 0;
if ( a1[5 * (int)v5 + 5] )
goto LABEL_26;
}
return result;
}