//
// sub_D797FC from 0xd797fc to 0xd79908 (268 bytes)
//
// 1 xrefs:
// > ??> @ 0x1122538
//
// 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_D797FC(_DWORD *a1, int a2, int a3, _DWORD *a4)
{
_DWORD *v6; // [xsp+20h] [xbp+20h]
int v7; // [xsp+28h] [xbp+28h]
if ( a2 > 12 )
{
if ( a2 == 104 )
{
if ( a1 && a1[7] )
{
if ( a1[6] )
{
v6 = a4;
v7 = a3;
BIO_closesocket(a1[10]);
a4 = v6;
a3 = v7;
}
a1[6] = 0;
a1[8] = 0;
}
a1[10] = *a4;
a1[7] = a3;
a1[6] = 1;
return 1;
}
else
{
if ( a2 != 105 )
return 0;
if ( a1[6] )
{
if ( a4 )
*a4 = a1[10];
return (int)a1[10];
}
else
{
return -1;
}
}
}
else
{
if ( a2 >= 11 )
return 1;
if ( a2 != 8 )
{
if ( a2 == 9 )
{
a1[7] = a3;
return 1;
}
return 0;
}
return (int)a1[7];
}
}