//
// sub_82AA64 from 0x82aa64 to 0x82ab88 (292 bytes)
//
// 2 xrefs:
// > sub_82ABA4 @ 0x82ac04
// > sub_82C054 @ 0x82c1ca
//
// 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:01:59 +0000
//
int __fastcall sub_82AA64(int a1, _BYTE *a2)
{
_DWORD *v2; // r5
int v3; // r3
int v4; // r9
int v6; // r4
int v8; // r0
bool v9; // cc
int v10; // r4
unsigned __int8 *v11; // r3
int result; // r0
int v13; // r2
int v14; // r3
int v15; // [sp+4h] [bp-4h]
__time_t v16[3]; // [sp+8h] [bp+0h] BYREF
int v17; // [sp+14h] [bp+Ch] BYREF
int v18; // [sp+18h] [bp+10h] BYREF
int v19; // [sp+1Ch] [bp+14h]
v2 = *(_DWORD **)a1;
v3 = *(_DWORD *)(a1 + 420);
v4 = *(_DWORD *)(a1 + 416);
*a2 = 0;
v6 = v2[130];
v15 = v3;
if ( v6 <= 0 )
v6 = 60000;
sub_81FA10(v16);
v18 = v16[0];
v19 = v16[1];
v8 = sub_83D604(v2, &v18, 0);
v9 = v8 < 0;
if ( v8 )
v9 = v8 < v6;
if ( !v9 )
{
v8 = v6 - sub_81FA58(v18, v19, v2[374], v2[375]);
if ( !v8 )
{
sub_8280FC((size_t)v2, "Checking for server connect\n");
goto LABEL_22;
}
}
v10 = v8;
sub_8280FC((size_t)v2, "Checking for server connect\n");
if ( v10 < 0 )
{
LABEL_22:
sub_828178((int)v2, "Accept timeout occurred while waiting server connect");
return 12;
}
if ( *(_DWORD *)(a1 + 1092) && (v11 = *(unsigned __int8 **)(a1 + 1088)) != nullptr && *v11 > 0x33u )
{
sub_8280FC((size_t)v2, "There is negative response in cache while serv connect\n");
sub_82A924(&v17, a1, &v18);
return 10;
}
else
{
result = sub_842E08(v4, v15, -1, 0);
v13 = result + 1;
if ( result == -1 )
{
sub_828178((int)v2, "Error while waiting for server connect", v13);
return 10;
}
else if ( result )
{
v14 = result << 28;
if ( (result & 8) != 0 )
{
sub_8280FC((size_t)v2, "Ready to accept data connection from server\n", v13, v14);
*a2 = 1;
return 0;
}
else
{
result &= 1u;
if ( result )
{
sub_8280FC((size_t)v2, "Ctrl conn has data while waiting for data conn\n", v13, v14);
sub_82A924(&v17, a1, &v18);
if ( v18 < 400 )
return 8;
else
return 10;
}
}
}
}
return result;
}