//
// sub_8577A8 from 0x8577a8 to 0x857890 (232 bytes)
//
// 4 xrefs:
// > sub_856B30 @ 0x856bdc
// > sub_856B30 @ 0x856cf2
// > sub_856B30 @ 0x856e7e
// > lws_client_reset @ 0x85ac00
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:02:37 +0000
//
int __fastcall sub_8577A8(_DWORD *a1)
{
_DWORD *v1; // r4
int v2; // r7
int v4; // r3
int v5; // r2
int v6; // r7
int v7; // r9
int *v8; // r1
int v9; // r0
int v10; // r1
_DWORD *v11; // r7
int v12; // r3
_DWORD v14[3]; // [sp+Ch] [bp-Ch] BYREF
v1 = (_DWORD *)a1[46];
v2 = a1[57];
v4 = v1[1139];
--v1[1138];
v5 = a1[57];
v14[1] = 0;
v14[0] = v2;
v14[2] = 0;
if ( v5 > v4 )
{
lws_log(1, "Socket fd %d too high (%d)\n", v5, v4);
return 1;
}
else
{
if ( (*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, int))(v1[11] + 4))(a1, 35, a1[48], v14, 1) )
return -1;
v6 = v1[6];
v7 = a1[59];
v8 = (int *)(v6 + 8 * v1[1138]);
v9 = *v8;
v10 = v8[1];
v11 = (_DWORD *)(v6 + 8 * v7);
*v11 = v9;
v11[1] = v10;
lws_plat_delete_socket_from_fds(v1, a1, v7);
*(_DWORD *)(*(_DWORD *)(v1[7] + 4 * *(_DWORD *)(v1[6] + 8 * v1[1138])) + 236) = v7;
*(_DWORD *)(v1[7] + 4 * a1[57]) = 0;
v12 = a1[57];
a1[59] = -1;
if ( v12 < 0 )
return -((*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, int))(v1[11] + 4))(a1, 36, a1[48], v14, 1) != 0);
if ( (*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, _DWORD))(v1[11] + 4))(a1, 33, a1[48], v14, 0) )
return -1;
else
return -((*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, int))(v1[11] + 4))(a1, 36, a1[48], v14, 1) != 0);
}
}