//
// sub_1005403A8 from 0x1005403a8 to 0x100540498 (240 bytes)
//
// 4 xrefs:
// > sub_10051CF68 @ 0x10051dadc
// > sub_100521AE0 @ 0x100522430
// > sub_100537D24 @ 0x100538858
// > sub_100538A48 @ 0x10053936c
//
// 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 sub_1005403A8(__int64 result, int a2)
{
__int64 v3; // x20
int v4; // w22
__int64 v5; // x20
unsigned __int8 *v6; // x8
time_t v7; // x1
v3 = result;
if ( !*(_DWORD *)(*(_QWORD *)(result + 304) + 68LL) )
return result;
result = *(_QWORD *)(result + 624);
v4 = *(_DWORD *)(result + 64);
if ( (v4 & a2) != 0 && !*(_DWORD *)(v3 + 168) )
{
if ( (v4 & 0x200) != 0 )
{
LABEL_7:
if ( *(_QWORD *)(result + 80) )
{
sub_100588508(*(_QWORD *)(v3 + 304) + 192LL, 1, 14, "ssl_lib.c", 2633);
result = (*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)(v3 + 624) + 80LL))(v3, *(_QWORD *)(v3 + 304));
if ( !(_DWORD)result )
result = sub_1005422E0(*(_QWORD *)(v3 + 304));
}
goto LABEL_10;
}
result = sub_100542CA0();
if ( (_DWORD)result )
{
result = *(_QWORD *)(v3 + 624);
goto LABEL_7;
}
}
LABEL_10:
if ( (v4 & 0x80) == 0 && (v4 & a2) == a2 )
{
v5 = *(_QWORD *)(v3 + 624);
v6 = (unsigned __int8 *)(v5 + 112);
if ( (a2 & 1) == 0 )
v6 = (unsigned __int8 *)(v5 + 124);
if ( *v6 == 255 )
{
v7 = time(nullptr);
return sub_10054310C(v5, v7);
}
}
return result;
}