//
// sub_E16B58 from 0xe16b58 to 0xe16d28 (464 bytes)
//
// 5 xrefs:
// > sub_E17090 @ 0xe17134
// > sub_E17400 @ 0xe174ec
// > sub_E17400 @ 0xe177e0
// > sub_E17400 @ 0xe17824
// > sub_E17400 @ 0xe17878
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:09:42 +0000
//
__int64 __fastcall sub_E16B58(__int64 a1)
{
_BOOL4 v2; // w20
__int64 v3; // x0
__int64 v4; // x0
int v5; // w5
__int64 v6; // x3
__int64 v7; // x2
__int64 v8; // x1
__int64 v9; // x0
int v10; // w4
v2 = *(_DWORD *)a1 == 0;
time((time_t *)(a1 + 40));
v3 = sub_E0E488(**(_QWORD ***)(a1 + 16), nullptr, v2);
if ( (v3 & 0x8000000000000000LL) == 0 )
{
if ( v2 )
{
v6 = *(_QWORD *)(a1 + 40);
v4 = (v3 + 500) / 1000;
v7 = v6 + v4;
*(_QWORD *)(a1 + 48) = v6 + v4;
v5 = (int)v4 / 5;
if ( (int)v4 / 5 <= 0 )
v5 = 1;
*(_DWORD *)(a1 + 36) = v5;
if ( (int)v4 / v5 <= 0 )
*(_DWORD *)(a1 + 32) = 1;
else
*(_DWORD *)(a1 + 32) = (int)v4 / v5;
if ( v5 <= 2 )
goto LABEL_6;
}
else
{
if ( v3 )
{
v4 = (v3 + 500) / 1000;
v5 = (int)v4 / 5;
}
else
{
v5 = 720;
v4 = 3600;
}
v6 = *(_QWORD *)(a1 + 40);
*(_DWORD *)(a1 + 36) = v5;
v7 = v6 + v4;
*(_QWORD *)(a1 + 48) = v6 + v4;
if ( v5 <= 2 )
{
LABEL_6:
v8 = 3;
v5 = 3;
*(_DWORD *)(a1 + 36) = 3;
goto LABEL_7;
}
}
v8 = v5;
if ( v5 > 50 )
{
*(_DWORD *)(a1 + 36) = 50;
v5 = 50;
v9 = v4 / 50;
v10 = v9;
if ( (int)v9 > 0 )
goto LABEL_8;
goto LABEL_17;
}
LABEL_7:
v9 = v4 / v8;
v10 = v9;
if ( (int)v9 > 0 )
{
LABEL_8:
*(_DWORD *)(a1 + 32) = v9;
LABEL_9:
sub_DF16E0(
**(_QWORD **)(a1 + 16),
"set timeouts for state %d; Total %ld, retry %d maxtry %d\n",
*(_DWORD *)a1,
v7 - v6,
v10,
v5);
time((time_t *)(a1 + 56));
return 0;
}
LABEL_17:
v10 = 1;
*(_DWORD *)(a1 + 32) = 1;
goto LABEL_9;
}
sub_DF1848(**(_QWORD **)(a1 + 16), "Connection time-out");
return 28;
}