//
// ssl3_write_pending from 0x7889d4 to 0x788b7c (424 bytes)
//
// 5 xrefs:
// > do_dtls1_write @ 0x787f64
// > do_ssl3_write @ 0x7890c0
// > do_ssl3_write @ 0x789228
// > ssl3_write_bytes @ 0x7895ac
// > ??> @ 0x5a6fc
//
// 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 ssl3_write_pending(_DWORD *a1, int a2, int a3, int a4)
{
_DWORD *v5; // r6
unsigned int v6; // r5
int v7; // r2
int v8; // r7
int v9; // r9
_DWORD *v10; // r4
int v11; // r2
_DWORD *v12; // r0
int v13; // r2
int v14; // r0
int v15; // r1
int v16; // r2
int v17; // r0
int v18; // r2
int v19; // r0
unsigned int v20; // r0
int v21; // r3
int result; // r0
v5 = a1 + 149;
if ( a1[701] > a4 || a1[704] != a3 && (a1[76] & 2) == 0 || a1[702] != a2 )
{
ERR_put_error(20, 159, 127, "ssl/record/rec_layer_s3.c", 902);
return -1;
}
v6 = 0;
v7 = a1[153];
v8 = 0;
while ( 1 )
{
while ( 1 )
{
v9 = v8 + v6;
v10 = &v5[v8 + v6];
if ( !v7 )
{
do
{
if ( v6 >= a1[143] - 1 )
break;
++v6;
v11 = v10[9];
v8 = 4 * v6;
v9 = 5 * v6;
v10 = &v5[5 * v6];
}
while ( !v11 );
}
v12 = (_DWORD *)_errno();
v13 = a1[3];
*v12 = 0;
if ( !v13 )
break;
v14 = v13;
v15 = v5[v9] + v10[3];
v16 = v10[4];
a1[5] = 2;
v17 = BIO_write(v14, v15, v16, 2);
v18 = v10[4];
if ( v17 == v18 )
goto LABEL_13;
if ( v17 <= 0 )
goto LABEL_16;
v7 = v18 - v17;
v19 = v10[3] + v17;
v10[4] = v7;
v10[3] = v19;
}
ERR_put_error(20, 159, 128, "ssl/record/rec_layer_s3.c", 921);
v18 = v10[4];
if ( v18 != -1 )
break;
LABEL_13:
v20 = a1[143];
v21 = v10[3];
v10[4] = 0;
v10[3] = v21 + v18;
if ( v6 + 1 >= v20 )
{
result = a1[703];
a1[5] = 1;
return result;
}
v7 = 0;
}
LABEL_16:
result = -1;
if ( (*(_DWORD *)(*(_DWORD *)(a1[1] + 100) + 52) & 8) != 0 )
v10[4] = 0;
return result;
}