//
// ssl_cert_set_current from 0x7915bc to 0x7917e4 (552 bytes)
//
// 3 xrefs:
// > ssl3_ctrl @ 0x78faa0
// > ssl3_ctx_ctrl @ 0x790280
// > ??> @ 0x5b01c
//
// 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
//
int __fastcall ssl_cert_set_current(_DWORD *a1, int a2)
{
int result; // r0
int v4; // r2
int v5; // r1
int v6; // r3
_DWORD *v7; // r0
int v8; // lr
int v9; // r2
_DWORD *v10; // r0
int v11; // r3
int v12; // r1
int v13; // r1
_DWORD *v14; // r0
int v15; // lr
_DWORD *v16; // r0
_DWORD *v17; // r0
int v18; // lr
_DWORD *v19; // r0
_DWORD *v20; // r0
int v21; // lr
_DWORD *v22; // r0
_DWORD *v23; // r0
int v24; // lr
_DWORD *v25; // r0
_DWORD *v26; // r3
_DWORD *v27; // r3
if ( !a1 )
return 0;
if ( a2 == 1 )
{
if ( !a1[5] )
{
v11 = 1;
v9 = 1;
if ( !a1[10] )
{
v13 = 2;
goto LABEL_12;
}
goto LABEL_10;
}
v9 = 0;
if ( a1[6] )
{
v12 = 0;
goto LABEL_26;
}
v11 = 1;
}
else
{
if ( a2 != 2 )
return 0;
v4 = (*a1 - (int)(a1 + 5)) >> 2;
v5 = -858993459 * v4 + 1;
if ( v5 > 6 )
return 0;
v6 = 4 * v5;
v7 = &a1[5 * v5];
v8 = v7[5];
v9 = -858993459 * v4 + 1;
v10 = v7 + 4;
if ( v8 && v10[2] )
goto LABEL_31;
v11 = v5 + 1;
if ( v5 == 6 )
return 0;
}
v9 = v11;
if ( !a1[5 * v11 + 5] )
goto LABEL_11;
LABEL_10:
v12 = 4 * v9;
if ( a1[5 * v9 + 6] )
{
LABEL_26:
*a1 = &a1[v12 + 5 + v9];
return 1;
}
LABEL_11:
v13 = v11 + 1;
if ( v11 == 6 )
return 0;
LABEL_12:
v6 = 4 * v13;
v14 = &a1[5 * v13];
v15 = v14[5];
v9 = v13;
v16 = v14 + 4;
if ( v15 && v16[2] )
goto LABEL_31;
v9 = v13 + 1;
if ( v13 == 6 )
return 0;
v6 = 4 * v9;
v17 = &a1[5 * v9];
v18 = v17[5];
v19 = v17 + 4;
if ( v18 && v19[2] )
goto LABEL_31;
v9 = v13 + 2;
if ( v13 == 5 )
return 0;
v6 = 4 * v9;
v20 = &a1[5 * v9];
v21 = v20[5];
v22 = v20 + 4;
if ( v21 && v22[2] )
goto LABEL_31;
v9 = v13 + 3;
if ( v13 == 4 )
return 0;
v6 = 4 * v9;
v23 = &a1[5 * v9];
v24 = v23[5];
v25 = v23 + 4;
if ( v24 && v25[2] )
{
LABEL_31:
v12 = v6;
goto LABEL_26;
}
v9 = v13 + 4;
if ( v13 == 3 )
return 0;
v12 = 4 * v9;
v26 = &a1[5 * v9];
result = v26[5];
v27 = v26 + 4;
if ( result )
{
result = v27[2];
if ( result )
goto LABEL_26;
}
return result;
}