//
// sub_8576BC from 0x8576bc to 0x8577a0 (228 bytes)
//
// 1 xrefs:
// > sub_85A74C @ 0x85aa14
//
// 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_8576BC(_DWORD *a1, _DWORD *a2)
{
int v2; // r2
int v3; // r3
int v5; // r1
int v7; // r7
_DWORD v9[3]; // [sp+Ch] [bp-Ch] BYREF
v2 = a2[57];
v3 = a1[1139];
v5 = a1[1138];
v9[0] = v2;
v9[1] = 1;
v9[2] = 0;
if ( v5 >= v3 )
{
lws_log(1, "Too many fds (%d)\n", v3);
return 1;
}
else if ( v2 >= v3 )
{
lws_log(1, "Socket fd %d is too high (%d)\n", v2, v3);
return 1;
}
else
{
if ( (*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, int))(a1[11] + 4))(a2, 35, a2[48], v9, 1) )
return -1;
*(_DWORD *)(a1[7] + 4 * a2[57]) = a2;
v7 = a2[57];
a2[59] = a1[1138];
*(_DWORD *)(a1[6] + 8 * a1[1138]) = v7;
*(_WORD *)(a1[6] + 8 * a1[1138] + 4) = 1;
lws_plat_insert_socket_into_fds(a1, a2);
if ( (*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, _DWORD))(a1[11] + 4))(a2, 32, a2[48], v9, 0) )
return -1;
else
return -((*(int (__fastcall **)(_DWORD *, int, _DWORD, _DWORD *, int))(a1[11] + 4))(a2, 36, a2[48], v9, 1) != 0);
}
}