//
// sub_1006980F8 from 0x1006980f8 to 0x1006982a4 (428 bytes)
//
// 5 xrefs:
// > sub_1006976F8 @ 0x1006977f0
// > sub_1006982A4 @ 0x10069847c
// > sub_1006982A4 @ 0x1006984b4
// > sub_1006982A4 @ 0x1006984fc
// > sub_1006982A4 @ 0x100698600
//
// 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 11:11:35 +0000
//
__int64 __fastcall sub_1006980F8(int *a1)
{
int v2; // w21
__int64 v3; // x0
__int64 v4; // x8
__int64 v5; // x9
__int64 v6; // x10
int v7; // w11
int *v8; // x12
int v10; // w13
__int64 v11; // x8
v2 = *a1;
time((time_t *)a1 + 5);
v3 = sub_1006903E8(**((_QWORD ***)a1 + 2), nullptr, v2 == 0);
if ( v3 < 0 )
{
sub_10067889C(**((_QWORD **)a1 + 2), "Connection time-out");
return 28;
}
if ( v2 )
{
v4 = 3600;
if ( v3 >= 1 )
v4 = (v3 + 500) / 1000;
v5 = *((_QWORD *)a1 + 5);
v6 = v5 + v4;
*((_QWORD *)a1 + 6) = v5 + v4;
v7 = (int)v4 / 5;
a1[9] = (int)v4 / 5;
v8 = a1 + 9;
}
else
{
v4 = (v3 + 500) / 1000;
v5 = *((_QWORD *)a1 + 5);
v6 = v5 + v4;
*((_QWORD *)a1 + 6) = v5 + v4;
v7 = (int)v4 / 5;
if ( (int)v4 < 5 )
v7 = 1;
a1[9] = v7;
v8 = a1 + 9;
if ( (int)v4 / v7 >= 1 )
v10 = (int)v4 / v7;
else
v10 = 1;
a1[8] = v10;
}
if ( v7 <= 2 )
{
v7 = 3;
LABEL_17:
*v8 = v7;
goto LABEL_18;
}
if ( v7 >= 51 )
{
v7 = 50;
goto LABEL_17;
}
LABEL_18:
v11 = v4 / v7;
if ( (int)v11 < 1 )
LODWORD(v11) = 1;
a1[8] = v11;
sub_10067860C(
**((_QWORD **)a1 + 2),
"set timeouts for state %d; Total %ld, retry %d maxtry %d\n",
*a1,
v6 - v5,
v11,
v7);
time((time_t *)a1 + 7);
return 0;
}