//
// sub_10056A3E4 from 0x10056a3e4 to 0x10056a5f4 (528 bytes)
//
// 2 xrefs:
// > sub_10055CB44 @ 0x10055cc0c
// > sub_10056A6B8 @ 0x10056ab0c
//
// 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_10056A3E4(__int64 result, int a2)
{
__int64 v3; // x20
__int64 v4; // x19
_OWORD *v5; // x21
_OWORD *v6; // x22
_OWORD *v7; // x8
_OWORD *v8; // x9
__int64 v9; // x21
__int64 v10; // x21
__int64 v11; // x21
__int64 v12; // x21
socklen_t v13; // [xsp+24h] [xbp-14Ch] BYREF
sockaddr __b[8]; // [xsp+28h] [xbp-148h] BYREF
sockaddr v15; // [xsp+A8h] [xbp-C8h] BYREF
v3 = result;
if ( *(_DWORD *)(result + 172) != 2 )
{
v4 = *(_QWORD *)result;
if ( *(_BYTE *)(result + 738) )
{
v5 = (_OWORD *)(result + 252);
v6 = (_OWORD *)(result + 312);
LABEL_4:
*(_OWORD *)(v4 + 35862) = *(_OWORD *)((char *)v5 + 30);
*(_OWORD *)(v4 + 35848) = v5[1];
*(_OWORD *)(v4 + 35832) = *v5;
v7 = *(_OWORD **)v3;
*(_OWORD *)((char *)v7 + 35918) = *(_OWORD *)((char *)v6 + 30);
v7[2244] = v6[1];
v7[2243] = *v6;
v8 = *(_OWORD **)v3;
*((_QWORD *)v8 + 4485) = *(_QWORD *)(v3 + 304);
*((_QWORD *)v8 + 4492) = *(_QWORD *)(v3 + 360);
return result;
}
v13 = 128;
if ( getpeername(a2, &v15, &v13) )
{
v9 = (unsigned int)*__error();
sub_100570168(v3, v9);
return sub_100552734(v4, "getpeername() failed with errno %d: %s");
}
else
{
v13 = 128;
memset(__b, 0, sizeof(__b));
if ( getsockname(a2, __b, &v13) )
{
v10 = (unsigned int)*__error();
sub_100570168(v3, v10);
return sub_100552734(v4, "getsockname() failed with errno %d: %s");
}
else
{
v5 = (_OWORD *)(v3 + 252);
if ( (sub_10056A5F4((int)&v15, (char *)(v3 + 252)) & 1) != 0 )
{
*(_OWORD *)(v3 + 150) = *(_OWORD *)(v3 + 282);
*(_OWORD *)(v3 + 136) = *(_OWORD *)(v3 + 268);
*(_OWORD *)(v3 + 120) = *v5;
v6 = (_OWORD *)(v3 + 312);
result = sub_10056A5F4((int)__b, (char *)(v3 + 312));
if ( (_DWORD)result )
{
v4 = *(_QWORD *)v3;
goto LABEL_4;
}
v12 = (unsigned int)*__error();
sub_100570168(v3, v12);
return sub_100552734(v4, "ssloc inet_ntop() failed with errno %d: %s");
}
else
{
v11 = (unsigned int)*__error();
sub_100570168(v3, v11);
return sub_100552734(v4, "ssrem inet_ntop() failed with errno %d: %s");
}
}
}
}
return result;
}