//
// sub_100583258 from 0x100583258 to 0x100583468 (528 bytes)
//
// 1 xrefs:
// > sub_100587770 @ 0x100587784
//
// 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_100583258(size_t *a1, int a2)
{
__int64 v3; // x21
size_t v4; // x19
__int64 *v5; // x24
char *v6; // x21
__int64 v7; // x0
int *v8; // x25
int v9; // w0
__int64 v10; // x0
__int64 v11; // x21
int *v12; // x0
__int64 v13; // x0
__int64 v14; // x20
int v15; // w0
char v17[120]; // [xsp+10h] [xbp-C0h] BYREF
v3 = a2;
v4 = *a1;
v5 = (__int64 *)&a1[5 * a2 + 68];
if ( *(_DWORD *)(*a1 + 1336) == 2 )
sub_10053ECAC(*v5);
if ( !*v5 )
return 0;
v6 = (char *)a1 + 4 * v3;
v7 = sub_100570DE8(*((_DWORD *)v6 + 116), -1, -1, 10000);
if ( (int)v7 < 1 )
{
LABEL_8:
if ( (_DWORD)v7 )
{
v12 = __error();
sub_100552734(v4, "select/poll on SSL socket, errno: %d", *v12);
v11 = 0xFFFFFFFFLL;
}
else
{
sub_100552734(v4, "SSL shutdown timeout");
LABEL_13:
v11 = 0;
}
}
else
{
v8 = (int *)(v6 + 464);
while ( 2 )
{
sub_1005E1158(v7);
v9 = sub_10053EB78(*v5);
v10 = sub_100540544(*v5, v9);
v11 = 0;
switch ( (int)v10 )
{
case 0:
case 6:
break;
case 2:
sub_1005524A4(v4, "SSL_ERROR_WANT_READ\n");
v7 = sub_100570DE8(*v8, -1, -1, 10000);
if ( (int)v7 <= 0 )
goto LABEL_8;
continue;
case 3:
sub_1005524A4(v4, "SSL_ERROR_WANT_WRITE\n");
v11 = 0;
break;
default:
v13 = sub_1005E11DC(v10);
v14 = *a1;
sub_1005E189C(v13, v17);
__error();
sub_100552734(v14, "OpenSSL SSL read: %s, errno %d");
goto LABEL_13;
}
break;
}
}
if ( *(_BYTE *)(v4 + 1320) )
{
v15 = sub_10054088C(*v5);
switch ( v15 )
{
case 3:
sub_1005524A4(v4, "SSL_get_shutdown() returned SSL_SENT_SHUTDOWN|SSL_RECEIVED__SHUTDOWN\n");
break;
case 2:
sub_1005524A4(v4, "SSL_get_shutdown() returned SSL_RECEIVED_SHUTDOWN\n");
break;
case 1:
sub_1005524A4(v4, "SSL_get_shutdown() returned SSL_SENT_SHUTDOWN\n");
break;
}
}
sub_10053E3A4(*v5);
*v5 = 0;
return v11;
}