//
// sub_100539AB4 from 0x100539ab4 to 0x100539b8c (216 bytes)
//
// 3 xrefs:
// > sub_1005398EC @ 0x100539940
// > sub_100539B8C @ 0x100539ba4
// > sub_100539D94 @ 0x100539da4
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
_QWORD *__fastcall sub_100539AB4(__int64 a1, _QWORD *a2)
{
__int64 v4; // x8
__int64 v5; // x9
__darwin_time_t v6; // x10
__darwin_time_t tv_sec; // x8
__darwin_suseconds_t tv_usec; // w10
__darwin_time_t v9; // x9
int v10; // w8
timeval v12; // [xsp+0h] [xbp-20h] BYREF
v4 = *(_QWORD *)(a1 + 136);
if ( !*(_QWORD *)(v4 + 848) && !*(_DWORD *)(v4 + 856) )
return nullptr;
gettimeofday(&v12, nullptr);
v5 = *(_QWORD *)(a1 + 136);
v6 = *(_QWORD *)(v5 + 848);
tv_sec = v12.tv_sec;
if ( v6 < v12.tv_sec )
goto LABEL_11;
if ( v6 == v12.tv_sec )
{
tv_usec = v12.tv_usec;
if ( *(_DWORD *)(v5 + 856) <= v12.tv_usec )
{
LABEL_11:
a2[1] = 0;
*a2 = 0;
return a2;
}
}
else
{
tv_usec = v12.tv_usec;
}
*(_OWORD *)a2 = *(_OWORD *)(v5 + 848);
v9 = *a2 - tv_sec;
*a2 = v9;
v10 = *((_DWORD *)a2 + 2) - tv_usec;
*((_DWORD *)a2 + 2) = v10;
if ( v10 < 0 )
{
*a2 = --v9;
v10 += 1000000;
*((_DWORD *)a2 + 2) = v10;
}
if ( !v9 && v10 <= 14999 )
goto LABEL_11;
return a2;
}