//
// sub_1005865FC from 0x1005865fc to 0x10058673c (320 bytes)
//
// 1 xrefs:
// > sub_1005834D0 @ 0x100585e14
//
// 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_1005865FC(__int64 *a1, int a2, __int64 a3, __int64 a4, int *a5)
{
__int64 *v8; // x21
__int64 result; // x0
__int64 v10; // x0
int v11; // w8
__int64 v12; // x20
const char *v13; // x1
__int64 v14; // x0
__int64 v15; // x0
__int64 v16; // [xsp+0h] [xbp-C0h]
char v17[120]; // [xsp+10h] [xbp-B0h] BYREF
sub_1005E1158(a1);
v8 = &a1[5 * a2];
LODWORD(result) = sub_10053EC38(v8[68]);
if ( (int)result > 0 )
{
*a5 = 0;
return (int)result;
}
v10 = sub_100540544(v8[68], result);
if ( (_DWORD)v10 == 5 )
{
v12 = *a1;
v16 = (unsigned int)*__error();
v13 = "SSL_write() returned SYSCALL, errno = %d";
LABEL_9:
v15 = v12;
LABEL_11:
sub_100552734(v15, v13, v16);
v11 = 55;
goto LABEL_12;
}
if ( (_DWORD)v10 == 1 )
{
v14 = sub_1005E11DC(v10);
v12 = *a1;
v16 = sub_1005E189C(v14, v17);
v13 = "SSL_write() error: %s";
goto LABEL_9;
}
if ( (unsigned int)(v10 - 2) > 1 )
{
v16 = v10;
v13 = "SSL_write() return error %d";
v15 = *a1;
goto LABEL_11;
}
v11 = 81;
LABEL_12:
*a5 = v11;
return -1;
}