//
// sub_785B18 from 0x785b18 to 0x785cac (404 bytes)
//
// 1 xrefs:
// > ??> @ 0xa2ee7c
//
// 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 sub_785B18(int a1, int a2, int a3)
{
_DWORD *data; // r0
int v7; // r7
_DWORD *v8; // r8
int v9; // r4
int v11; // r1
unsigned int v12; // r3
unsigned int v13; // r2
unsigned int v14; // r0
int v15; // r3
if ( !a2 )
return 0;
data = (_DWORD *)BIO_get_data();
v7 = *data;
v8 = data;
BIO_clear_flags(a1, 15);
v9 = SSL_read(v7, a2, a3);
switch ( SSL_get_error(v7, v9) )
{
case 0:
if ( v9 <= 0 )
goto LABEL_16;
v12 = v8[2];
if ( !v12 )
goto LABEL_15;
v13 = v9 + v8[3];
if ( v12 < v13 )
{
++v8[1];
v8[3] = 0;
SSL_renegotiate(v7);
v11 = 0;
}
else
{
v8[3] = v13;
LABEL_15:
if ( !v8[4] )
goto LABEL_16;
v14 = time(nullptr);
if ( v14 <= v8[4] + v8[5] )
goto LABEL_16;
v15 = v8[1];
v8[5] = v14;
v8[1] = v15 + 1;
SSL_renegotiate(v7);
v11 = 0;
}
LABEL_5:
BIO_set_retry_reason(a1, v11);
return v9;
case 2:
BIO_set_flags(a1, 9);
v11 = 0;
goto LABEL_5;
case 3:
BIO_set_flags(a1, 10);
v11 = 0;
goto LABEL_5;
case 4:
BIO_set_flags(a1, 12);
v11 = 1;
goto LABEL_5;
case 7:
BIO_set_flags(a1, 12);
v11 = 2;
goto LABEL_5;
case 8:
BIO_set_flags(a1, 12);
v11 = 3;
goto LABEL_5;
default:
LABEL_16:
v11 = 0;
goto LABEL_5;
}
}